Skip to content

Commit 2587952

Browse files
committed
Fixes sys.winver generation and removes dependency on user32.dll
1 parent a39eb0f commit 2587952

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

PC/dl_nt.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ forgotten) from the programmer.
1212
#include "windows.h"
1313

1414
#ifdef Py_ENABLE_SHARED
15+
#ifdef MS_DLL_ID
16+
// The string is available at build, so fill the buffer immediately
17+
char dllVersionBuffer[16] = MS_DLL_ID;
18+
#else
1519
char dllVersionBuffer[16] = ""; // a private buffer
20+
#endif
1621

1722
// Python Globals
1823
HMODULE PyWin_DLLhModule = NULL;
@@ -88,8 +93,11 @@ BOOL WINAPI DllMain (HANDLE hInst,
8893
{
8994
case DLL_PROCESS_ATTACH:
9095
PyWin_DLLhModule = hInst;
96+
#ifndef MS_DLL_ID
97+
// If we have MS_DLL_ID, we don't need to load the string.
9198
// 1000 is a magic number I picked out of the air. Could do with a #define, I spose...
9299
LoadString(hInst, 1000, dllVersionBuffer, sizeof(dllVersionBuffer));
100+
#endif
93101

94102
#if HAVE_SXS
95103
// and capture our activation context for use when loading extensions.

PCbuild/pyproject.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
<WriteLinesToFile File="$(PySourcePath)PC\pythonnt_rc$(PyDebugExt).h" Overwrite="true" Encoding="ascii"
8888
Lines='/* This file created by python.props /t:GeneratePythonNtRcH */
8989
#define FIELD3 $(Field3Value)
90-
#define MS_DLL_ID "$(PythonMajorVersion).$(PythonMinorVersion)"
90+
#define MS_DLL_ID "$(SysWinVer)"
9191
#define PYTHON_DLL_NAME "$(PyDllName).dll"
9292
' />
9393
<ItemGroup>

PCbuild/python.props

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" TreatAsLocalProperty="Platform">
33
<PropertyGroup>
4-
<Platform Condition="'$(Platform)' == ''">Win32</Platform>
4+
<Platform Condition="'$(Platform)' == '' or '$(Platform)' == 'x86'">Win32</Platform>
55
<Configuration Condition="'$(Configuration)' == ''">Release</Configuration>
66
<!--
77
Use the latest available version of Visual Studio to build. To override
@@ -100,6 +100,10 @@
100100
<!-- The version and platform tag to include in .pyd filenames -->
101101
<PydTag Condition="$(Platform) == 'Win32'">.cp$(MajorVersionNumber)$(MinorVersionNumber)-win32</PydTag>
102102
<PydTag Condition="$(Platform) == 'x64'">.cp$(MajorVersionNumber)$(MinorVersionNumber)-win_amd64</PydTag>
103+
104+
<!-- The version number for sys.winver -->
105+
<SysWinVer>$(MajorVersionNumber).$(MinorVersionNumber)</SysWinVer>
106+
<SysWinVer Condition="$(Platform) == 'Win32'">$(SysWinVer)-32</SysWinVer>
103107
</PropertyGroup>
104108

105109
<!-- Displays the calculated version info -->

PCbuild/pythoncore.vcxproj

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
<ClCompile>
6868
<AdditionalOptions>/Zm200 %(AdditionalOptions)</AdditionalOptions>
6969
<AdditionalIncludeDirectories>$(PySourcePath)Python;$(PySourcePath)Modules\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
70-
<PreprocessorDefinitions>_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED;%(PreprocessorDefinitions)</PreprocessorDefinitions>
70+
<PreprocessorDefinitions>_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED;MS_DLL_ID="$(SysWinVer)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
7171
</ClCompile>
7272
<Link>
7373
<AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
@@ -335,7 +335,6 @@
335335
<ClCompile Include="..\Parser\tokenizer.c" />
336336
<ClCompile Include="..\PC\winreg.c" />
337337
<ClCompile Include="..\PC\config.c" />
338-
<ClCompile Include="..\PC\dl_nt.c" />
339338
<ClCompile Include="..\PC\getpathp.c" />
340339
<ClCompile Include="..\PC\msvcrtmodule.c" />
341340
<ClCompile Include="..\Python\pyhash.c" />
@@ -386,14 +385,17 @@
386385
<ClCompile Include="..\Python\thread.c" />
387386
<ClCompile Include="..\Python\traceback.c" />
388387
</ItemGroup>
388+
<ItemGroup>
389+
<ClCompile Include="..\PC\dl_nt.c" />
390+
</ItemGroup>
389391
<ItemGroup>
390392
<ResourceCompile Include="..\PC\python_nt.rc" />
391393
</ItemGroup>
392394
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
393395
<ImportGroup Label="ExtensionTargets">
394396
</ImportGroup>
395397

396-
<Target Name="_GetBuildInfo" AfterTargets="PrepareForBuild">
398+
<Target Name="_GetBuildInfo" BeforeTargets="PrepareForBuild">
397399
<Exec Command='hg id -b &gt; "$(IntDir)hgbranch.txt"' ContinueOnError="true" />
398400
<Exec Command='hg id -i &gt; "$(IntDir)hgversion.txt"' ContinueOnError="true" />
399401
<Exec Command='hg id -t &gt; "$(IntDir)hgtag.txt"' ContinueOnError="true" />

0 commit comments

Comments
 (0)