[Python-checkins] cpython (3.5): Adds scripts for producing Nuget packages.

steve.dower python-checkins at python.org
Fri Jun 24 13:33:09 EDT 2016


https://hg.python.org/cpython/rev/4d92949a2080
changeset:   102155:4d92949a2080
branch:      3.5
parent:      102153:be435520e493
user:        Steve Dower <steve.dower at microsoft.com>
date:        Fri Jun 24 10:32:15 2016 -0700
summary:
  Adds scripts for producing Nuget packages.

files:
  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(-)


diff --git a/Tools/msi/make_zip.py b/Tools/msi/make_zip.py
--- a/Tools/msi/make_zip.py
+++ b/Tools/msi/make_zip.py
@@ -75,10 +75,12 @@
     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 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 @@
         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 @@
         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
--- /dev/null
+++ b/Tools/nuget/make_pkg.proj
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+    <PropertyGroup>
+        <ProjectGuid>{10487945-15D1-4092-A214-338395C4116B}</ProjectGuid>
+        <OutputName>python</OutputName>
+        <OutputName Condition="$(Platform) == 'x86'">$(OutputName)x86</OutputName>
+        <OutputSuffix></OutputSuffix>
+        <SupportSigning>false</SupportSigning>
+    </PropertyGroup>
+
+    <Import Project="..\msi\msi.props" />
+
+    <PropertyGroup>
+        <Nuget Condition="$(Nuget) == ''">$(ExternalsDir)\windows-installer\nuget\nuget.exe</Nuget>
+        <NuspecVersion>$(MajorVersionNumber).$(MinorVersionNumber).$(MicroVersionNumber)</NuspecVersion>
+        <SignOutput>false</SignOutput>
+        <TargetName>$(OutputName).$(NuspecVersion)</TargetName>
+        <TargetExt>.nupkg</TargetExt>
+        <TargetPath>$(OutputPath)\en-us\$(TargetName)$(TargetExt)</TargetPath>
+        <IntermediateOutputPath>$(IntermediateOutputPath)\nuget_$(ArchName)</IntermediateOutputPath>
+        
+        <CleanCommand>rmdir /q/s "$(IntermediateOutputPath)"</CleanCommand>
+        
+        <PythonArguments>"$(PythonExe)" "$(MSBuildThisFileDirectory)\..\msi\make_zip.py"</PythonArguments>
+        <PythonArguments>$(PythonArguments) -t "$(IntermediateOutputPath)" -a $(ArchName)</PythonArguments>
+        
+        <NugetArguments>"$(Nuget)" pack "$(MSBuildThisFileDirectory)\$(OutputName).nuspec"</NugetArguments>
+        <NugetArguments>$(NugetArguments) -BasePath "$(IntermediateOutputPath)"</NugetArguments>
+        <NugetArguments>$(NugetArguments) -OutputDirectory "$(OutputPath)\en-us"</NugetArguments>
+        <NugetArguments>$(NugetArguments) -Version "$(NuspecVersion)"</NugetArguments>
+        <NugetArguments>$(NugetArguments) -NoPackageAnalysis -NonInteractive</NugetArguments>
+        
+        <Environment>setlocal
+set DOC_FILENAME=python$(PythonVersion).chm
+set VCREDIST_PATH=$(VS140COMNTOOLS)\..\..\VC\redist\$(Platform)\Microsoft.VC140.CRT</Environment>
+    </PropertyGroup>
+
+    <Target Name="_NugetMissing" BeforeTargets="_Build" Condition="!Exists($(Nuget))">
+        <Error Text="$(Nuget) could not be found. Either avoid specifying the property or update your externals/windows-installer files." />
+    </Target>
+
+    <Target Name="_Build">
+        <Exec Command="$(Environment)
+$(CleanCommand)
+$(PythonArguments)" />
+        <Exec Command="$(NugetArguments)" />
+    </Target>
+
+    <Target Name="AfterBuild" />
+    <Target Name="Build" DependsOnTargets="_Build;AfterBuild" />
+</Project>
diff --git a/Tools/nuget/python.nuspec b/Tools/nuget/python.nuspec
new file mode 100644
--- /dev/null
+++ b/Tools/nuget/python.nuspec
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<package >
+  <metadata>
+    <id>python</id>
+    <title>Python</title>
+    <version>0.0.0.0</version>
+    <authors>Python Software Foundation</authors>
+    <licenseUrl>https://docs.python.org/3/license.html</licenseUrl>
+    <projectUrl>https://www.python.org/</projectUrl>
+    <requireLicenseAcceptance>false</requireLicenseAcceptance>
+    <description>Installs 64-bit Python for use in build scenarios.</description>
+    <iconUrl>https://www.python.org/static/favicon.ico</iconUrl>
+    <tags>python</tags>
+  </metadata>
+  <files>
+    <file src="**\*" target="tools" />
+  </files>
+</package>
diff --git a/Tools/nuget/pythonx86.nuspec b/Tools/nuget/pythonx86.nuspec
new file mode 100644
--- /dev/null
+++ b/Tools/nuget/pythonx86.nuspec
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<package >
+  <metadata>
+    <id>pythonx86</id>
+    <title>Python (32-bit)</title>
+    <authors>Python Software Foundation</authors>
+    <version>0.0.0.0</version>
+    <licenseUrl>https://docs.python.org/3/license.html</licenseUrl>
+    <projectUrl>https://www.python.org/</projectUrl>
+    <requireLicenseAcceptance>false</requireLicenseAcceptance>
+    <description>Installs 32-bit Python for use in build scenarios.</description>
+    <iconUrl>https://www.python.org/static/favicon.ico</iconUrl>
+    <tags>python</tags>
+  </metadata>
+  <files>
+    <file src="**\*" target="tools" />
+  </files>
+</package>

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list