Skip to content

Commit 2507e29

Browse files
authored
bpo-32588: Move _findvs into its own module and add missing _queue module to installer (#5227)
1 parent fa78806 commit 2507e29

File tree

11 files changed

+132
-23
lines changed

11 files changed

+132
-23
lines changed

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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Create standalone _distutils_findvs module and add missing _queue module to
2+
installer.

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 -- */
@@ -162,8 +161,6 @@ struct _inittab _PyImport_Inittab[] = {
162161
{"_stat", PyInit__stat},
163162
{"_opcode", PyInit__opcode},
164163

165-
{"_findvs", PyInit__findvs},
166-
167164
/* Sentinel */
168165
{0, 0}
169166
};

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;_queue;select;unicodedata;winsound" />
52+
<ExtensionModules Include="_asyncio;_ctypes;_decimal;_distutils_findvs;_elementtree;_msi;_multiprocessing;_overlapped;pyexpat;_queue;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: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Microsoft Visual Studio Solution File, Format Version 12.00
22
# Visual Studio 15
3-
VisualStudioVersion = 15.0.26621.2
3+
VisualStudioVersion = 15.0.27130.2024
44
MinimumVisualStudioVersion = 10.0.40219.1
55
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{553EC33E-9816-4996-A660-5D6186A0B0B3}"
66
ProjectSection(SolutionItems) = preProject
@@ -93,6 +93,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_queue", "_queue.vcxproj",
9393
EndProject
9494
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "liblzma", "liblzma.vcxproj", "{12728250-16EC-4DC6-94D7-E21DD88947F8}"
9595
EndProject
96+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_distutils_findvs", "_distutils_findvs.vcxproj", "{41ADEDF9-11D8-474E-B4D7-BB82332C878E}"
97+
EndProject
9698
Global
9799
GlobalSection(SolutionConfigurationPlatforms) = preSolution
98100
Debug|Win32 = Debug|Win32
@@ -693,6 +695,22 @@ Global
693695
{12728250-16EC-4DC6-94D7-E21DD88947F8}.Release|Win32.Build.0 = Release|Win32
694696
{12728250-16EC-4DC6-94D7-E21DD88947F8}.Release|x64.ActiveCfg = Release|x64
695697
{12728250-16EC-4DC6-94D7-E21DD88947F8}.Release|x64.Build.0 = Release|x64
698+
{41ADEDF9-11D8-474E-B4D7-BB82332C878E}.Debug|Win32.ActiveCfg = Debug|Win32
699+
{41ADEDF9-11D8-474E-B4D7-BB82332C878E}.Debug|Win32.Build.0 = Debug|Win32
700+
{41ADEDF9-11D8-474E-B4D7-BB82332C878E}.Debug|x64.ActiveCfg = Debug|x64
701+
{41ADEDF9-11D8-474E-B4D7-BB82332C878E}.Debug|x64.Build.0 = Debug|x64
702+
{41ADEDF9-11D8-474E-B4D7-BB82332C878E}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32
703+
{41ADEDF9-11D8-474E-B4D7-BB82332C878E}.PGInstrument|Win32.Build.0 = PGInstrument|Win32
704+
{41ADEDF9-11D8-474E-B4D7-BB82332C878E}.PGInstrument|x64.ActiveCfg = PGInstrument|x64
705+
{41ADEDF9-11D8-474E-B4D7-BB82332C878E}.PGInstrument|x64.Build.0 = PGInstrument|x64
706+
{41ADEDF9-11D8-474E-B4D7-BB82332C878E}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32
707+
{41ADEDF9-11D8-474E-B4D7-BB82332C878E}.PGUpdate|Win32.Build.0 = PGUpdate|Win32
708+
{41ADEDF9-11D8-474E-B4D7-BB82332C878E}.PGUpdate|x64.ActiveCfg = PGUpdate|x64
709+
{41ADEDF9-11D8-474E-B4D7-BB82332C878E}.PGUpdate|x64.Build.0 = PGUpdate|x64
710+
{41ADEDF9-11D8-474E-B4D7-BB82332C878E}.Release|Win32.ActiveCfg = Release|Win32
711+
{41ADEDF9-11D8-474E-B4D7-BB82332C878E}.Release|Win32.Build.0 = Release|Win32
712+
{41ADEDF9-11D8-474E-B4D7-BB82332C878E}.Release|x64.ActiveCfg = Release|x64
713+
{41ADEDF9-11D8-474E-B4D7-BB82332C878E}.Release|x64.Build.0 = Release|x64
696714
EndGlobalSection
697715
GlobalSection(SolutionProperties) = preSolution
698716
HideSolutionNode = FALSE

PCbuild/pythoncore.vcxproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@
7575
</ClCompile>
7676
<Link>
7777
<AdditionalDependencies>version.lib;shlwapi.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
78-
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories);$(PySourcePath)PC\external\$(PlatformToolset)\$(ArchName)</AdditionalLibraryDirectories>
7978
</Link>
8079
</ItemDefinitionGroup>
8180
<ItemGroup>
@@ -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\_warnings.c" />
356354
<ClCompile Include="..\Python\asdl.c" />

Tools/msi/lib/lib_files.wxs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
3-
<?define exts=pyexpat;select;unicodedata;winsound;_bz2;_elementtree;_socket;_ssl;_msi;_ctypes;_hashlib;_multiprocessing;_lzma;_decimal;_overlapped;_sqlite3;_asyncio ?>
3+
<?define exts=pyexpat;select;unicodedata;winsound;_bz2;_elementtree;_socket;_ssl;_msi;_ctypes;_hashlib;_multiprocessing;_lzma;_decimal;_overlapped;_sqlite3;_asyncio;_queue;_distutils_findvs ?>
44
<Fragment>
55
<ComponentGroup Id="lib_extensions">
66
<?foreach ext in $(var.exts)?>

0 commit comments

Comments
 (0)