Skip to content

Commit ccf7f05

Browse files
authored
[3.6] bpo-32588 Move _distutils_findvs into its own module (GH-5227) (#5228)
1 parent f31c70b commit ccf7f05

11 files changed

Lines changed: 133 additions & 22 deletions

File tree

Lib/distutils/_msvccompiler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def _find_vc2015():
5656
return best_version, best_dir
5757

5858
def _find_vc2017():
59-
import _findvs
59+
import _distutils_findvs
6060
import threading
6161

6262
best_version = 0, # tuple for full version comparisons
@@ -66,7 +66,7 @@ def _find_vc2017():
6666
# initialize COM.
6767
all_packages = []
6868
def _getall():
69-
all_packages.extend(_findvs.findall())
69+
all_packages.extend(_distutils_findvs.findall())
7070
t = threading.Thread(target=_getall)
7171
t.start()
7272
t.join()

Lib/distutils/command/bdist_wininst.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -337,11 +337,10 @@ def get_exe_bytes(self):
337337
# cross-building, so assume the latest version
338338
bv = '14.0'
339339
else:
340-
bv = '.'.join(CRT_ASSEMBLY_VERSION.split('.', 2)[:2])
341-
if bv in ('14.11', '14.12'):
342-
# v142, v141 and v140 are binary compatible,
343-
# so keep using the 14.0 stub.
344-
bv = '14.0'
340+
# as far as we know, CRT is binary compatible based on
341+
# the first field, so assume 'x.0' until proven otherwise
342+
major = CRT_ASSEMBLY_VERSION.partition('.')[0]
343+
bv = major + '.0'
345344

346345

347346
# wininst-x.y.exe is in the same directory as this file
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Create standalone _distutils_findvs module.

PC/_findvs.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
#include <Windows.h>
1313
#include <Strsafe.h>
1414
#include "external\include\Setup.Configuration.h"
15-
#pragma comment(lib, "ole32.lib")
16-
#pragma comment(lib, "oleaut32.lib")
17-
#pragma comment(lib, "version.lib")
18-
#pragma comment(lib, "Microsoft.VisualStudio.Setup.Configuration.Native.lib")
1915

2016
#include <Python.h>
2117

@@ -236,7 +232,7 @@ static int exec_findvs(PyObject *module)
236232
return 0; // success
237233
}
238234

239-
PyDoc_STRVAR(findvs_doc, "The _findvs helper module");
235+
PyDoc_STRVAR(findvs_doc, "The _distutils_findvs helper module");
240236

