Skip to content

Commit 1f06a68

Browse files
authored
Add props file for nuget packages (#3410)
1 parent d3b9f97 commit 1f06a68

File tree

5 files changed

+76
-3
lines changed

5 files changed

+76
-3
lines changed

Tools/nuget/make_pkg.proj

+14
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,20 @@
5151
<Exec Command="setlocal%0D%0A$(Environment)%0D%0A$(PythonArguments)" />
5252
<Exec Command="$(PipArguments)" />
5353
<Exec Command="$(PackageArguments)" Condition="$(PackageArguments) != ''" />
54+
55+
<PropertyGroup>
56+
<_PropsContents>$([System.IO.File]::ReadAllText('python.props'))</_PropsContents>
57+
<_PropsContents>$(_PropsContents.Replace('$$PYTHON_TAG$$', '$(MajorVersionNumber).$(MinorVersionNumber)'))</_PropsContents>
58+
<_PropsContents>$(_PropsContents.Replace('$$PYTHON_VERSION$$', '$(NuspecVersion)'))</_PropsContents>
59+
<_PropsContents Condition="$(Platform) == 'x86'">$(_PropsContents.Replace('$$PYTHON_PLATFORM$$', 'Win32'))</_PropsContents>
60+
<_PropsContents Condition="$(Platform) != 'x86'">$(_PropsContents.Replace('$$PYTHON_PLATFORM$$', '$(Platform)'))</_PropsContents>
61+
<_PropsContents>$(_PropsContents.Replace('$$PYTHON_TARGET$$', '_GetPythonRuntimeFilesDependsOn$(MajorVersionNumber)$(MinorVersionNumber)_$(Platform)'))</_PropsContents>
62+
<_ExistingContents Condition="Exists('$(IntermediateOutputPath)\python.props')">$([System.IO.File]::ReadAllText('$(IntermediateOutputPath)\python.props'))</_ExistingContents>
63+
</PropertyGroup>
64+
<WriteLinesToFile File="$(IntermediateOutputPath)\python.props"
65+
Lines="$(_PropsContents)"
66+
Condition="$(_PropsContents) != $(_ExistingContents)" />
67+
5468
<Exec Command="$(NugetPackCommand) $(NugetArguments)" />
5569
<Exec Command="$(NugetPackSymbolsCommand) $(NugetArguments)" Condition="$(NugetPackSymbolsCommand) != ''" />
5670
</Target>

Tools/nuget/python.nuspec

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<tags>python</tags>
1414
</metadata>
1515
<files>
16-
<file src="**\*" target="tools" />
16+
<file src="**\*" exclude="python.props" target="tools" />
17+
<file src="python.props" target="build\native" />
1718
</files>
1819
</package>

Tools/nuget/python.props

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup Condition="$(Platform) == '$$PYTHON_PLATFORM$$'">
4+
<PythonHome>$(MSBuildThisFileDirectory)\..\..\tools</PythonHome>
5+
<PythonInclude>$(PythonHome)\include</PythonInclude>
6+
<PythonLibs>$(PythonHome)\libs</PythonLibs>
7+
<PythonTag>$$PYTHON_TAG$$</PythonTag>
8+
<PythonVersion>$$PYTHON_VERSION$$</PythonVersion>
9+
10+
<IncludePythonExe Condition="$(IncludePythonExe) == ''">true</IncludePythonExe>
11+
<IncludeDistutils Condition="$(IncludeDistutils) == ''">false</IncludeDistutils>
12+
<IncludeLib2To3 Condition="$(IncludeLib2To3) == ''">false</IncludeLib2To3>
13+
<IncludeVEnv Condition="$(IncludeVEnv) == ''">false</IncludeVEnv>
14+
15+
<GetPythonRuntimeFilesDependsOn>$$PYTHON_TARGET$$;$(GetPythonRuntimeFilesDependsOn)</GetPythonRuntimeFilesDependsOn>
16+
</PropertyGroup>
17+
18+
<ItemDefinitionGroup Condition="$(Platform) == '$$PYTHON_PLATFORM$$'">
19+
<ClCompile>
20+
<AdditionalIncludeDirectories>$(PythonInclude);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
21+
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
22+
</ClCompile>
23+
<Link>
24+
<AdditionalLibraryDirectories>$(PythonLibs);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
25+
</Link>
26+
</ItemDefinitionGroup>
27+
28+
<Target Name="GetPythonRuntimeFiles" Returns="@(PythonRuntime)" DependsOnTargets="$(GetPythonRuntimeFilesDependsOn)" />
29+
30+
<Target Name="$$PYTHON_TARGET$$" Returns="@(PythonRuntime)">
31+
<ItemGroup>
32+
<_PythonRuntimeExe Include="$(PythonHome)\python*.dll" />
33+
<_PythonRuntimeExe Include="$(PythonHome)\vcruntime140.dll" />
34+
<_PythonRuntimeExe Include="$(PythonHome)\python*.exe" Condition="$(IncludePythonExe) == 'true'" />
35+
<_PythonRuntimeExe>
36+
<Link>%(Filename)%(Extension)</Link>
37+
</_PythonRuntimeExe>
38+
<_PythonRuntimeDlls Include="$(PythonHome)\DLLs\*.pyd" />
39+
<_PythonRuntimeDlls Include="$(PythonHome)\DLLs\*.dll" />
40+
<_PythonRuntimeDlls>
41+
<Link>DLLs\%(Filename)%(Extension)</Link>
42+
</_PythonRuntimeDlls>
43+
<_PythonRuntimeLib Include="$(PythonHome)\Lib\**\*" Exclude="$(PythonHome)\Lib\**\*.pyc;$(PythonHome)\Lib\site-packages\**\*" />
44+
<_PythonRuntimeLib Remove="$(PythonHome)\Lib\distutils\**\*" Condition="$(IncludeDistutils) != 'true'" />
45+
<_PythonRuntimeLib Remove="$(PythonHome)\Lib\lib2to3\**\*" Condition="$(IncludeLib2To3) != 'true'" />
46+
<_PythonRuntimeLib Remove="$(PythonHome)\Lib\ensurepip\**\*" Condition="$(IncludeVEnv) != 'true'" />
47+
<_PythonRuntimeLib Remove="$(PythonHome)\Lib\venv\**\*" Condition="$(IncludeVEnv) != 'true'" />
48+
<_PythonRuntimeLib>
49+
<Link>Lib\%(RecursiveDir)%(Filename)%(Extension)</Link>
50+
</_PythonRuntimeLib>
51+
<PythonRuntime Include="@(_PythonRuntimeExe);@(_PythonRuntimeDlls);@(_PythonRuntimeLib)" />
52+
</ItemGroup>
53+
54+
<Message Importance="low" Text="Collected Python runtime from $(PythonHome):%0D%0A@(PythonRuntime->' %(Link)','%0D%0A')" />
55+
</Target>
56+
</Project>

Tools/nuget/pythondaily.nuspec

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<tags>python</tags>
1414
</metadata>
1515
<files>
16-
<file src="**\*" target="tools" />
16+
<file src="**\*" exclude="python.props" target="tools" />
17+
<file src="python.props" target="build\native" />
1718
</files>
1819
</package>

Tools/nuget/pythonx86.nuspec

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<tags>python</tags>
1414
</metadata>
1515
<files>
16-
<file src="**\*" target="tools" />
16+
<file src="**\*" exclude="python.props" target="tools" />
17+
<file src="python.props" target="build\native" />
1718
</files>
1819
</package>

0 commit comments

Comments
 (0)