Skip to content

Commit 33f7310

Browse files
committed
Adds scripts for producing Nuget packages.
1 parent a064382 commit 33f7310

4 files changed

Lines changed: 103 additions & 12 deletions

File tree

Tools/msi/make_zip.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,12 @@ def include_in_tools(p):
7575
return p.suffix.lower() in {'.py', '.pyw', '.txt'}
7676

7777
FULL_LAYOUT = [
78-
('/', 'PCBuild/$arch', 'python*.exe', is_not_debug),
79-
('/', 'PCBuild/$arch', 'python*.dll', is_not_debug),
78+
('/', 'PCBuild/$arch', 'python.exe', is_not_debug),
79+
('/', 'PCBuild/$arch', 'pythonw.exe', is_not_debug),
80+
('/', 'PCBuild/$arch', 'python{0.major}.dll'.format(sys.version_info), is_not_debug),
81+
('/', 'PCBuild/$arch', 'python{0.major}{0.minor}.dll'.format(sys.version_info), is_not_debug),
8082
('DLLs/', 'PCBuild/$arch', '*.pyd', is_not_debug),
81-
('DLLs/', 'PCBuild/$arch', '*.dll', is_not_debug),
83+
('DLLs/', 'PCBuild/$arch', '*.dll', is_not_debug_or_python),
8284
('include/', 'include', '*.h', None),
8385
('include/', 'PC', 'pyconfig.h', None),
8486
('Lib/', 'Lib', '**/*', include_in_lib),
@@ -150,17 +152,17 @@ def rglob(root, pattern, condition):
150152
def main():
151153
parser = argparse.ArgumentParser()
152154
parser.add_argument('-s', '--source', metavar='dir', help='The directory containing the repository root', type=Path)
153-
parser.add_argument('-o', '--out', metavar='file', help='The name of the output self-extracting archive', type=Path, required=True)
155+
parser.add_argument('-o', '--out', metavar='file', help='The name of the output self-extracting archive', type=Path, default=None)
154156
parser.add_argument('-t', '--temp', metavar='dir', help='A directory to temporarily extract files into', type=Path, default=None)
155157
parser.add_argument('-e', '--embed', help='Create an embedding layout', action='store_true', default=False)
156158
parser.add_argument('-a', '--arch', help='Specify the architecture to use (win32/amd64)', type=str, default="win32")
157159
ns = parser.parse_args()
158160

159-
source = ns.source or (Path(__file__).parent.parent.parent)
161+
source = ns.source or (Path(__file__).resolve().parent.parent.parent)
160162
out = ns.out
161163
arch = ns.arch
162164
assert isinstance(source, Path)
163-
assert isinstance(out, Path)
165+
assert not out or isinstance(out, Path)
164166
assert isinstance(arch, str)
165167

166168
if ns.temp:
@@ -170,10 +172,11 @@ def main():
170172
temp = Path(tempfile.mkdtemp())
171173
delete_temp = True
172174

173-
try:
174-
out.parent.mkdir(parents=True)
175-
except FileExistsError:
176-
pass
175+
if out:
176+
try:
177+
out.parent.mkdir(parents=True)
178+
except FileExistsError:
179+
pass
177180
try:
178181
temp.mkdir(parents=True)
179182
except FileExistsError:
@@ -190,8 +193,9 @@ def main():
190193
with open(str(temp / 'pyvenv.cfg'), 'w') as f:
191194
print('applocal = true', file=f)
192195

193-
total = copy_to_layout(out, rglob(temp, '*', None))
194-
print('Wrote {} files to {}'.format(total, out))
196+
if out:
197+
total = copy_to_layout(out, rglob(temp, '**/*', None))
198+
print('Wrote {} files to {}'.format(total, out))
195199
finally:
196200
if delete_temp:
197201
shutil.rmtree(temp, True)

Tools/nuget/make_pkg.proj

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<ProjectGuid>{10487945-15D1-4092-A214-338395C4116B}</ProjectGuid>
5+
<OutputName>python</OutputName>
6+
<OutputName Condition="$(Platform) == 'x86'">$(OutputName)x86</OutputName>
7+
<OutputSuffix></OutputSuffix>
8+
<SupportSigning>false</SupportSigning>
9+
</PropertyGroup>
10+
11+
<Import Project="..\msi\msi.props" />
12+
13+
<PropertyGroup>
14+
<Nuget Condition="$(Nuget) == ''">$(ExternalsDir)\windows-installer\nuget\nuget.exe</Nuget>
15+
<NuspecVersion>$(MajorVersionNumber).$(MinorVersionNumber).$(MicroVersionNumber)</NuspecVersion>
16+
<SignOutput>false</SignOutput>
17+
<TargetName>$(OutputName).$(NuspecVersion)</TargetName>
18+
<TargetExt>.nupkg</TargetExt>
19+
<TargetPath>$(OutputPath)\en-us\$(TargetName)$(TargetExt)</TargetPath>
20+
<IntermediateOutputPath>$(IntermediateOutputPath)\nuget_$(ArchName)</IntermediateOutputPath>
21+
22+
<CleanCommand>rmdir /q/s "$(IntermediateOutputPath)"</CleanCommand>
23+
24+
<PythonArguments>"$(PythonExe)" "$(MSBuildThisFileDirectory)\..\msi\make_zip.py"</PythonArguments>
25+
<PythonArguments>$(PythonArguments) -t "$(IntermediateOutputPath)" -a $(ArchName)</PythonArguments>
26+
27+
<NugetArguments>"$(Nuget)" pack "$(MSBuildThisFileDirectory)\$(OutputName).nuspec"</NugetArguments>
28+
<NugetArguments>$(NugetArguments) -BasePath "$(IntermediateOutputPath)"</NugetArguments>
29+
<NugetArguments>$(NugetArguments) -OutputDirectory "$(OutputPath)\en-us"</NugetArguments>
30+
<NugetArguments>$(NugetArguments) -Version "$(NuspecVersion)"</NugetArguments>
31+
<NugetArguments>$(NugetArguments) -NoPackageAnalysis -NonInteractive</NugetArguments>
32+
33+
<Environment>setlocal
34+
set DOC_FILENAME=python$(PythonVersion).chm
35+
set VCREDIST_PATH=$(VS140COMNTOOLS)\..\..\VC\redist\$(Platform)\Microsoft.VC140.CRT</Environment>
36+
</PropertyGroup>
37+
38+
<Target Name="_NugetMissing" BeforeTargets="_Build" Condition="!Exists($(Nuget))">
39+
<Error Text="$(Nuget) could not be found. Either avoid specifying the property or update your externals/windows-installer files." />
40+
</Target>
41+
42+
<Target Name="_Build">
43+
<Exec Command="$(Environment)
44+
$(CleanCommand)
45+
$(PythonArguments)" />
46+
<Exec Command="$(NugetArguments)" />
47+
</Target>
48+
49+
<Target Name="AfterBuild" />
50+
<Target Name="Build" DependsOnTargets="_Build;AfterBuild" />
51+
</Project>

Tools/nuget/python.nuspec

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0"?>
2+
<package >
3+
<metadata>
4+
<id>python</id>
5+
<title>Python</title>
6+
<version>0.0.0.0</version>
7+
<authors>Python Software Foundation</authors>
8+
<licenseUrl>https://docs.python.org/3/license.html</licenseUrl>
9+
<projectUrl>https://www.python.org/</projectUrl>
10+
<requireLicenseAcceptance>false</requireLicenseAcceptance>
11+
<description>Installs 64-bit Python for use in build scenarios.</description>
12+
<iconUrl>https://www.python.org/static/favicon.ico</iconUrl>
13+
<tags>python</tags>
14+
</metadata>
15+
<files>
16+
<file src="**\*" target="tools" />
17+
</files>
18+
</package>

Tools/nuget/pythonx86.nuspec

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0"?>
2+
<package >
3+
<metadata>
4+
<id>pythonx86</id>
5+
<title>Python (32-bit)</title>
6+
<authors>Python Software Foundation</authors>
7+
<version>0.0.0.0</version>
8+
<licenseUrl>https://docs.python.org/3/license.html</licenseUrl>
9+
<projectUrl>https://www.python.org/</projectUrl>
10+
<requireLicenseAcceptance>false</requireLicenseAcceptance>
11+
<description>Installs 32-bit Python for use in build scenarios.</description>
12+
<iconUrl>https://www.python.org/static/favicon.ico</iconUrl>
13+
<tags>python</tags>
14+
</metadata>
15+
<files>
16+
<file src="**\*" target="tools" />
17+
</files>
18+
</package>

0 commit comments

Comments
 (0)