1@echo off 2setlocal 3rem Simple script to fetch source for external libraries 4 5if NOT DEFINED PCBUILD (set PCBUILD=%~dp0) 6if NOT DEFINED EXTERNALS_DIR (set EXTERNALS_DIR=%PCBUILD%\..\externals) 7 8set DO_FETCH=true 9set DO_CLEAN=false 10set IncludeLibffiSrc=false 11set IncludeTkinterSrc=false 12set IncludeSSLSrc=false 13 14:CheckOpts 15if "%~1"=="--no-tkinter" (set IncludeTkinter=false) & shift & goto CheckOpts 16if "%~1"=="--no-openssl" (set IncludeSSL=false) & shift & goto CheckOpts 17if "%~1"=="--no-libffi" (set IncludeLibffi=false) & shift & goto CheckOpts 18if "%~1"=="--tkinter-src" (set IncludeTkinterSrc=true) & shift & goto CheckOpts 19if "%~1"=="--openssl-src" (set IncludeSSLSrc=true) & shift & goto CheckOpts 20if "%~1"=="--libffi-src" (set IncludeLibffiSrc=true) & shift & goto CheckOpts 21if "%~1"=="--python" (set PYTHON=%2) & shift & shift & goto CheckOpts 22if "%~1"=="--organization" (set ORG=%2) & shift & shift & goto CheckOpts 23if "%~1"=="-c" (set DO_CLEAN=true) & shift & goto CheckOpts 24if "%~1"=="--clean" (set DO_CLEAN=true) & shift & goto CheckOpts 25if "%~1"=="--clean-only" (set DO_FETCH=false) & goto clean 26 27rem Include old options for compatibility 28if "%~1"=="--no-tkinter" shift & goto CheckOpts 29if "%~1"=="--no-openssl" shift & goto CheckOpts 30 31if "x%~1" NEQ "x" goto usage 32 33if "%DO_CLEAN%"=="false" goto fetch 34:clean 35echo.Cleaning up external libraries. 36if exist "%EXTERNALS_DIR%" ( 37 rem Sometimes this fails the first time; try it twice 38 rmdir /s /q "%EXTERNALS_DIR%" || rmdir /s /q "%EXTERNALS_DIR%" 39) 40 41if "%DO_FETCH%"=="false" goto end 42:fetch 43 44if "%ORG%"=="" (set ORG=python) 45call "%PCBUILD%\find_python.bat" "%PYTHON%" 46 47if NOT DEFINED PYTHON ( 48 where /Q git || echo Python 3.6 could not be found or installed, and git.exe is not on your PATH && exit /B 1 49) 50 51echo.Fetching external libraries... 52 53set libraries= 54set libraries=%libraries% bzip2-1.0.6 55if NOT "%IncludeLibffiSrc%"=="false" set libraries=%libraries% libffi-3.3.0 56if NOT "%IncludeSSLSrc%"=="false" set libraries=%libraries% openssl-1.1.1m 57set libraries=%libraries% sqlite-3.35.5.0 58if NOT "%IncludeTkinterSrc%"=="false" set libraries=%libraries% tcl-core-8.6.12.0 59if NOT "%IncludeTkinterSrc%"=="false" set libraries=%libraries% tk-8.6.12.0 60if NOT "%IncludeTkinterSrc%"=="false" set libraries=%libraries% tix-8.4.3.6 61set libraries=%libraries% xz-5.2.2 62set libraries=%libraries% zlib-1.2.11 63 64for %%e in (%libraries%) do ( 65 if exist "%EXTERNALS_DIR%\%%e" ( 66 echo.%%e already exists, skipping. 67 ) else if NOT DEFINED PYTHON ( 68 echo.Fetching %%e with git... 69 git clone --depth 1 https://github.com/%ORG%/cpython-source-deps --branch %%e "%EXTERNALS_DIR%\%%e" 70 ) else ( 71 echo.Fetching %%e... 72 %PYTHON% -E "%PCBUILD%\get_external.py" -O %ORG% -e "%EXTERNALS_DIR%" %%e 73 ) 74) 75 76echo.Fetching external binaries... 77 78set binaries= 79if NOT "%IncludeLibffi%"=="false" set binaries=%binaries% libffi-3.3.0 80if NOT "%IncludeSSL%"=="false" set binaries=%binaries% openssl-bin-1.1.1m 81if NOT "%IncludeTkinter%"=="false" set binaries=%binaries% tcltk-8.6.12.0 82if NOT "%IncludeSSLSrc%"=="false" set binaries=%binaries% nasm-2.11.06 83 84for %%b in (%binaries%) do ( 85 if exist "%EXTERNALS_DIR%\%%b" ( 86 echo.%%b already exists, skipping. 87 ) else if NOT DEFINED PYTHON ( 88 echo.Fetching %%b with git... 89 git clone --depth 1 https://github.com/%ORG%/cpython-bin-deps --branch %%b "%EXTERNALS_DIR%\%%b" 90 ) else ( 91 echo.Fetching %%b... 92 %PYTHON% -E "%PCBUILD%\get_external.py" -b -O %ORG% -e "%EXTERNALS_DIR%" %%b 93 ) 94) 95 96echo Finished. 97goto end 98 99:usage 100echo.Valid options: -c, --clean, --clean-only, --organization, --python, 101echo.--no-tkinter, --no-openssl 102echo. 103echo.Pull all sources and binaries necessary for compiling optional extension 104echo.modules that rely on external libraries. 105echo. 106echo.The --organization option determines which github organization to download 107echo.from, the --python option determines which Python 3.6+ interpreter to use 108echo.with PCbuild\get_external.py. 109echo. 110echo.Use the -c or --clean option to remove the entire externals directory. 111echo. 112echo.Use the --clean-only option to do the same cleaning, without pulling in 113echo.anything new. 114echo. 115exit /b -1 116 117:end 118