| 
									
										
										
										
											2019-06-14 08:29:20 -07:00
										 |  |  | """
 | 
					
						
							|  |  |  | Provides .props file. | 
					
						
							|  |  |  | """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import os | 
					
						
							| 
									
										
										
										
											2020-02-25 20:07:00 +00:00
										 |  |  | import sys | 
					
						
							| 
									
										
										
										
											2019-06-14 08:29:20 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 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"), | 
					
						
							| 
									
										
										
										
											2020-02-29 00:21:46 +00:00
										 |  |  |     "FILELIST": r'    <file src="**\*" exclude="python.png" target="tools" />', | 
					
						
							| 
									
										
										
										
											2020-02-25 20:07:00 +00:00
										 |  |  |     "GIT": sys._git, | 
					
						
							| 
									
										
										
										
											2019-06-14 08:29:20 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-20 09:30:47 -08:00
										 |  |  | NUSPEC_PLATFORM_DATA = dict( | 
					
						
							|  |  |  |     _keys=("PYTHON_BITNESS", "PACKAGENAME", "PACKAGETITLE"), | 
					
						
							|  |  |  |     win32=("32-bit", "pythonx86", "Python (32-bit)"), | 
					
						
							|  |  |  |     amd64=("64-bit", "python", "Python"), | 
					
						
							|  |  |  |     arm32=("ARM", "pythonarm", "Python (ARM)"), | 
					
						
							|  |  |  |     arm64=("ARM64", "pythonarm64", "Python (ARM64)"), | 
					
						
							|  |  |  | ) | 
					
						
							| 
									
										
										
										
											2019-06-14 08:29:20 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-20 09:30:47 -08:00
										 |  |  | if not NUSPEC_DATA["PYTHON_VERSION"]: | 
					
						
							|  |  |  |     NUSPEC_DATA["PYTHON_VERSION"] = "{}.{}{}{}".format( | 
					
						
							|  |  |  |         VER_DOT, VER_MICRO, "-" if VER_SUFFIX else "", VER_SUFFIX | 
					
						
							|  |  |  |     ) | 
					
						
							| 
									
										
										
										
											2019-06-14 08:29:20 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-29 00:21:46 +00:00
										 |  |  | FILELIST_WITH_PROPS = r"""    <file src="**\*" exclude="python.png;python.props" target="tools" />
 | 
					
						
							| 
									
										
										
										
											2019-06-14 08:29:20 -07:00
										 |  |  |     <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> | 
					
						
							| 
									
										
										
										
											2020-02-29 00:21:46 +00:00
										 |  |  |     <icon>images\python.png</icon> | 
					
						
							| 
									
										
										
										
											2019-06-14 08:29:20 -07:00
										 |  |  |     <iconUrl>https://www.python.org/static/favicon.ico</iconUrl> | 
					
						
							|  |  |  |     <tags>python</tags> | 
					
						
							| 
									
										
										
										
											2020-02-25 20:07:00 +00:00
										 |  |  |     <repository type="git" url="https://github.com/Python/CPython.git" commit="{GIT[2]}" /> | 
					
						
							| 
									
										
										
										
											2019-06-14 08:29:20 -07:00
										 |  |  |   </metadata> | 
					
						
							|  |  |  |   <files> | 
					
						
							| 
									
										
										
										
											2020-02-29 00:21:46 +00:00
										 |  |  |     <file src="python.png" target="images" /> | 
					
						
							| 
									
										
										
										
											2019-06-14 08:29:20 -07:00
										 |  |  | {FILELIST} | 
					
						
							|  |  |  |   </files> | 
					
						
							|  |  |  | </package> | 
					
						
							|  |  |  | """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-20 09:30:47 -08:00
										 |  |  | def _get_nuspec_data_overrides(ns): | 
					
						
							|  |  |  |     for k, v in zip(NUSPEC_PLATFORM_DATA["_keys"], NUSPEC_PLATFORM_DATA[ns.arch]): | 
					
						
							|  |  |  |         ev = os.getenv("PYTHON_NUSPEC_" + k) | 
					
						
							|  |  |  |         if ev: | 
					
						
							|  |  |  |             yield k, ev | 
					
						
							|  |  |  |         yield k, v | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-14 08:29:20 -07:00
										 |  |  | def get_nuspec_layout(ns): | 
					
						
							|  |  |  |     if ns.include_all or ns.include_nuspec: | 
					
						
							| 
									
										
										
										
											2019-11-20 09:30:47 -08:00
										 |  |  |         data = dict(NUSPEC_DATA) | 
					
						
							|  |  |  |         for k, v in _get_nuspec_data_overrides(ns): | 
					
						
							|  |  |  |             if not data.get(k): | 
					
						
							|  |  |  |                 data[k] = v | 
					
						
							| 
									
										
										
										
											2019-06-14 08:29:20 -07:00
										 |  |  |         if ns.include_all or ns.include_props: | 
					
						
							|  |  |  |             data["FILELIST"] = FILELIST_WITH_PROPS | 
					
						
							|  |  |  |         nuspec = NUSPEC_TEMPLATE.format_map(data) | 
					
						
							|  |  |  |         yield "python.nuspec", ("python.nuspec", nuspec.encode("utf-8")) | 
					
						
							| 
									
										
										
										
											2020-02-29 00:21:46 +00:00
										 |  |  |         yield "python.png", ns.source / "PC" / "icons" / "logox128.png" |