]> granicus.if.org Git - python/commitdiff
Add props file for nuget packages (#3410) (#3413)
authorSteve Dower <steve.dower@microsoft.com>
Thu, 7 Sep 2017 03:41:32 +0000 (20:41 -0700)
committerGitHub <noreply@github.com>
Thu, 7 Sep 2017 03:41:32 +0000 (20:41 -0700)
Tools/nuget/make_pkg.proj
Tools/nuget/python.nuspec
Tools/nuget/python.props [new file with mode: 0644]
Tools/nuget/pythondaily.nuspec
Tools/nuget/pythonx86.nuspec

index 3750d8dcc860e862c93595b9dd031c4ec270dcd8..9843bc97ccdc1e3fc41b57cc8f9e1dc9ddd0fc45 100644 (file)
@@ -30,8 +30,8 @@
         <PipArguments>"$(IntermediateOutputPath)\python.exe" -B -c "import sys; sys.path.append(r'$(PySourcePath)\Lib'); import ensurepip; ensurepip._main()"</PipArguments>
         <PackageArguments Condition="$(Packages) != ''">"$(IntermediateOutputPath)\python.exe" -B -m pip install -U $(Packages)</PackageArguments>
         
-        <NugetArguments>"$(Nuget)" pack "$(MSBuildThisFileDirectory)\$(OutputName).nuspec"</NugetArguments>
-        <NugetArguments>$(NugetArguments) -BasePath "$(IntermediateOutputPath)"</NugetArguments>
+        <NugetPackCommand>"$(Nuget)" pack "$(MSBuildThisFileDirectory)\$(OutputName).nuspec" -BasePath "$(IntermediateOutputPath)"</NugetPackCommand>
+        <NugetPackSymbolsCommand Condition="Exists('$(MSBuildThisFileDirectory)\$(OutputName).symbols.nuspec')">"$(Nuget)" pack "$(MSBuildThisFileDirectory)\$(OutputName).symbols.nuspec" -BasePath "$(BuildPath.TrimEnd(`\`))"</NugetPackSymbolsCommand>
         <NugetArguments>$(NugetArguments) -OutputDirectory "$(OutputPath.Trim(`\`))"</NugetArguments>
         <NugetArguments>$(NugetArguments) -Version "$(NuspecVersion)"</NugetArguments>
         <NugetArguments>$(NugetArguments) -NoPackageAnalysis -NonInteractive</NugetArguments>
         <Exec Command="setlocal%0D%0A$(Environment)%0D%0A$(PythonArguments)" />
         <Exec Command="$(PipArguments)" />
         <Exec Command="$(PackageArguments)" Condition="$(PackageArguments) != ''" />
-        <Exec Command="$(NugetArguments)" />
+
+        <PropertyGroup>
+            <_PropsContents>$([System.IO.File]::ReadAllText('python.props'))</_PropsContents>
+            <_PropsContents>$(_PropsContents.Replace('$$PYTHON_TAG$$', '$(MajorVersionNumber).$(MinorVersionNumber)'))</_PropsContents>
+            <_PropsContents>$(_PropsContents.Replace('$$PYTHON_VERSION$$', '$(NuspecVersion)'))</_PropsContents>
+            <_PropsContents Condition="$(Platform) == 'x86'">$(_PropsContents.Replace('$$PYTHON_PLATFORM$$', 'Win32'))</_PropsContents>
+            <_PropsContents Condition="$(Platform) != 'x86'">$(_PropsContents.Replace('$$PYTHON_PLATFORM$$', '$(Platform)'))</_PropsContents>
+            <_PropsContents>$(_PropsContents.Replace('$$PYTHON_TARGET$$', '_GetPythonRuntimeFilesDependsOn$(MajorVersionNumber)$(MinorVersionNumber)_$(Platform)'))</_PropsContents>
+            <_ExistingContents Condition="Exists('$(IntermediateOutputPath)\python.props')">$([System.IO.File]::ReadAllText('$(IntermediateOutputPath)\python.props'))</_ExistingContents>
+        </PropertyGroup>
+        <WriteLinesToFile File="$(IntermediateOutputPath)\python.props"
+                          Lines="$(_PropsContents)"
+                          Condition="$(_PropsContents) != $(_ExistingContents)" />
+
+        <Exec Command="$(NugetPackCommand) $(NugetArguments)" />
+        <Exec Command="$(NugetPackSymbolsCommand) $(NugetArguments)" Condition="$(NugetPackSymbolsCommand) != ''" />
     </Target>
 
     <Target Name="AfterBuild" />
index b3c5c3487adfb9fcd8f8b1a28323e2c997a676cc..d5f3e6324236724e306404b47fb906127703818b 100644 (file)
@@ -13,6 +13,7 @@
     <tags>python</tags>
   </metadata>
   <files>
-    <file src="**\*" target="tools" />
+    <file src="**\*" exclude="python.props" target="tools" />
+    <file src="python.props" target="build\native" />
   </files>
 </package>
diff --git a/Tools/nuget/python.props b/Tools/nuget/python.props
new file mode 100644 (file)
index 0000000..4cc7008
--- /dev/null
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup Condition="$(Platform) == '$$PYTHON_PLATFORM$$'">
+    <PythonHome>$(MSBuildThisFileDirectory)\..\..\tools</PythonHome>
+    <PythonInclude>$(PythonHome)\include</PythonInclude>
+    <PythonLibs>$(PythonHome)\libs</PythonLibs>
+    <PythonTag>$$PYTHON_TAG$$</PythonTag>
+    <PythonVersion>$$PYTHON_VERSION$$</PythonVersion>
+    
+    <IncludePythonExe Condition="$(IncludePythonExe) == ''">true</IncludePythonExe>
+    <IncludeDistutils Condition="$(IncludeDistutils) == ''">false</IncludeDistutils>
+    <IncludeLib2To3 Condition="$(IncludeLib2To3) == ''">false</IncludeLib2To3>
+    <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)\vcruntime140.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\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>
+        <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>
index 2634ed14a88d6c349fe0eeaa7a2879bef6046599..ee3343bbb7b324832db08d7323f5cc3ec08d1315 100644 (file)
@@ -13,6 +13,7 @@
     <tags>python</tags>
   </metadata>
   <files>
-    <file src="**\*" target="tools" />
+    <file src="**\*" exclude="python.props" target="tools" />
+    <file src="python.props" target="build\native" />
   </files>
 </package>
index b55c8799c0f090570f3dac15fc995d26cb08f01e..ebfcd6c92a4a6442be389c9b7ed95adb79372aef 100644 (file)
@@ -13,6 +13,7 @@
     <tags>python</tags>
   </metadata>
   <files>
-    <file src="**\*" target="tools" />
+    <file src="**\*" exclude="python.props" target="tools" />
+    <file src="python.props" target="build\native" />
   </files>
 </package>