Skip to content

Commit 043c876

Browse files
committed
Update build system for activestate builds
These are non-branding related camel build patches brought forward from the 3.7 and 3.8 core patches.
1 parent 14ac77e commit 043c876

File tree

4 files changed

+266
-34
lines changed

4 files changed

+266
-34
lines changed

PCbuild/build_activestate.bat

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
@echo off
2+
goto Run
3+
:Usage
4+
echo.%~nx0 [flags and arguments] [quoted MSBuild options]
5+
echo.
6+
echo.Build CPython from the command line. Requires the appropriate
7+
echo.version(s) of Microsoft Visual Studio to be installed (see readme.txt).
8+
echo.Also requires Subversion (svn.exe) to be on PATH if the '-e' flag is
9+
echo.given.
10+
echo.
11+
echo.After the flags recognized by this script, up to 9 arguments to be passed
12+
echo.directly to MSBuild may be passed. If the argument contains an '=', the
13+
echo.entire argument must be quoted (e.g. `%~nx0 "/p:PlatformToolset=v100"`)
14+
echo.
15+
echo.Available flags:
16+
echo. -h Display this help message
17+
echo. -V Display version information for the current build
18+
echo. -r Target Rebuild instead of Build
19+
echo. -d Set the configuration to Debug
20+
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
23+
echo. -m Enable parallel build (enabled by default)
24+
echo. -M Disable parallel build
25+
echo. -v Increased output messages
26+
echo. -k Attempt to kill any running Pythons before building (usually done
27+
echo. automatically by the pythoncore project)
28+
echo. --pgo Build with Profile-Guided Optimization. This flag
29+
echo. overrides -c and -d
30+
echo. --test-marker Enable the test marker within the build.
31+
echo.
32+
echo.Available flags to avoid building certain modules.
33+
echo.These flags have no effect if '-e' is not given:
34+
echo. --no-ssl Do not attempt to build _ssl
35+
echo. --no-tkinter Do not attempt to build Tkinter
36+
echo.
37+
echo.Available arguments:
38+
echo. -c Release ^| Debug ^| PGInstrument ^| PGUpdate
39+
echo. Set the configuration (default: Release)
40+
echo. -p x64 ^| Win32
41+
echo. Set the platform (default: Win32)
42+
echo. -t Build ^| Rebuild ^| Clean ^| CleanAll
43+
echo. Set the target manually
44+
echo. --pgo-job The job to use for PGO training; implies --pgo
45+
echo. (default: "-m test --pgo")
46+
exit /b 127
47+
48+
:Run
49+
setlocal
50+
set platf=Win32
51+
set vs_platf=x86
52+
set conf=Release
53+
set target=Build
54+
set dir=%~dp0
55+
set parallel=/m
56+
set verbose=/nologo /v:m
57+
set kill=
58+
set do_pgo=
59+
set pgo_job=-m test --pgo
60+
61+
:CheckOpts
62+
if "%~1"=="-h" goto Usage
63+
if "%~1"=="-c" (set conf=%2) & shift & shift & goto CheckOpts
64+
if "%~1"=="-p" (set platf=%2) & shift & shift & goto CheckOpts
65+
if "%~1"=="-r" (set target=Rebuild) & shift & goto CheckOpts
66+
if "%~1"=="-t" (set target=%2) & shift & shift & goto CheckOpts
67+
if "%~1"=="-d" (set conf=Debug) & shift & goto CheckOpts
68+
if "%~1"=="-m" (set parallel=/m) & shift & goto CheckOpts
69+
if "%~1"=="-M" (set parallel=) & shift & goto CheckOpts
70+
if "%~1"=="-v" (set verbose=/v:n) & shift & goto CheckOpts
71+
if "%~1"=="-k" (set kill=true) & shift & goto CheckOpts
72+
if "%~1"=="--pgo" (set do_pgo=true) & shift & goto CheckOpts
73+
if "%~1"=="--pgo-job" (set do_pgo=true) & (set pgo_job=%~2) & shift & shift & goto CheckOpts
74+
if "%~1"=="--test-marker" (set UseTestMarker=true) & shift & goto CheckOpts
75+
if "%~1"=="-V" shift & goto Version
76+
rem These use the actual property names used by MSBuild. We could just let
77+
rem them in through the environment, but we specify them on the command line
78+
rem anyway for visibility so set defaults after this
79+
if "%~1"=="-e" (set IncludeExternals=true) & shift & goto CheckOpts
80+
if "%~1"=="--no-ssl" (set IncludeSSL=false) & shift & goto CheckOpts
81+
if "%~1"=="--no-tkinter" (set IncludeTkinter=false) & shift & goto CheckOpts
82+
83+
if "%IncludeExternals%"=="" set IncludeExternals=false
84+
if "%IncludeSSL%"=="" set IncludeSSL=true
85+
if "%IncludeTkinter%"=="" set IncludeTkinter=true
86+
87+
rem UBS has called get_externals_activestate.bat before running the build
88+
rem if "%IncludeExternals%"=="true" call "%dir%get_externals_activestate.bat"
89+
90+
if "%do_pgo%" EQU "true" if "%platf%" EQU "x64" (
91+
if "%PROCESSOR_ARCHITEW6432%" NEQ "AMD64" if "%PROCESSOR_ARCHITECTURE%" NEQ "AMD64" (
92+
echo.ERROR: Cannot cross-compile with PGO
93+
echo. 32bit operating system detected. Ensure your PROCESSOR_ARCHITECTURE
94+
echo. and PROCESSOR_ARCHITEW6432 environment variables are correct.
95+
exit /b 1
96+
)
97+
)
98+
99+
if "%platf%"=="x64" (set vs_platf=x86_amd64)
100+
101+
rem Setup the environment
102+
call "%dir%env.bat" %vs_platf% >nul
103+
104+
if "%kill%"=="true" call :Kill
105+
106+
if "%do_pgo%"=="true" (
107+
set conf=PGInstrument
108+
call :Build
109+
del /s "%dir%\*.pgc"
110+
del /s "%dir%\..\Lib\*.pyc"
111+
echo on
112+
call "%dir%\..\python.bat" %pgo_job%
113+
@echo off
114+
call :Kill
115+
set conf=PGUpdate
116+
)
117+
goto Build
118+
119+
:Kill
120+
echo on
121+
msbuild "%dir%\pythoncore.vcxproj" /t:KillPython %verbose%^
122+
/p:Configuration=%conf% /p:Platform=%platf%^
123+
/p:KillPython=true
124+
125+
@echo off
126+
goto :eof
127+
128+
:Build
129+
rem Call on MSBuild to do the work, echo the command.
130+
rem Passing %1-9 is not the preferred option, but argument parsing in
131+
rem batch is, shall we say, "lackluster"
132+
echo on
133+
if "%IncludeSSL%"=="true" (
134+
if "%PERL%" == "" where perl > "%TEMP%\perl.loc" 2> nul && set /P PERL= <"%TEMP%\perl.loc" & del "%TEMP%\perl.loc"
135+
if "%PERL%" == "" (echo Cannot locate perl.exe on PATH or as PERL variable & exit /b 4)
136+
msbuild "%dir%openssl.vcxproj"^
137+
/p:Configuration=%conf% /p:Platform=%platf%
138+
)
139+
msbuild "%dir%pcbuild.proj" /t:%target% %parallel% %verbose%^
140+
/p:Configuration=%conf% /p:Platform=%platf%^
141+
/p:IncludeExternals=%IncludeExternals%^
142+
/p:IncludeSSL=%IncludeSSL% /p:IncludeTkinter=%IncludeTkinter%^
143+
/p:UseTestMarker=%UseTestMarker%^
144+
%1 %2 %3 %4 %5 %6 %7 %8 %9
145+
146+
@echo off
147+
goto :eof
148+
149+
:Version
150+
rem Display the current build version information
151+
msbuild "%dir%python.props" /t:ShowVersionInfo /v:m /nologo %1 %2 %3 %4 %5 %6 %7 %8 %9
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
@echo off
2+
setlocal
3+
rem Simple script to fetch source for external libraries
4+
5+
if not exist "%~dp0..\externals" mkdir "%~dp0..\externals"
6+
pushd "%~dp0..\externals"
7+
8+
echo.Fetching external libraries...
9+
10+
set IncludeTkinterSrc=false
11+
set IncludeSSLSrc=false
12+
13+
rem *** IMPORTANT ***
14+
rem If updating bzip2, db, nasm, openssl, or sqlite you must also edit their directory names in python.props.
15+
rem If updating tcl/tk/tix you must also update their versions/directories in tcltk.props.
16+
17+
set default_OpenSSL=1.1.1v
18+
if "%OpenSSL_version%"=="" set OpenSSL_version=%default_OpenSSL%
19+
20+
set libraries=
21+
set libraries=%libraries% bzip2-1.0.8
22+
if NOT "%IncludeSSL%"=="false" set libraries=%libraries% nasm-2.11.06
23+
if NOT "%IncludeSSL%"=="false" set libraries=%libraries% openssl-%OpenSSL_version%
24+
set libraries=%libraries% sqlite-3.43.0.0
25+
if NOT "%IncludeTkinter%"=="false" set libraries=%libraries% tcltk-8.6.9.0-bin
26+
if NOT "%IncludeTkinter%"=="false" set libraries=%libraries% tix-8.4.3.6
27+
set libraries=%libraries% xz-5.2.2
28+
set libraries=%libraries% zlib-1.2.13
29+
rem CAMEL_GIT_SHA contains the commit SHA used for the current build.
30+
rem Note that the branch 'master' in the below URL is ignored by the server because sha is present.
31+
32+
for %%e in (%libraries%) do (
33+
if exist %%e (
34+
echo.%%e already exists, skipping.
35+
) else (
36+
echo.Fetching %%e...
37+
call lwp-download https://s3.amazonaws.com/camel-sources/src/vendor-sources/python-core/%%e-pysvn.tar.gz ..\externals\%%e.tar.gz
38+
cd ..\externals
39+
call tar zxf %%e.tar.gz
40+
del %%e.tar.gz
41+
if exist cpython-source-deps-%%e (
42+
move cpython-source-deps-%%e %%e
43+
)
44+
cd ..\PCbuild
45+
)
46+
)
47+
48+
cd ..\externals
49+
if NOT "%OpenSSL_version%"=="%default_OpenSSL%" (
50+
if exist openssl-%OpenSSL_version% (
51+
move openssl-%OpenSSL_version% openssl-%default_OpenSSL%
52+
)
53+
)
54+
cd ..\PCbuild
55+
56+
goto end
57+
58+
:usage
59+
echo.invalid argument: %1
60+
echo.usage: %~n0 [[ -c ^| --clean ] ^| --clean-only ]
61+
echo.
62+
echo.Pull all sources necessary for compiling optional extension modules
63+
echo.that rely on external libraries. Requires svn.exe to be on your PATH
64+
echo.and pulls sources from %SVNROOT%.
65+
echo.
66+
echo.Use the -c or --clean option to clean up all external library sources
67+
echo.before pulling in the current versions.
68+
echo.
69+
echo.Use the --clean-only option to do the same cleaning, without pulling in
70+
echo.anything new.
71+
echo.
72+
echo.Only the first argument is checked, all others are ignored.
73+
echo.
74+
echo.**WARNING**: the cleaning options unconditionally remove any directory
75+
echo.that is a child of
76+
echo. %CD%
77+
echo.and matches wildcard patterns beginning with bzip2-, db-, nasm-, openssl-,
78+
echo.tcl-, tcltk, tk-, tix-, sqlite-, or xz-, and as such has the potential
79+
echo.to be very destructive if you are not aware of what it is doing. Use with
80+
echo.caution!
81+
popd
82+
exit /b -1
83+
84+
85+
:end
86+
echo Finished.
87+
popd

