--- /dev/null
+@echo off\r
+setlocal\r
+set D=%~dp0\r
+set PCBUILD=%D%..\..\PCBuild\\r
+\r
+set BUILDX86=\r
+set BUILDX64=\r
+set REBUILD=\r
+set OUTPUT=\r
+set PACKAGES=\r
+\r
+:CheckOpts\r
+if "%~1" EQU "-h" goto Help\r
+if "%~1" EQU "-x86" (set BUILDX86=1) && shift && goto CheckOpts\r
+if "%~1" EQU "-x64" (set BUILDX64=1) && shift && goto CheckOpts\r
+if "%~1" EQU "-r" (set REBUILD=-r) && shift && goto CheckOpts\r
+if "%~1" EQU "-o" (set OUTPUT="/p:OutputPath=%~2") && shift && shift && goto CheckOpts\r
+if "%~1" EQU "--out" (set OUTPUT="/p:OutputPath=%~2") && shift && shift && goto CheckOpts\r
+if "%~1" EQU "-p" (set PACKAGES=%PACKAGES% %~2) && shift && shift && goto CheckOpts\r
+\r
+if not defined BUILDX86 if not defined BUILDX64 (set BUILDX86=1) && (set BUILDX64=1)\r
+\r
+if not defined NUGET where nuget -q || echo Cannot find nuget.exe on PATH and NUGET is not set. && exit /B 1\r
+if not defined PYTHON set PYTHON=py -3\r
+\r
+@%PYTHON% -c "" >nul 2>nul\r
+@if errorlevel 1 (\r
+ %NUGET% install python -OutputDirectory "%D%obj" -ExcludeVersion -NonInteractive\r
+ set PYTHON="%D%obj\python\tools\python.exe"\r
+)\r
+\r
+call "%PCBUILD%env.bat" x86\r
+\r
+if defined PACKAGES set PACKAGES="/p:Packages=%PACKAGES%"\r
+\r
+if defined BUILDX86 (\r
+ if defined REBUILD ( call "%PCBUILD%build.bat" -e -r\r
+ ) else if not exist "%PCBUILD%python.exe" call "%PCBUILD%build.bat" -e\r
+ if errorlevel 1 goto :eof\r
+\r
+ msbuild "%D%make_pkg.proj" /p:Configuration=Release /p:Platform=x86 %OUTPUT% %PACKAGES%\r
+ if errorlevel 1 goto :eof\r
+)\r
+\r
+if defined BUILDX64 (\r
+ if defined REBUILD ( call "%PCBUILD%build.bat" -p x64 -e -r\r
+ ) else if not exist "%PCBUILD%amd64\python.exe" call "%PCBUILD%build.bat" -p x64 -e\r
+ if errorlevel 1 goto :eof\r
+\r
+ msbuild "%D%make_pkg.proj" /p:Configuration=Release /p:Platform=x64 %OUTPUT% %PACKAGES%\r
+ if errorlevel 1 goto :eof\r
+)\r
+\r
+exit /B 0\r
+\r
+:Help\r
+echo build.bat [-x86] [-x64] [--out DIR] [-r] [-h]\r
+echo.\r
+echo -x86 Build x86 installers\r
+echo -x64 Build x64 installers\r
+echo -r Rebuild rather than incremental build\r
+echo --out [DIR] Override output directory\r
+echo -h Show usage\r
<OutputPath Condition="$(OutputPath) == ''">$(MSBuildThisFileDirectory)</OutputPath>
<OutputSuffix></OutputSuffix>
<SupportSigning>false</SupportSigning>
+ <BuildForRelease Condition="$(BuildForRelease) == ''">true</BuildForRelease>
</PropertyGroup>
<Import Project="..\..\PCBuild\python.props" />
<PythonArguments>$(PythonArguments) -s "$(PySourcePath.Trim('\'))" -t "$(IntermediateOutputPath)" -a $(ArchName)</PythonArguments>
<PipArguments>"$(IntermediateOutputPath)\python.exe" -B -c "import sys; sys.path.append(r'$(PySourcePath)\Lib'); import ensurepip; ensurepip._main()"</PipArguments>
+ <PackageArguments Condition="$(Packages) != ''">"$(IntermediateOutputPath)\python.exe" -B -m pip install -U $(Packages)</PackageArguments>
<NugetArguments>"$(Nuget)" pack "$(MSBuildThisFileDirectory)\$(OutputName).nuspec"</NugetArguments>
<NugetArguments>$(NugetArguments) -BasePath "$(IntermediateOutputPath)"</NugetArguments>
- <NugetArguments>$(NugetArguments) -OutputDirectory "$(OutputPath.Trim('\'))"</NugetArguments>
+ <NugetArguments>$(NugetArguments) -OutputDirectory "$(OutputPath.Trim(`\`))"</NugetArguments>
<NugetArguments>$(NugetArguments) -Version "$(NuspecVersion)"</NugetArguments>
<NugetArguments>$(NugetArguments) -NoPackageAnalysis -NonInteractive</NugetArguments>
</PropertyGroup>
<Exec Command="$(CleanCommand)" />
<Exec Command="$(PythonArguments)" />
<Exec Command="$(PipArguments)" />
+ <Exec Command="$(PackageArguments)" Condition="$(PackageArguments) != ''" />
<Exec Command="$(NugetArguments)" />
</Target>
import subprocess
TKTCL_RE = re.compile(r'^(_?tk|tcl).+\.(pyd|dll)', re.IGNORECASE)
-DEBUG_RE = re.compile(r'_d\.(pyd|dll|exe)$', re.IGNORECASE)
+DEBUG_RE = re.compile(r'_d\.(pyd|dll|exe|pdb|lib)$', re.IGNORECASE)
PYTHON_DLL_RE = re.compile(r'python\d\d?\.dll$', re.IGNORECASE)
+DEBUG_FILES = {
+ '_ctypes_test',
+ '_testbuffer',
+ '_testcapi',
+ '_testimportmultiple',
+ '_testmultiphase',
+ 'xxlimited',
+ 'python3_dstub',
+}
+
EXCLUDE_FROM_LIBRARY = {
'__pycache__',
'ensurepip',
'site-packages',
'tkinter',
'turtledemo',
+ 'venv',
}
EXCLUDE_FILE_FROM_LIBRARY = {
'bdist_wininst.py',
}
+EXCLUDE_FILE_FROM_LIBS = {
+ 'ssleay',
+ 'libeay',
+ 'python3stub',
+}
+
def is_not_debug(p):
if DEBUG_RE.search(p.name):
return False
if TKTCL_RE.search(p.name):
return False
- return p.name.lower() not in {
- '_ctypes_test.pyd',
- '_testbuffer.pyd',
- '_testcapi.pyd',
- '_testimportmultiple.pyd',
- '_testmultiphase.pyd',
- 'xxlimited.pyd',
- }
+ return p.stem.lower() not in DEBUG_FILES
def is_not_debug_or_python(p):
return is_not_debug(p) and not PYTHON_DLL_RE.search(p.name)
suffix = p.suffix.lower()
return suffix not in {'.pyc', '.pyo', '.exe'}
+def include_in_libs(p):
+ if not is_not_debug(p):
+ return False
+
+ return p.stem.lower() not in EXCLUDE_FILE_FROM_LIBS
+
def include_in_tools(p):
if p.is_dir() and p.name.lower() in {'scripts', 'i18n', 'pynche', 'demo', 'parser'}:
return True
('include/', 'include', '*.h', None),
('include/', 'PC', 'pyconfig.h', None),
('Lib/', 'Lib', '**/*', include_in_lib),
+ ('libs/', 'PCBuild/$arch', '*.lib', include_in_libs),
('Tools/', 'Tools', '**/*', include_in_tools),
]
source = ns.source or (Path(__file__).resolve().parent.parent.parent)
out = ns.out
- arch = "" if ns.arch == "win32" else ns.arch
+ arch = '' if ns.arch == 'win32' else ns.arch
assert isinstance(source, Path)
assert not out or isinstance(out, Path)
assert isinstance(arch, str)