cpython (2.7): Adds batch file for building nuget package, and includes libs folder

https://hg.python.org/cpython/rev/ccec979392d7 changeset: 102215:ccec979392d7 branch: 2.7 parent: 102185:e2d0d921d526 user: Steve Dower <steve.dower@microsoft.com> date: Mon Jun 27 09:54:03 2016 -0700 summary: Adds batch file for building nuget package, and includes libs folder files: Tools/nuget/build.bat | 63 +++++++++++++++++++++++++++ Tools/nuget/make_pkg.proj | 5 +- Tools/nuget/make_zip.py | 37 +++++++++++---- 3 files changed, 94 insertions(+), 11 deletions(-) diff --git a/Tools/nuget/build.bat b/Tools/nuget/build.bat new file mode 100644 --- /dev/null +++ b/Tools/nuget/build.bat @@ -0,0 +1,63 @@ +@echo off +setlocal +set D=%~dp0 +set PCBUILD=%D%..\..\PCBuild\ + +set BUILDX86= +set BUILDX64= +set REBUILD= +set OUTPUT= +set PACKAGES= + +:CheckOpts +if "%~1" EQU "-h" goto Help +if "%~1" EQU "-x86" (set BUILDX86=1) && shift && goto CheckOpts +if "%~1" EQU "-x64" (set BUILDX64=1) && shift && goto CheckOpts +if "%~1" EQU "-r" (set REBUILD=-r) && shift && goto CheckOpts +if "%~1" EQU "-o" (set OUTPUT="/p:OutputPath=%~2") && shift && shift && goto CheckOpts +if "%~1" EQU "--out" (set OUTPUT="/p:OutputPath=%~2") && shift && shift && goto CheckOpts +if "%~1" EQU "-p" (set PACKAGES=%PACKAGES% %~2) && shift && shift && goto CheckOpts + +if not defined BUILDX86 if not defined BUILDX64 (set BUILDX86=1) && (set BUILDX64=1) + +if not defined NUGET where nuget -q || echo Cannot find nuget.exe on PATH and NUGET is not set. && exit /B 1 +if not defined PYTHON set PYTHON=py -3 + +@%PYTHON% -c "" >nul 2>nul +@if errorlevel 1 ( + %NUGET% install python -OutputDirectory "%D%obj" -ExcludeVersion -NonInteractive + set PYTHON="%D%obj\python\tools\python.exe" +) + +call "%PCBUILD%env.bat" x86 + +if defined PACKAGES set PACKAGES="/p:Packages=%PACKAGES%" + +if defined BUILDX86 ( + if defined REBUILD ( call "%PCBUILD%build.bat" -e -r + ) else if not exist "%PCBUILD%python.exe" call "%PCBUILD%build.bat" -e + if errorlevel 1 goto :eof + + msbuild "%D%make_pkg.proj" /p:Configuration=Release /p:Platform=x86 %OUTPUT% %PACKAGES% + if errorlevel 1 goto :eof +) + +if defined BUILDX64 ( + if defined REBUILD ( call "%PCBUILD%build.bat" -p x64 -e -r + ) else if not exist "%PCBUILD%amd64\python.exe" call "%PCBUILD%build.bat" -p x64 -e + if errorlevel 1 goto :eof + + msbuild "%D%make_pkg.proj" /p:Configuration=Release /p:Platform=x64 %OUTPUT% %PACKAGES% + if errorlevel 1 goto :eof +) + +exit /B 0 + +:Help +echo build.bat [-x86] [-x64] [--out DIR] [-r] [-h] +echo. +echo -x86 Build x86 installers +echo -x64 Build x64 installers +echo -r Rebuild rather than incremental build +echo --out [DIR] Override output directory +echo -h Show usage diff --git a/Tools/nuget/make_pkg.proj b/Tools/nuget/make_pkg.proj --- a/Tools/nuget/make_pkg.proj +++ b/Tools/nuget/make_pkg.proj @@ -7,6 +7,7 @@ <OutputPath Condition="$(OutputPath) == ''">$(MSBuildThisFileDirectory)</OutputPath> <OutputSuffix></OutputSuffix> <SupportSigning>false</SupportSigning> + <BuildForRelease Condition="$(BuildForRelease) == ''">true</BuildForRelease> </PropertyGroup> <Import Project="..\..\PCBuild\python.props" /> @@ -26,10 +27,11 @@ <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> @@ -42,6 +44,7 @@ <Exec Command="$(CleanCommand)" /> <Exec Command="$(PythonArguments)" /> <Exec Command="$(PipArguments)" /> + <Exec Command="$(PackageArguments)" Condition="$(PackageArguments) != ''" /> <Exec Command="$(NugetArguments)" /> </Target> diff --git a/Tools/nuget/make_zip.py b/Tools/nuget/make_zip.py --- a/Tools/nuget/make_zip.py +++ b/Tools/nuget/make_zip.py @@ -14,9 +14,19 @@ 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', @@ -25,12 +35,19 @@ '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 @@ -38,14 +55,7 @@ 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) @@ -69,6 +79,12 @@ 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 @@ -84,6 +100,7 @@ ('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), ] @@ -160,7 +177,7 @@ 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) -- Repository URL: https://hg.python.org/cpython
participants (1)
-
steve.dower