PCbuild/tcltk.props

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<tkDir>$(ExternalsDir)tk-$(TkMajorVersion).$(TkMinorVersion).$(TkPatchLevel).$(TkRevision)\</tkDir>
1919
<tixDir>$(ExternalsDir)tix-$(TixMajorVersion).$(TixMinorVersion).$(TixPatchLevel).$(TixRevision)\</tixDir>
2020
<tcltkDir>$(ExternalsDir)tcltk-$(TclMajorVersion).$(TclMinorVersion).$(TclPatchLevel).$(TclRevision)\$(ArchName)\</tcltkDir>
21-
<!--<TclDebugExt Condition="'$(Configuration)' == 'Debug'">g</TclDebugExt>-->
21+
<TclDebugExt Condition="'$(Configuration)' == 'Debug'">g</TclDebugExt>
2222
<tclDLLName>tcl$(TclMajorVersion)$(TclMinorVersion)t$(TclDebugExt).dll</tclDLLName>
2323
<tclLibName>tcl$(TclMajorVersion)$(TclMinorVersion)t$(TclDebugExt).lib</tclLibName>
2424
<tclShExeName>tclsh$(TclMajorVersion)$(TclMinorVersion)t$(TclDebugExt).exe</tclShExeName>
@@ -36,8 +36,7 @@
3636
<BuildDirTop>Release</BuildDirTop>
3737
<BuildDirTop Condition="$(Configuration) == 'Debug'">Debug</BuildDirTop>
3838
<BuildDirTop Condition="$(TclMachine) != 'IX86'">$(BuildDirTop)_$(TclMachine)</BuildDirTop>
39-
<BuildDirTop Condition="$(PlatformToolset) == 'v141'">$(BuildDirTop)_VC13</BuildDirTop>
40-
<BuildDirTop Condition="$(PlatformToolset) == 'v140'">$(BuildDirTop)_VC13</BuildDirTop>
39+
<BuildDirTop Condition="$(PlatformToolset.StartsWith('v14'))">$(BuildDirTop)_VC13</BuildDirTop>
4140
<BuildDirTop Condition="$(PlatformToolset) == 'v120'">$(BuildDirTop)_VC12</BuildDirTop>
4241
<BuildDirTop Condition="$(PlatformToolset) == 'v110'">$(BuildDirTop)_VC11</BuildDirTop>
4342
<BuildDirTop Condition="$(PlatformToolset) == 'v100'">$(BuildDirTop)_VC10</BuildDirTop>

