From 33f7310c5eeedf12690c3548e3315dbbfff6b770 Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Fri, 24 Jun 2016 10:32:15 -0700 Subject: Adds scripts for producing Nuget packages. --- Tools/msi/make_zip.py | 28 +++++++++++++----------- Tools/nuget/make_pkg.proj | 51 ++++++++++++++++++++++++++++++++++++++++++++ Tools/nuget/python.nuspec | 18 ++++++++++++++++ Tools/nuget/pythonx86.nuspec | 18 ++++++++++++++++ 4 files changed, 103 insertions(+), 12 deletions(-) create mode 100644 Tools/nuget/make_pkg.proj create mode 100644 Tools/nuget/python.nuspec create mode 100644 Tools/nuget/pythonx86.nuspec diff --git a/Tools/msi/make_zip.py b/Tools/msi/make_zip.py index 753ba0f..2fb40d1 100644 --- a/Tools/msi/make_zip.py +++ b/Tools/msi/make_zip.py @@ -75,10 +75,12 @@ def include_in_tools(p): return p.suffix.lower() in {'.py', '.pyw', '.txt'} FULL_LAYOUT = [ - ('/', 'PCBuild/$arch', 'python*.exe', is_not_debug), - ('/', 'PCBuild/$arch', 'python*.dll', is_not_debug), + ('/', 'PCBuild/$arch', 'python.exe', is_not_debug), + ('/', 'PCBuild/$arch', 'pythonw.exe', is_not_debug), + ('/', 'PCBuild/$arch', 'python{0.major}.dll'.format(sys.version_info), is_not_debug), + ('/', 'PCBuild/$arch', 'python{0.major}{0.minor}.dll'.format(sys.version_info), is_not_debug), ('DLLs/', 'PCBuild/$arch', '*.pyd', is_not_debug), - ('DLLs/', 'PCBuild/$arch', '*.dll', is_not_debug), + ('DLLs/', 'PCBuild/$arch', '*.dll', is_not_debug_or_python), ('include/', 'include', '*.h', None), ('include/', 'PC', 'pyconfig.h', None), ('Lib/', 'Lib', '**/*', include_in_lib), @@ -150,17 +152,17 @@ def rglob(root, pattern, condition): def main(): parser = argparse.ArgumentParser() parser.add_argument('-s', '--source', metavar='dir', help='The directory containing the repository root', type=Path) - parser.add_argument('-o', '--out', metavar='file', help='The name of the output self-extracting archive', type=Path, required=True) + parser.add_argument('-o', '--out', metavar='file', help='The name of the output self-extracting archive', type=Path, default=None) parser.add_argument('-t', '--temp', metavar='dir', help='A directory to temporarily extract files into', type=Path, default=None) parser.add_argument('-e', '--embed', help='Create an embedding layout', action='store_true', default=False) parser.add_argument('-a', '--arch', help='Specify the architecture to use (win32/amd64)', type=str, default="win32") ns = parser.parse_args() - source = ns.source or (Path(__file__).parent.parent.parent) + source = ns.source or (Path(__file__).resolve().parent.parent.parent) out = ns.out arch = ns.arch assert isinstance(source, Path) - assert isinstance(out, Path) + assert not out or isinstance(out, Path) assert isinstance(arch, str) if ns.temp: @@ -170,10 +172,11 @@ def main(): temp = Path(tempfile.mkdtemp()) delete_temp = True - try: - out.parent.mkdir(parents=True) - except FileExistsError: - pass + if out: + try: + out.parent.mkdir(parents=True) + except FileExistsError: + pass try: temp.mkdir(parents=True) except FileExistsError: @@ -190,8 +193,9 @@ def main(): with open(str(temp / 'pyvenv.cfg'), 'w') as f: print('applocal = true', file=f) - total = copy_to_layout(out, rglob(temp, '*', None)) - print('Wrote {} files to {}'.format(total, out)) + if out: + total = copy_to_layout(out, rglob(temp, '**/*', None)) + print('Wrote {} files to {}'.format(total, out)) finally: if delete_temp: shutil.rmtree(temp, True) diff --git a/Tools/nuget/make_pkg.proj b/Tools/nuget/make_pkg.proj new file mode 100644 index 0000000..812349a --- /dev/null +++ b/Tools/nuget/make_pkg.proj @@ -0,0 +1,51 @@ + + + + {10487945-15D1-4092-A214-338395C4116B} + python + $(OutputName)x86 + + false + + + + + + $(ExternalsDir)\windows-installer\nuget\nuget.exe + $(MajorVersionNumber).$(MinorVersionNumber).$(MicroVersionNumber) + false + $(OutputName).$(NuspecVersion) + .nupkg + $(OutputPath)\en-us\$(TargetName)$(TargetExt) + $(IntermediateOutputPath)\nuget_$(ArchName) + + rmdir /q/s "$(IntermediateOutputPath)" + + "$(PythonExe)" "$(MSBuildThisFileDirectory)\..\msi\make_zip.py" + $(PythonArguments) -t "$(IntermediateOutputPath)" -a $(ArchName) + + "$(Nuget)" pack "$(MSBuildThisFileDirectory)\$(OutputName).nuspec" + $(NugetArguments) -BasePath "$(IntermediateOutputPath)" + $(NugetArguments) -OutputDirectory "$(OutputPath)\en-us" + $(NugetArguments) -Version "$(NuspecVersion)" + $(NugetArguments) -NoPackageAnalysis -NonInteractive + + setlocal +set DOC_FILENAME=python$(PythonVersion).chm +set VCREDIST_PATH=$(VS140COMNTOOLS)\..\..\VC\redist\$(Platform)\Microsoft.VC140.CRT + + + + + + + + + + + + + + diff --git a/Tools/nuget/python.nuspec b/Tools/nuget/python.nuspec new file mode 100644 index 0000000..b3c5c34 --- /dev/null +++ b/Tools/nuget/python.nuspec @@ -0,0 +1,18 @@ + + + + python + Python + 0.0.0.0 + Python Software Foundation + https://docs.python.org/3/license.html + https://www.python.org/ + false + Installs 64-bit Python for use in build scenarios. + https://www.python.org/static/favicon.ico + python + + + + + diff --git a/Tools/nuget/pythonx86.nuspec b/Tools/nuget/pythonx86.nuspec new file mode 100644 index 0000000..b55c879 --- /dev/null +++ b/Tools/nuget/pythonx86.nuspec @@ -0,0 +1,18 @@ + + + + pythonx86 + Python (32-bit) + Python Software Foundation + 0.0.0.0 + https://docs.python.org/3/license.html + https://www.python.org/ + false + Installs 32-bit Python for use in build scenarios. + https://www.python.org/static/favicon.ico + python + + + + + -- cgit v0.12