summaryrefslogtreecommitdiff
path: root/PC/layout/support/nuspec.py
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@python.org>2019-06-14 08:29:20 -0700
committerGitHub <noreply@github.com>2019-06-14 08:29:20 -0700
commit21a92f8cda525d25a165b773fbe1bfffd303a000 (patch)
tree84d08fcb306ee46d6f5147d734745af0c3f64b7b /PC/layout/support/nuspec.py
parentf0749da9a535375f05a2015e8960e8ae54877349 (diff)
downloadcpython-git-21a92f8cda525d25a165b773fbe1bfffd303a000.tar.gz
Implement Windows release builds in Azure Pipelines (GH-14065)
Diffstat (limited to 'PC/layout/support/nuspec.py')
-rw-r--r--PC/layout/support/nuspec.py66
1 files changed, 66 insertions, 0 deletions
diff --git a/PC/layout/support/nuspec.py b/PC/layout/support/nuspec.py
new file mode 100644
index 0000000000..ba26ff337e
--- /dev/null
+++ b/PC/layout/support/nuspec.py
@@ -0,0 +1,66 @@
+"""
+Provides .props file.
+"""
+
+import os
+
+from .constants import *
+
+__all__ = ["get_nuspec_layout"]
+
+PYTHON_NUSPEC_NAME = "python.nuspec"
+
+NUSPEC_DATA = {
+ "PYTHON_TAG": VER_DOT,
+ "PYTHON_VERSION": os.getenv("PYTHON_NUSPEC_VERSION"),
+ "PYTHON_BITNESS": "64-bit" if IS_X64 else "32-bit",
+ "PACKAGENAME": os.getenv("PYTHON_NUSPEC_PACKAGENAME"),
+ "PACKAGETITLE": os.getenv("PYTHON_NUSPEC_PACKAGETITLE"),
+ "FILELIST": r' <file src="**\*" target="tools" />',
+}
+
+if not NUSPEC_DATA["PYTHON_VERSION"]:
+ if VER_NAME:
+ NUSPEC_DATA["PYTHON_VERSION"] = "{}.{}-{}{}".format(
+ VER_DOT, VER_MICRO, VER_NAME, VER_SERIAL
+ )
+ else:
+ NUSPEC_DATA["PYTHON_VERSION"] = "{}.{}".format(VER_DOT, VER_MICRO)
+
+if not NUSPEC_DATA["PACKAGETITLE"]:
+ NUSPEC_DATA["PACKAGETITLE"] = "Python" if IS_X64 else "Python (32-bit)"
+
+if not NUSPEC_DATA["PACKAGENAME"]:
+ NUSPEC_DATA["PACKAGENAME"] = "python" if IS_X64 else "pythonx86"
+
+FILELIST_WITH_PROPS = r""" <file src="**\*" exclude="python.props" target="tools" />
+ <file src="python.props" target="build\native" />"""
+
+NUSPEC_TEMPLATE = r"""<?xml version="1.0"?>
+<package>
+ <metadata>
+ <id>{PACKAGENAME}</id>
+ <title>{PACKAGETITLE}</title>
+ <version>{PYTHON_VERSION}</version>
+ <authors>Python Software Foundation</authors>
+ <license type="file">tools\LICENSE.txt</license>
+ <projectUrl>https://www.python.org/</projectUrl>
+ <description>Installs {PYTHON_BITNESS} Python for use in build scenarios.</description>
+ <iconUrl>https://www.python.org/static/favicon.ico</iconUrl>
+ <tags>python</tags>
+ </metadata>
+ <files>
+{FILELIST}
+ </files>
+</package>
+"""
+
+
+def get_nuspec_layout(ns):
+ if ns.include_all or ns.include_nuspec:
+ data = NUSPEC_DATA
+ if ns.include_all or ns.include_props:
+ data = dict(data)
+ data["FILELIST"] = FILELIST_WITH_PROPS
+ nuspec = NUSPEC_TEMPLATE.format_map(data)
+ yield "python.nuspec", ("python.nuspec", nuspec.encode("utf-8"))