241237
static PyModuleDef_Slot findvs_slots[] = {
242238
{ Py_mod_exec, exec_findvs },
@@ -245,7 +241,7 @@ static PyModuleDef_Slot findvs_slots[] = {
245241

246242
static PyModuleDef findvs_def = {
247243
PyModuleDef_HEAD_INIT,
248-
"_findvs",
244+
"_distutils_findvs",
249245
findvs_doc,
250246
0, // m_size
251247
NULL, // m_methods
@@ -256,8 +252,8 @@ static PyModuleDef findvs_def = {
256252
};
257253

258254
extern "C" {
259-
PyMODINIT_FUNC PyInit__findvs(void)
255+
PyMODINIT_FUNC PyInit__distutils_findvs(void)
260256
{
261257
return PyModuleDef_Init(&findvs_def);
262258
}
263-
}
259+
}

PC/config.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ extern PyObject* _PyWarnings_Init(void);
6969
extern PyObject* PyInit__string(void);
7070
extern PyObject* PyInit__stat(void);
7171
extern PyObject* PyInit__opcode(void);
72-
extern PyObject* PyInit__findvs(void);
7372

7473
/* tools/freeze/makeconfig.py marker for additional "extern" */
7574
/* -- ADDMODULE MARKER 1 -- */
@@ -166,8 +165,6 @@ struct _inittab _PyImport_Inittab[] = {
166165
{"_stat", PyInit__stat},
167166
{"_opcode", PyInit__opcode},
168167

169-
{"_findvs", PyInit__findvs},
170-
171168
/* Sentinel */
172169
{0, 0}
173170
};

PCbuild/_distutils_findvs.vcxproj

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Debug|x64">
9+
<Configuration>Debug</Configuration>
10+
<Platform>x64</Platform>
11+
</ProjectConfiguration>
12+
<ProjectConfiguration Include="PGInstrument|Win32">
13+
<Configuration>PGInstrument</Configuration>
14+
<Platform>Win32</Platform>
15+
</ProjectConfiguration>
16+
<ProjectConfiguration Include="PGInstrument|x64">
17+
<Configuration>PGInstrument</Configuration>
18+
<Platform>x64</Platform>
19+
</ProjectConfiguration>
20+
<ProjectConfiguration Include="PGUpdate|Win32">
21+
<Configuration>PGUpdate</Configuration>
22+
<Platform>Win32</Platform>
23+
</ProjectConfiguration>
24+
<ProjectConfiguration Include="PGUpdate|x64">
25+
<Configuration>PGUpdate</Configuration>
26+
<Platform>x64</Platform>
27+
</ProjectConfiguration>
28+
<ProjectConfiguration Include="Release|Win32">
29+
<Configuration>Release</Configuration>
30+
<Platform>Win32</Platform>
31+
</ProjectConfiguration>
32+
<ProjectConfiguration Include="Release|x64">
33+
<Configuration>Release</Configuration>
34+
<Platform>x64</Platform>
35+
</ProjectConfiguration>
36+
</ItemGroup>
37+
<PropertyGroup Label="Globals">
38+
<ProjectGuid>{41ADEDF9-11D8-474E-B4D7-BB82332C878E}</ProjectGuid>
39+
<RootNamespace>_distutils_findvs</RootNamespace>
40+
<Keyword>Win32Proj</Keyword>
41+
</PropertyGroup>
42+
<Import Project="python.props" />
43+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
44+
<PropertyGroup Label="Configuration">
45+
<ConfigurationType>DynamicLibrary</ConfigurationType>
46+
<CharacterSet>NotSet</CharacterSet>
47+
</PropertyGroup>
48+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
49+
<PropertyGroup>
50+
<TargetExt>.pyd</TargetExt>
51+
</PropertyGroup>
52+
<ImportGroup Label="ExtensionSettings">
53+
</ImportGroup>
54+
<ImportGroup Label="PropertySheets">
55+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
56+
<Import Project="pyproject.props" />
57+
</ImportGroup>
58+
<PropertyGroup Label="UserMacros" />
59+
<PropertyGroup>
60+
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
61+
</PropertyGroup>
62+
<ItemDefinitionGroup>
63+
<Link>
64+
<AdditionalDependencies>version.lib;ole32.lib;oleaut32.lib;Microsoft.VisualStudio.Setup.Configuration.Native.lib;%(AdditionalDependencies)</AdditionalDependencies>
65+
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories);$(PySourcePath)PC\external\$(PlatformToolset)\$(ArchName)</AdditionalLibraryDirectories>
66+
</Link>
67+
</ItemDefinitionGroup>
68+
<ItemGroup>
69+
<ClCompile Include="..\PC\_findvs.cpp" />
70+
</ItemGroup>
71+
<ItemGroup>
72+
<ResourceCompile Include="..\PC\python_nt.rc" />
73+
</ItemGroup>
74+
<ItemGroup>
75+
<ProjectReference Include="pythoncore.vcxproj">
76+
<Project>{cf7ac3d1-e2df-41d2-bea6-1e2556cdea26}</Project>
77+
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
78+
</ProjectReference>
79+
</ItemGroup>
80+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
81+
<ImportGroup Label="ExtensionTargets">
82+
</ImportGroup>
83+
</Project>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<ResourceCompile Include="..\PC\python_nt.rc" />
5+
</ItemGroup>
6+
<ItemGroup>
7+
<Filter Include="Source Files">
8+
<UniqueIdentifier>{c56a5dd3-7838-48e9-a781-855d8be7370f}</UniqueIdentifier>
9+
</Filter>
10+
</ItemGroup>
11+
<ItemGroup>
12+
<ClCompile Include="..\PC\_findvs.cpp">
13+
<Filter>Source Files</Filter>
14+
</ClCompile>
15+
</ItemGroup>
16+
</Project>

PCbuild/pcbuild.proj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
<!-- pyshellext.dll -->
5050
<Projects Include="pyshellext.vcxproj" />
5151
<!-- Extension modules -->
52-
<ExtensionModules Include="_asyncio;_ctypes;_decimal;_elementtree;_msi;_multiprocessing;_overlapped;pyexpat;select;unicodedata;winsound" />
52+
<ExtensionModules Include="_asyncio;_ctypes;_decimal;_distutils_findvs;_elementtree;_msi;_multiprocessing;_overlapped;pyexpat;select;unicodedata;winsound" />
5353
<!-- Extension modules that require external sources -->
5454
<ExternalModules Include="_bz2;_lzma;_sqlite3" />
5555
<!-- _ssl will build _socket as well, which may cause conflicts in parallel builds -->

PCbuild/pcbuild.sln

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_asyncio", "_asyncio.vcxpro
9898
EndProject
9999
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "liblzma", "liblzma.vcxproj", "{12728250-16EC-4DC6-94D7-E21DD88947F8}"
100100
EndProject
101+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_distutils_findvs", "_distutils_findvs.vcxproj", "{41ADEDF9-11D8-474E-B4D7-BB82332C878E}"
102+
EndProject
101103
Global
102104
GlobalSection(SolutionConfigurationPlatforms) = preSolution
103105
Debug|Win32 = Debug|Win32
@@ -762,8 +764,27 @@ Global
762764
{12728250-16EC-4DC6-94D7-E21DD88947F8}.Release|Win32.Build.0 = Release|Win32
763765
{12728250-16EC-4DC6-94D7-E21DD88947F8}.Release|x64.ActiveCfg = Release|x64
764766
{12728250-16EC-4DC6-94D7-E21DD88947F8}.Release|x64.Build.0 = Release|x64
767+
{41ADEDF9-11D8-474E-B4D7-BB82332C878E}.Debug|Win32.ActiveCfg = Debug|Win32
768+
{41ADEDF9-11D8-474E-B4D7-BB82332C878E}.Debug|Win32.Build.0 = Debug|Win32
769+
{41ADEDF9-11D8-474E-B4D7-BB82332C878E}.Debug|x64.ActiveCfg = Debug|x64
770+
{41ADEDF9-11D8-474E-B4D7-BB82332C878E}.Debug|x64.Build.0 = Debug|x64
771+
{41ADEDF9-11D8-474E-B4D7-BB82332C878E}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32
772+
{41ADEDF9-11D8-474E-B4D7-BB82332C878E}.PGInstrument|Win32.Build.0 = PGInstrument|Win32
773+
{41ADEDF9-11D8-474E-B4D7-BB82332C878E}.PGInstrument|x64.ActiveCfg = PGInstrument|x64
774+
{41ADEDF9-11D8-474E-B4D7-BB82332C878E}.PGInstrument|x64.Build.0 = PGInstrument|x64
775+
{41ADEDF9-11D8-474E-B4D7-BB82332C878E}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32
776+
{41ADEDF9-11D8-474E-B4D7-BB82332C878E}.PGUpdate|Win32.Build.0 = PGUpdate|Win32
777+
{41ADEDF9-11D8-474E-B4D7-BB82332C878E}.PGUpdate|x64.ActiveCfg = PGUpdate|x64
778+
{41ADEDF9-11D8-474E-B4D7-BB82332C878E}.PGUpdate|x64.Build.0 = PGUpdate|x64
779+
{41ADEDF9-11D8-474E-B4D7-BB82332C878E}.Release|Win32.ActiveCfg = Release|Win32
780+
{41ADEDF9-11D8-474E-B4D7-BB82332C878E}.Release|Win32.Build.0 = Release|Win32
781+
{41ADEDF9-11D8-474E-B4D7-BB82332C878E}.Release|x64.ActiveCfg = Release|x64
782+
{41ADEDF9-11D8-474E-B4D7-BB82332C878E}.Release|x64.Build.0 = Release|x64
765783
EndGlobalSection
766784
GlobalSection(SolutionProperties) = preSolution
767785
HideSolutionNode = FALSE
768786
EndGlobalSection
787+
GlobalSection(ExtensibilityGlobals) = postSolution
788+
SolutionGuid = {E8690CFE-326A-430E-82D4-B4CE667CC1BA}
789+
EndGlobalSection
769790
EndGlobal

PCbuild/pythoncore.vcxproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@
7171
</ClCompile>
7272
<Link>
7373
<AdditionalDependencies>version.lib;shlwapi.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
74-
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories);$(PySourcePath)PC\external\$(PlatformToolset)\$(ArchName)</AdditionalLibraryDirectories>
7574
<BaseAddress>0x1e000000</BaseAddress>
7675
</Link>
7776
</ItemDefinitionGroup>
@@ -350,7 +349,6 @@
350349
<ClCompile Include="..\PC\config.c" />
351350
<ClCompile Include="..\PC\getpathp.c" />
352351
<ClCompile Include="..\PC\msvcrtmodule.c" />
353-
<ClCompile Include="..\PC\_findvs.cpp" />
354352
<ClCompile Include="..\Python\pyhash.c" />
355353
<ClCompile Include="..\Python\random.c" />
356354
<ClCompile Include="..\Python\_warnings.c" />

0 commit comments

Comments
 (0)