Skip to content

Commit b27f3c3

Browse files
committed
Issue #24986: Allow building Python without external libraries on Windows
This modifies the behavior of the '-e' flag to PCbuild\build.bat: when '-e' is not supplied, no attempt will be made to build extension modules that require external libraries, even if the external libraries are present. Also adds '--no-<module>' flags to PCbuild\build.bat, where '<module>' is one of 'ssl', 'tkinter', or 'bsddb', to allow skipping just those modules (if '-e' is given).
1 parent e74fe18 commit b27f3c3

3 files changed

Lines changed: 38 additions & 6 deletions

File tree

Misc/NEWS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ Tests
6262
- PCbuild\rt.bat now accepts an unlimited number of arguments to pass along
6363
to regrtest.py. Previously there was a limit of 9.
6464

65+
Build
66+
-----
67+
68+
- Issue #24986: It is now possible to build Python on Windows without errors
69+
when external libraries are not available.
70+
6571

6672
What's New in Python 3.5.0 release candidate 3?
6773
===============================================

PCbuild/build.bat

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,19 @@ echo. -V Display version information for the current build
1818
echo. -r Target Rebuild instead of Build
1919
echo. -d Set the configuration to Debug
2020
echo. -e Build external libraries fetched by get_externals.bat
21+
echo. Extension modules that depend on external libraries will not attempt
22+
echo. to build if this flag is not present
2123
echo. -m Enable parallel build (enabled by default)
2224
echo. -M Disable parallel build
2325
echo. -v Increased output messages
2426
echo. -k Attempt to kill any running Pythons before building (usually done
2527
echo. automatically by the pythoncore project)
2628
echo.
29+
echo.Available flags to avoid building certain modules.
30+
echo.These flags have no effect if '-e' is not given:
31+
echo. --no-ssl Do not attempt to build _ssl
32+
echo. --no-tkinter Do not attempt to build Tkinter
33+
echo.
2734
echo.Available arguments:
2835
echo. -c Release ^| Debug ^| PGInstrument ^| PGUpdate
2936
echo. Set the configuration (default: Release)
@@ -51,12 +58,21 @@ if "%~1"=="-p" (set platf=%2) & shift & shift & goto CheckOpts
5158
if "%~1"=="-r" (set target=Rebuild) & shift & goto CheckOpts
5259
if "%~1"=="-t" (set target=%2) & shift & shift & goto CheckOpts
5360
if "%~1"=="-d" (set conf=Debug) & shift & goto CheckOpts
54-
if "%~1"=="-e" call "%dir%get_externals.bat" & shift & goto CheckOpts
5561
if "%~1"=="-m" (set parallel=/m) & shift & goto CheckOpts
5662
if "%~1"=="-M" (set parallel=) & shift & goto CheckOpts
5763
if "%~1"=="-v" (set verbose=/v:n) & shift & goto CheckOpts
5864
if "%~1"=="-k" (set kill=true) & shift & goto CheckOpts
5965
if "%~1"=="-V" shift & goto Version
66+
rem These use the actual property names used by MSBuild. We could just let
67+
rem them in through the environment, but we specify them on the command line
68+
rem anyway for visibility so set defaults after this
69+
if "%~1"=="-e" (set IncludeExternals=true) & call "%dir%get_externals.bat" & shift & goto CheckOpts
70+
if "%~1"=="--no-ssl" (set IncludeSSL=false) & shift & goto CheckOpts
71+
if "%~1"=="--no-tkinter" (set IncludeTkinter=false) & shift & goto CheckOpts
72+
73+
if "%IncludeExternals%"=="" set IncludeExternals=false
74+
if "%IncludeSSL%"=="" set IncludeSSL=true
75+
if "%IncludeTkinter%"=="" set IncludeTkinter=true
6076

6177
if "%platf%"=="x64" (set vs_platf=x86_amd64)
6278

