provides props file def getpropslayoutns if ns includeall or ns includeprops todo filter contents of props file according to includedexcluded items d dictpropsdata if not d getpythonplatform dpythonplatform win32 win32 amd64 x64 arm32 arm arm64 arm64 ns arch props propstemplate formatmapd yield python props python props props encodeutf8 xml version 1 0 encoding utf 8 project xmlns http schemas microsoft com developer msbuild 2003 propertygroup condition platform python_platform pythonhome condition pythonhome system io path getfullpath msbuildthisfiledirectory tools pythonhome pythoninclude pythonhome include pythoninclude pythonlibs pythonhome libs pythonlibs pythontag python_tag pythontag pythonversion python_version pythonversion includepythonexe condition includepythonexe true includepythonexe includevenv condition includevenv false includevenv getpythonruntimefilesdependson python_target getpythonruntimefilesdependson getpythonruntimefilesdependson propertygroup itemdefinitiongroup condition platform python_platform clcompile additionalincludedirectories pythoninclude additionalincludedirectories additionalincludedirectories runtimelibrary multithreadeddll runtimelibrary clcompile link additionallibrarydirectories pythonlibs additionallibrarydirectories additionallibrarydirectories link itemdefinitiongroup target name getpythonruntimefiles returns pythonruntime dependsontargets getpythonruntimefilesdependson target name python_target returns pythonruntime itemgroup _pythonruntimeexe include pythonhome python dll _pythonruntimeexe include pythonhome python exe condition includepythonexe true _pythonruntimeexe link filename extension link _pythonruntimeexe _pythonruntimedlls include pythonhome dlls pyd _pythonruntimedlls include pythonhome dlls dll _pythonruntimedlls link dlls filename extension link _pythonruntimedlls _pythonruntimelib include pythonhome lib exclude pythonhome lib pyc pythonhome lib site packages _pythonruntimelib remove pythonhome lib ensurepip condition includevenv true _pythonruntimelib remove pythonhome lib venv condition includevenv true _pythonruntimelib link lib recursivedir filename extension link _pythonruntimelib pythonruntime include _pythonruntimeexe _pythonruntimedlls _pythonruntimelib itemgroup message importance low text collected python runtime from pythonhome 0d 0a pythonruntime link 0d 0a target project todo filter contents of props file according to included excluded items
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"]:
    PROPS_DATA["PYTHON_VERSION"] = "{}.{}{}{}".format(
        VER_DOT, VER_MICRO, "-" if VER_SUFFIX else "", VER_SUFFIX
    )

PROPS_DATA["PYTHON_TARGET"] = "_GetPythonRuntimeFilesDependsOn{}{}_{}".format(
    VER_MAJOR, VER_MINOR, PROPS_DATA["PYTHON_PLATFORM"]
)

PROPS_TEMPLATE = r


def get_props_layout(ns):
    if ns.include_all or ns.include_props:
        
        d = dict(PROPS_DATA)
        if not d.get("PYTHON_PLATFORM"):
            d["PYTHON_PLATFORM"] = {
                "win32": "Win32",
                "amd64": "X64",
                "arm32": "ARM",
                "arm64": "ARM64",
            }[ns.arch]
        props = PROPS_TEMPLATE.format_map(d)
        yield "python.props", ("python.props", props.encode("utf-8"))