setup.py

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ def get_platform():
4444
return sys.platform
4545
host_platform = get_platform()
4646

47+
# ActivePython change:
48+
# ActivePython builds some external libraries into a private build
49+
# directory for controlled use by common Python extension modules.
50+
apy_prefix_dir = r"PT_CONFIG_build_prefix_abs_dir"
51+
apy_inc_dir = os.path.join(apy_prefix_dir, "include")
52+
apy_lib_dir = os.path.join(apy_prefix_dir, "lib")
53+
4754
# Were we compiled --with-pydebug or with #define Py_DEBUG?
4855
COMPILED_WITH_PYDEBUG = ('--with-pydebug' in sysconfig.get_config_var("CONFIG_ARGS"))
4956

@@ -1449,38 +1456,22 @@ class db_found(Exception): pass
14491456
#
14501457
# You can upgrade zlib to version 1.1.4 yourself by going to
14511458
# http://www.gzip.org/zlib/
1452-
zlib_inc = find_file('zlib.h', [], inc_dirs)
1453-
have_zlib = False
1454-
if zlib_inc is not None:
1455-
zlib_h = zlib_inc[0] + '/zlib.h'
1456-
version = '"0.0.0"'
1457-
version_req = '"1.1.3"'
1458-
if host_platform == 'darwin' and is_macosx_sdk_path(zlib_h):
1459-
zlib_h = os.path.join(macosx_sdk_root(), zlib_h[1:])
1460-
with open(zlib_h) as fp:
1461-
while 1:
1462-
line = fp.readline()
1463-
if not line:
1464-
break
1465-
if line.startswith('#define ZLIB_VERSION'):
1466-
version = line.split()[2]
1467-
break
1468-
if version >= version_req:
1469-
if (self.compiler.find_library_file(lib_dirs, 'z')):
1470-
if host_platform == "darwin":
1471-
zlib_extra_link_args = ('-Wl,-search_paths_first',)
1472-
else:
1473-
zlib_extra_link_args = ()
1474-
exts.append( Extension('zlib', ['zlibmodule.c'],
1475-
libraries = ['z'],
1476-
extra_link_args = zlib_extra_link_args))
1477-
have_zlib = True
1478-
else:
1479-
missing.append('zlib')
1480-
else:
1481-
missing.append('zlib')
1459+
#
1460+
# ActivePython Change:
1461+
# ActivePython's build ALWAYS expects a zlib install in
1462+
# $(TOP)/build.
1463+
zlib_inc_dirs = [apy_inc_dir]
1464+
zlib_lib_dirs = [apy_lib_dir]
1465+
if sys.platform == "darwin":
1466+
zlib_extra_link_args = ('-Wl,-search_paths_first',)
14821467
else:
1483-
missing.append('zlib')
1468+
zlib_extra_link_args = ()
1469+
exts.append(Extension('zlib', ['zlibmodule.c'],
1470+
include_dirs = zlib_inc_dirs,
1471+
library_dirs = zlib_lib_dirs,
1472+
libraries = ['z'],
1473+
extra_link_args = zlib_extra_link_args))
1474+
have_zlib = True
14841475

14851476
# Helper module for various ascii-encoders. Uses zlib for an optimized
14861477
# crc32 if we have it. Otherwise binascii uses its own.
@@ -1495,6 +1486,8 @@ class db_found(Exception): pass
14951486
exts.append( Extension('binascii', ['binascii.c'],
14961487
extra_compile_args = extra_compile_args,
14971488
libraries = libraries,
1489+
include_dirs = zlib_inc_dirs,
1490+
library_dirs = zlib_lib_dirs,
14981491
extra_link_args = extra_link_args) )
14991492

15001493
# Gustavo Niemeyer's bz2 module.
@@ -1893,6 +1886,8 @@ def detect_tkinter(self, inc_dirs, lib_dirs):
18931886
include_dirs.append('/usr/X11/include')
18941887
added_lib_dirs.append('/usr/X11/lib')
18951888

1889+
added_lib_dirs.insert(0, apy_lib_dir)
1890+
18961891
# If Cygwin, then verify that X is installed before proceeding
18971892
if host_platform == 'cygwin':
18981893
x11_inc = find_file('X11/Xlib.h', [], include_dirs)

0 commit comments

Comments
 (0)