""" Provides .props file. """ import os from .constants import * __all__ = ["get_props_layout"] PYTHON_PROPS_NAME = "python.props" PROPS_DATA = { "PYTHON_TAG": VER_DOT, "PYTHON_VERSION": os.getenv("PYTHON_NUSPEC_VERSION"), "PYTHON_PLATFORM": os.getenv("PYTHON_PROPS_PLATFORM"), "PYTHON_TARGET": "", } if not PROPS_DATA["PYTHON_VERSION"]: if VER_NAME: PROPS_DATA["PYTHON_VERSION"] = "{}.{}-{}{}".format( VER_DOT, VER_MICRO, VER_NAME, VER_SERIAL ) else: PROPS_DATA["PYTHON_VERSION"] = "{}.{}".format(VER_DOT, VER_MICRO) if not PROPS_DATA["PYTHON_PLATFORM"]: PROPS_DATA["PYTHON_PLATFORM"] = "x64" if IS_X64 else "Win32" PROPS_DATA["PYTHON_TARGET"] = "_GetPythonRuntimeFilesDependsOn{}{}_{}".format( VER_MAJOR, VER_MINOR, PROPS_DATA["PYTHON_PLATFORM"] ) PROPS_TEMPLATE = r""" $([msbuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), "python_d.exe") $([msbuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), "python.exe") $(PythonHome)\include $(PythonHome)\libs {PYTHON_TAG} {PYTHON_VERSION} true false false false {PYTHON_TARGET};$(GetPythonRuntimeFilesDependsOn) $(PythonInclude);%(AdditionalIncludeDirectories) MultiThreadedDLL $(PythonLibs);%(AdditionalLibraryDirectories) <_PythonRuntimeExe Include="$(PythonHome)\python*.dll" /> <_PythonRuntimeExe Include="$(PythonHome)\python*.exe" Condition="$(IncludePythonExe) == 'true'" /> <_PythonRuntimeExe> %(Filename)%(Extension) <_PythonRuntimeDlls Include="$(PythonHome)\DLLs\*.pyd" /> <_PythonRuntimeDlls Include="$(PythonHome)\DLLs\*.dll" /> <_PythonRuntimeDlls> DLLs\%(Filename)%(Extension) <_PythonRuntimeLib Include="$(PythonHome)\Lib\**\*" Exclude="$(PythonHome)\Lib\**\*.pyc;$(PythonHome)\Lib\site-packages\**\*" /> <_PythonRuntimeLib Remove="$(PythonHome)\Lib\distutils\**\*" Condition="$(IncludeDistutils) != 'true'" /> <_PythonRuntimeLib Remove="$(PythonHome)\Lib\lib2to3\**\*" Condition="$(IncludeLib2To3) != 'true'" /> <_PythonRuntimeLib Remove="$(PythonHome)\Lib\ensurepip\**\*" Condition="$(IncludeVEnv) != 'true'" /> <_PythonRuntimeLib Remove="$(PythonHome)\Lib\venv\**\*" Condition="$(IncludeVEnv) != 'true'" /> <_PythonRuntimeLib> Lib\%(RecursiveDir)%(Filename)%(Extension) """ def get_props_layout(ns): if ns.include_all or ns.include_props: # TODO: Filter contents of props file according to included/excluded items props = PROPS_TEMPLATE.format_map(PROPS_DATA) yield "python.props", ("python.props", props.encode("utf-8"))