From a35ca4e6dfb53cfc4671e9b56f2440b9eea0082b Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Wed, 23 Mar 2022 20:01:43 +0000 Subject: [PATCH 1/3] bpo-47103: Copy pgort140.dll into output directory when building PGInstrument on Windows --- .../Build/2022-03-23-20-01-16.bpo-47103.b4-00F.rst | 2 ++ PCbuild/python.vcxproj | 12 ++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 Misc/NEWS.d/next/Build/2022-03-23-20-01-16.bpo-47103.b4-00F.rst 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 000000000000000..c1e01adce0d2690 --- /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 77bccde69e3ba3b..2915065222e3016 100644 --- a/PCbuild/python.vcxproj +++ b/PCbuild/python.vcxproj @@ -134,6 +134,7 @@ set PYTHONPATH=$(PySourcePath)Lib <_PGOPath Condition="$(Configuration) == 'PGInstrument' and $(Platform) == 'Win32'">@set PATH=%PATH%%3B$(VCInstallDir)bin <_PGOPath Condition="$(Configuration) == 'PGInstrument' and $(Platform) == 'x64'">@set PATH=%PATH%%3B$(VCInstallDir)bin\amd64 + <_PGOPath Condition="$(Configuration) == 'PGInstrument' and $(Platform) == 'ARM64'">@set PATH=%PATH%%3B$(VCInstallDir)bin\arm64 <_PGOPath Condition="$(Configuration) == 'PGInstrument' and $(VC_PGO_RunTime_Dir) != ''">@set PATH=%PATH%%3B$(VC_PGO_RunTime_Dir) <_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 @@ -151,4 +152,15 @@ $(_PGOPath) + + + <_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'" /> + + + + + + From ea29eb763e544417dfa0c07cf474f97b1a6207d3 Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Wed, 23 Mar 2022 20:02:53 +0000 Subject: [PATCH 2/3] Remove PATH modifications from python.bat --- PCbuild/python.vcxproj | 5 ----- 1 file changed, 5 deletions(-) diff --git a/PCbuild/python.vcxproj b/PCbuild/python.vcxproj index 2915065222e3016..73520900e0739f7 100644 --- a/PCbuild/python.vcxproj +++ b/PCbuild/python.vcxproj @@ -132,10 +132,6 @@ set PYTHONPATH=$(PySourcePath)Lib - <_PGOPath Condition="$(Configuration) == 'PGInstrument' and $(Platform) == 'Win32'">@set PATH=%PATH%%3B$(VCInstallDir)bin - <_PGOPath Condition="$(Configuration) == 'PGInstrument' and $(Platform) == 'x64'">@set PATH=%PATH%%3B$(VCInstallDir)bin\amd64 - <_PGOPath Condition="$(Configuration) == 'PGInstrument' and $(Platform) == 'ARM64'">@set PATH=%PATH%%3B$(VCInstallDir)bin\arm64 - <_PGOPath Condition="$(Configuration) == 'PGInstrument' and $(VC_PGO_RunTime_Dir) != ''">@set PATH=%PATH%%3B$(VC_PGO_RunTime_Dir) <_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 @@ -145,7 +141,6 @@ set PYTHONPATH=$(PySourcePath)Lib @echo Running $(Configuration)^|$(Platform) interpreter... @setlocal @set PYTHONHOME=$(PySourcePath) -$(_PGOPath) @"$(OutDir)python$(PyDebugExt).exe" %* <_ExistingContent Condition="Exists('$(PySourcePath)python.bat')">$([System.IO.File]::ReadAllText('$(PySourcePath)python.bat')) From b5817963d477f75ddd2d09ceca8feb09ddb2d63d Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Tue, 5 Apr 2022 16:27:35 +0100 Subject: [PATCH 3/3] Correct test_embed handling of DLLs --- Lib/test/test_embed.py | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py index 80b9674c1c2582f..cbed08b73a9eaad 100644 --- a/Lib/test/test_embed.py +++ b/Lib/test/test_embed.py @@ -1201,20 +1201,11 @@ def tmpdir_with_python(self, subdir=None): 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))