22setlocal
33rem Simple script to fetch source for external libraries
44
5- if not exist " %~dp0 ..\externals" mkdir " %~dp0 ..\externals"
6- pushd " %~dp0 ..\externals"
5+ if " %PCBUILD% " == " " (set PCBUILD=%~dp0 )
6+ if " %EXTERNALS_DIR% " == " " (set EXTERNALS_DIR=%PCBUILD% \..\externals)
7+ if " %NUGET% " == " " (set NUGET=%EXTERNALS_DIR% \nuget.exe)
8+ if " %NUGET_URL% " == " " (set NUGET_URL=https://aka.ms/nugetclidl)
79
8- if " %SVNROOT% " == " " set SVNROOT = http://svn.python.org/projects/external/
10+ set DO_FETCH = true
11+ set DO_CLEAN = false
912
10- rem Optionally clean up first. Be warned that this can be very destructive!
11- if not " %1 " == " " (
12- for %%c in (-c --clean --clean-only) do (
13- if " %1 " == " %%c " goto clean
14- )
15- goto usage
16- )
17- goto fetch
13+ :CheckOpts
14+ if " %~1 " == " --no-tkinter" (set IncludeTkinter=false) & shift & goto CheckOpts
15+ if " %~1 " == " --no-openssl" (set IncludeSSL=false) & shift & goto CheckOpts
16+ if " %~1 " == " --python" (set PYTHON_FOR_BUILD=%2 ) & shift & shift & goto CheckOpts
17+ if " %~1 " == " --organization" (set ORG=%2 ) & shift & shift & goto CheckOpts
18+ if " %~1 " == " -c" (set DO_CLEAN=true) & shift & goto CheckOpts
19+ if " %~1 " == " --clean" (set DO_CLEAN=true) & shift & goto CheckOpts
20+ if " %~1 " == " --clean-only" (set DO_FETCH=false) & goto clean
21+ if " x%~1 " NEQ " x" goto usage
1822
23+ if " %DO_CLEAN% " == " false" goto fetch
1924:clean
2025echo .Cleaning up external libraries.
21- for /D %%d in (
22- bzip2-*
23- db-*
24- nasm-*
25- openssl-*
26- tcl-*
27- tcltk*
28- tk-*
29- tix-*
30- sqlite-*
31- xz-*
32- ) do (
33- echo .Removing %%d
34- rmdir /s /q %%d
35- )
36- if " %1 " == " --clean-only" (
37- goto end
26+ if exist " %EXTERNALS_DIR% " (
27+ rem Sometimes this fails the first time; try it twice
28+ rmdir /s /q " %EXTERNALS_DIR% " || rmdir /s /q " %EXTERNALS_DIR% "
3829)
3930
31+ if " %DO_FETCH% " == " false" goto end
4032:fetch
41- rem Fetch current versions
42-
43- svn --version > nul 2 >& 1
44- if ERRORLEVEL 9009 (
45- echo .svn.exe must be on your PATH.
46- echo .Try TortoiseSVN (http://tortoisesvn.net/^ ) and be sure to check the
47- echo .command line tools option.
48- popd
49- exit /b 1
33+
34+ if " %ORG% " == " " (set ORG=python)
35+
36+ if " %PYTHON_FOR_BUILD% " == " " (
37+ echo Checking for installed python...
38+ py -3.6 -V > nul 2 >& 1 && (set PYTHON_FOR_BUILD=py -3.6)
39+ )
40+ if " %PYTHON_FOR_BUILD% " == " " (
41+ if NOT exist " %EXTERNALS_DIR% " mkdir " %EXTERNALS_DIR% "
42+ if NOT exist " %NUGET% " (
43+ echo Downloading nuget...
44+ rem NB: Must use single quotes around NUGET here, NOT double!
45+ rem Otherwise, a space in the path would break things
46+ powershell.exe -Command Invoke-WebRequest %NUGET_URL% -OutFile '%NUGET% '
47+ )
48+ echo Installing Python via nuget...
49+ " %NUGET% " install pythonx86 -ExcludeVersion -OutputDirectory " %EXTERNALS_DIR% "
50+ rem Quote it here; it's not quoted later because "py -3.6" wouldn't work
51+ set PYTHON_FOR_BUILD = " %EXTERNALS_DIR% \pythonx86\tools\python.exe"
5052)
5153
5254echo .Fetching external libraries...
@@ -57,51 +59,55 @@ rem files in both this dir and PC\VS9.0
5759set libraries =
5860set libraries = %libraries% bzip2-1.0.6
5961if NOT " %IncludeBsddb% " == " false" set libraries = %libraries% db-4.7.25.0
60- if NOT " %IncludeSSL% " == " false" set libraries = %libraries% nasm-2.11.06
6162if NOT " %IncludeSSL% " == " false" set libraries = %libraries% openssl-1.0.2k
6263set libraries = %libraries% sqlite-3.8.11.0
6364if NOT " %IncludeTkinter% " == " false" set libraries = %libraries% tcl-8.5.15.0
6465if NOT " %IncludeTkinter% " == " false" set libraries = %libraries% tk-8.5.15.0
6566if NOT " %IncludeTkinter% " == " false" set libraries = %libraries% tix-8.4.3.5
6667
6768for %%e in (%libraries% ) do (
68- if exist %%e (
69+ if exist " %EXTERNALS_DIR% \ %%e " (
6970 echo .%%e already exists, skipping.
7071 ) else (
7172 echo .Fetching %%e ...
72- svn export -q %SVNROOT% %%e
73+ %PYTHON_FOR_BUILD% " %PCBUILD% get_external.py" -O %ORG% %%e
74+ )
75+ )
76+
77+ echo .Fetching external binaries...
78+
79+ set binaries =
80+ set binaries = %binaries%
81+ if NOT " %IncludeSSL% " == " false" set binaries = %binaries% nasm-2.11.06
82+
83+ for %%b in (%binaries% ) do (
84+ if exist " %EXTERNALS_DIR% \%%b " (
85+ echo .%%b already exists, skipping.
86+ ) else (
87+ echo .Fetching %%b ...
88+ %PYTHON_FOR_BUILD% " %PCBUILD% get_external.py" -b -O %ORG% %%b
7389 )
7490)
7591
92+ echo Finished.
7693goto end
7794
7895:usage
79- echo .invalid argument: %1
80- echo .usage: %~n0 [[ -c ^ | --clean ] ^ | --clean-only ]
96+ echo .Valid options: -c, --clean, --clean-only, --organization, --python,
97+ echo .--no-tkinter, --no-openssl
8198echo .
82- echo .Pull all sources necessary for compiling optional extension modules
83- echo .that rely on external libraries. Requires svn.exe to be on your PATH
84- echo .and pulls sources from %SVNROOT% .
99+ echo .Pull all sources and binaries necessary for compiling optional extension
100+ echo .modules that rely on external libraries.
85101echo .
86- echo .Use the -c or --clean option to clean up all external library sources
87- echo .before pulling in the current versions.
102+ echo .The --organization option determines which github organization to download
103+ echo .from, the --python option determines which Python 3.6+ interpreter to use
104+ echo .with PCbuild\get_external.py.
105+ echo .
106+ echo .Use the -c or --clean option to remove the entire externals directory.
88107echo .
89108echo .Use the --clean-only option to do the same cleaning, without pulling in
90109echo .anything new.
91110echo .
92- echo .Only the first argument is checked, all others are ignored.
93- echo .
94- echo .**WARNING**: the cleaning options unconditionally remove any directory
95- echo .that is a child of
96- echo . %CD%
97- echo .and matches wildcard patterns beginning with bzip2-, db-, nasm-, openssl-,
98- echo .tcl-, tcltk, tk-, tix-, sqlite-, or xz-, and as such has the potential
99- echo .to be very destructive if you are not aware of what it is doing. Use with
100- echo .caution!
101- popd
102111exit /b -1
103112
104-
105113:end
106- echo Finished.
107- popd
0 commit comments