Skip to content

Commit 6e2c7c8

Browse files
committed
Add VCRuntime to Python 2
We need to copy the vcruntime dll as it is a dependency of python2.
1 parent 38077d1 commit 6e2c7c8

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

PCbuild/pyproject.props

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,24 @@ foreach (System.Diagnostics.Process p in System.Diagnostics.Process.GetProcesses
157157
<Error Text="Unable to locate signtool.exe. Set /p:SignToolPath and rebuild" Condition="'$(_SignCommand)' == ''" />
158158
<Exec Command='$(_SignCommand) "$(TargetPath)" || $(_SignCommand) "$(TargetPath)" || $(_SignCommand) "$(TargetPath)"' ContinueOnError="false" />
159159
</Target>
160+
161+
<Target Name="FindVCRuntime" Returns="VCRuntimeDLL">
162+
<PropertyGroup Condition="$(PlatformToolset) != 'v140'">
163+
<VCRedistDir>$(VCInstallDir)\Redist\MSVC\$(VCToolsRedistVersion)\</VCRedistDir>
164+
<VCRedistDir Condition="$(Platform) == 'Win32'">$(VCRedistDir)x86\</VCRedistDir>
165+
<VCRedistDir Condition="$(Platform) != 'Win32'">$(VCRedistDir)$(Platform)\</VCRedistDir>
166+
</PropertyGroup>
167+
<PropertyGroup Condition="$(PlatformToolset) == 'v140'">
168+
<VCRedistDir>$(VCInstallDir)\redist\</VCRedistDir>
169+
<VCRedistDir Condition="$(Platform) == 'Win32'">$(VCRedistDir)x86\</VCRedistDir>
170+
<VCRedistDir Condition="$(Platform) != 'Win32'">$(VCRedistDir)$(Platform)\</VCRedistDir>
171+
</PropertyGroup>
172+
173+
<ItemGroup Condition="$(VCInstallDir) != ''">
174+
<VCRuntimeDLL Include="$(VCRedistDir)\Microsoft.VC*.CRT\vcruntime*.dll" />
175+
</ItemGroup>
176+
177+
<Error Text="vcruntime14*.dll not found under $(VCInstallDir)" Condition="@(VCRuntimeDLL) == ''" />
178+
<Message Text="VCRuntimeDLL: @(VCRuntimeDLL)" Importance="high" />
179+
</Target>
160180
</Project>

PCbuild/pythoncore.vcxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,4 +406,12 @@
406406
<Target Name="_WarnAboutToolset" BeforeTargets="PrepareForBuild" Condition="$(PlatformToolset) != 'v90'">
407407
<Warning Text="Toolset $(PlatformToolset) is not used for official builds. Your build may have errors or incompatibilities." />
408408
</Target>
409+
<Target Name="_CopyVCRuntime" AfterTargets="Build" Inputs="@(VCRuntimeDLL)" Outputs="$(OutDir)%(Filename)%(Extension)" DependsOnTargets="FindVCRuntime">
410+
<!-- bpo-38597: When we switch to another VCRuntime DLL, include vcruntime140.dll as well -->
411+
<Warning Text="A copy of vcruntime140.dll is also required" Condition="!$(VCToolsRedistVersion.StartsWith(`14.`))" />
412+
<Copy SourceFiles="%(VCRuntimeDLL.FullPath)" DestinationFolder="$(OutDir)" />
413+
</Target>
414+
<Target Name="_CleanVCRuntime" AfterTargets="Clean">
415+
<Delete Files="@(VCRuntimeDLL->'$(OutDir)%(Filename)%(Extension)')" />
416+
</Target>
409417
</Project>

0 commit comments

Comments
 (0)