@@ -71,7 +87,11 @@ rem Call on MSBuild to do the work, echo the command.
7187
rem Passing %1-9 is not the preferred option, but argument parsing in
7288
rem batch is, shall we say, "lackluster"
7389
echo on
74-
msbuild "%dir%pcbuild.proj" /t:%target% %parallel% %verbose% /p:Configuration=%conf% /p:Platform=%platf% %1 %2 %3 %4 %5 %6 %7 %8 %9
90+
msbuild "%dir%pcbuild.proj" /t:%target% %parallel% %verbose%^
91+
/p:Configuration=%conf% /p:Platform=%platf%^
92+
/p:IncludeExternals=%IncludeExternals%^
93+
/p:IncludeSSL=%IncludeSSL% /p:IncludeTkinter=%IncludeTkinter%^
94+
%1 %2 %3 %4 %5 %6 %7 %8 %9
7595

7696
@goto :eof
7797

PCbuild/pcbuild.proj

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
<Platform Condition="'$(Platform)' == ''">Win32</Platform>
66
<Configuration Condition="'$(Configuration)' == ''">Release</Configuration>
77
<IncludeExtensions Condition="'$(IncludeExtensions)' == ''">true</IncludeExtensions>
8+
<IncludeExternals Condition="'$(IncludeExternals)' == ''">true</IncludeExternals>
89
<IncludeTests Condition="'$(IncludeTest)' == ''">true</IncludeTests>
910
<IncludeSSL Condition="'$(IncludeSSL)' == ''">true</IncludeSSL>
11+
<IncludeTkinter Condition="'$(IncludeTkinter)' == ''">true</IncludeTkinter>
1012
</PropertyGroup>
1113

1214
<ItemDefinitionGroup>
@@ -25,7 +27,7 @@
2527
<!--
2628
Parallel build is explicitly disabled for this project because it
2729
causes many conflicts between pythoncore and projects that depend
28-
in pythoncore. Once the core DLL has been built, subsequent
30+
on pythoncore. Once the core DLL has been built, subsequent
2931
projects will be built in parallel.
3032
-->
3133
<Projects Include="pythoncore.vcxproj">
@@ -40,10 +42,14 @@
4042
<!-- _freeze_importlib -->
4143
<Projects Include="_freeze_importlib.vcxproj" />
4244
<!-- Extension modules -->
43-
<ExtensionModules Include="_bz2;_ctypes;_decimal;_elementtree;_lzma;_msi;_multiprocessing;_overlapped;_sqlite3;_tkinter;tix;pyexpat;select;unicodedata;winsound" />
45+
<ExtensionModules Include="_ctypes;_decimal;_elementtree;_msi;_multiprocessing;_overlapped;pyexpat;select;unicodedata;winsound" />
46+
<!-- Extension modules that require external sources -->
47+
<ExternalModules Include="_bz2;_lzma;_sqlite3" />
4448
<!-- _ssl will build _socket as well, which may cause conflicts in parallel builds -->
45-
<ExtensionModules Include="_socket" Condition="!$(IncludeSSL)" />
46-
<ExtensionModules Include="_ssl;_hashlib" Condition="$(IncludeSSL)" />
49+
<ExtensionModules Include="_socket" Condition="!$(IncludeSSL) or !$(IncludeExternals)" />
50+
<ExternalModules Include="_ssl;_hashlib" Condition="$(IncludeSSL)" />
51+
<ExternalModules Include="_tkinter;tix" Condition="$(IncludeTkinter)" />
52+
<ExtensionModules Include="@(ExternalModules->'%(Identity)')" Condition="$(IncludeExternals)" />
4753
<Projects Include="@(ExtensionModules->'%(Identity).vcxproj')" Condition="$(IncludeExtensions)" />
4854
<!-- Test modules -->
4955
<TestModules Include="_ctypes_test;_testbuffer;_testcapi;_testembed;_testimportmultiple;_testmultiphase" />

0 commit comments

Comments
 (0)