[Python-checkins] bpo-47103: Copy pgort140.dll into output directory when building PGInstrument on Windows (GH-32083)
zooba
webhook-mailer at python.org
Thu Apr 7 20:03:07 EDT 2022
https://github.com/python/cpython/commit/80c115385c01f456cdc6550543cf2112ae7a8161
commit: 80c115385c01f456cdc6550543cf2112ae7a8161
branch: 3.9
author: Steve Dower <steve.dower at python.org>
committer: zooba <steve.dower at microsoft.com>
date: 2022-04-08T01:02:58+01:00
summary:
bpo-47103: Copy pgort140.dll into output directory when building PGInstrument on Windows (GH-32083)
files:
A Misc/NEWS.d/next/Build/2022-03-23-20-01-16.bpo-47103.b4-00F.rst
M Lib/test/test_embed.py
M PCbuild/python.vcxproj
diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py
index 11c8f012896d3..8e5cfa4824b15 100644
--- a/Lib/test/test_embed.py
+++ b/Lib/test/test_embed.py
@@ -1145,20 +1145,11 @@ def tmpdir_with_python(self):
if MS_WINDOWS:
# Copy pythonXY.dll (or pythonXY_d.dll)
- ver = sys.version_info
- dll = f'python{ver.major}{ver.minor}'
- dll3 = f'python{ver.major}'
- if debug_build(sys.executable):
- dll += '_d'
- dll3 += '_d'
- dll += '.dll'
- dll3 += '.dll'
- dll = os.path.join(os.path.dirname(self.test_exe), dll)
- dll3 = os.path.join(os.path.dirname(self.test_exe), dll3)
- dll_copy = os.path.join(tmpdir, os.path.basename(dll))
- dll3_copy = os.path.join(tmpdir, os.path.basename(dll3))
- shutil.copyfile(dll, dll_copy)
- shutil.copyfile(dll3, dll3_copy)
+ import fnmatch
+ exedir = os.path.dirname(self.test_exe)
+ for f in os.listdir(exedir):
+ if fnmatch.fnmatch(f, '*.dll'):
+ shutil.copyfile(os.path.join(exedir, f), os.path.join(tmpdir, f))
# Copy Python program
exec_copy = os.path.join(tmpdir, os.path.basename(self.test_exe))
diff --git a/Misc/NEWS.d/next/Build/2022-03-23-20-01-16.bpo-47103.b4-00F.rst b/Misc/NEWS.d/next/Build/2022-03-23-20-01-16.bpo-47103.b4-00F.rst
new file mode 100644
index 0000000000000..c1e01adce0d26
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2022-03-23-20-01-16.bpo-47103.b4-00F.rst
@@ -0,0 +1,2 @@
+Windows ``PGInstrument`` builds now copy a required DLL into the output
+directory, making it easier to run the profile stage of a PGO build.
diff --git a/PCbuild/python.vcxproj b/PCbuild/python.vcxproj
index 2094420a8df39..42b27084e04d7 100644
--- a/PCbuild/python.vcxproj
+++ b/PCbuild/python.vcxproj
@@ -126,9 +126,6 @@ set PYTHONPATH=$(PySourcePath)Lib
</Target>
<Target Name="GeneratePythonBat" AfterTargets="AfterBuild">
<PropertyGroup>
- <_PGOPath Condition="$(Configuration) == 'PGInstrument' and $(Platform) == 'Win32'">@set PATH=%PATH%%3B$(VCInstallDir)bin</_PGOPath>
- <_PGOPath Condition="$(Configuration) == 'PGInstrument' and $(Platform) == 'x64'">@set PATH=%PATH%%3B$(VCInstallDir)bin\amd64</_PGOPath>
- <_PGOPath Condition="$(Configuration) == 'PGInstrument' and $(VC_PGO_RunTime_Dir) != ''">@set PATH=%PATH%%3B$(VC_PGO_RunTime_Dir)</_PGOPath>
<_Content>@rem This script invokes the most recently built Python with all arguments
@rem passed through to the interpreter. This file is generated by the
@rem build process and any changes *will* be thrown away by the next
@@ -138,7 +135,6 @@ set PYTHONPATH=$(PySourcePath)Lib
@echo Running $(Configuration)^|$(Platform) interpreter...
@setlocal
@set PYTHONHOME=$(PySourcePath)
-$(_PGOPath)
@"$(OutDir)python$(PyDebugExt).exe" %*
</_Content>
<_ExistingContent Condition="Exists('$(PySourcePath)python.bat')">$([System.IO.File]::ReadAllText('$(PySourcePath)python.bat'))</_ExistingContent>
@@ -164,4 +160,15 @@ $(_PGOPath)
Overwrite="true"
Lines="@(_LicenseFiles->'%(Content)')" />
</Target>
+ <Target Name="CopyPGORT" AfterTargets="Link" Condition="$(Configuration) == 'PGInstrument'">
+ <ItemGroup>
+ <_PGORT Include="$(VCToolsInstallDir)bin\Hostx86\x86\pgort140.dll" Condition="$(Platform) == 'Win32'" />
+ <_PGORT Include="$(VCToolsInstallDir)bin\Hostx64\x64\pgort140.dll" Condition="$(Platform) == 'x64'" />
+ <_PGORT Include="$(VCToolsInstallDir)bin\arm64\pgort140.dll" Condition="$(Platform) == 'ARM64'" />
+ </ItemGroup>
+ <Warning Text="Unable to locate pgort140.dll for $(Platform)." Condition="@(_PGORT) == '' or !Exists(@(_PGORT))" />
+ <Copy SourceFiles="@(_PGORT)" DestinationFolder="$(OutDir)">
+ <Output TaskParameter="CopiedFiles" ItemName="FileWrites" />
+ </Copy>
+ </Target>
</Project>
More information about the Python-checkins
mailing list