From 1e6bb41821372060dfb55eeb859b8f7763c64c2e Mon Sep 17 00:00:00 2001
From: neonene <53406459+neonene@users.noreply.github.com>
Date: Fri, 10 Dec 2021 02:32:18 +0900
Subject: [PATCH 01/11] VPATH definition exclusive for PGInstrument
---
PCbuild/pythoncore.vcxproj | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj
index 119650a1eec51b..0196bbd7e08bbd 100644
--- a/PCbuild/pythoncore.vcxproj
+++ b/PCbuild/pythoncore.vcxproj
@@ -115,11 +115,12 @@
PREFIX=NULL;
EXEC_PREFIX=NULL;
VERSION=NULL;
- VPATH="..\\..";
PYDEBUGEXT="$(PyDebugExt)";
PLATLIBDIR="DLLs";
%(PreprocessorDefinitions)
+ VPATH="..\\..";%(PreprocessorDefinitions)
+ VPATH="..\\..\\..";%(PreprocessorDefinitions)
From 24d03eb12b08e45ff354292adedb0bcb174dc2b5 Mon Sep 17 00:00:00 2001
From: neonene <53406459+neonene@users.noreply.github.com>
Date: Fri, 10 Dec 2021 02:39:48 +0900
Subject: [PATCH 02/11] Use VPATH for BUILD_LANDMARK
---
Modules/getpath.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Modules/getpath.py b/Modules/getpath.py
index 2eadfba1dfda24..b444b82c0b6141 100644
--- a/Modules/getpath.py
+++ b/Modules/getpath.py
@@ -187,7 +187,7 @@
elif os_name == 'nt':
BUILDDIR_TXT = 'pybuilddir.txt'
- BUILD_LANDMARK = r'..\..\Modules\Setup.local'
+ BUILD_LANDMARK = f'{VPATH}\\Modules\\Setup.local'
DEFAULT_PROGRAM_NAME = f'python'
STDLIB_SUBDIR = 'Lib'
STDLIB_LANDMARKS = [f'{STDLIB_SUBDIR}\\os.py', f'{STDLIB_SUBDIR}\\os.pyc']
From 0529d08d7a72a776543f68f3ea34368b0f838333 Mon Sep 17 00:00:00 2001
From: neonene <53406459+neonene@users.noreply.github.com>
Date: Fri, 10 Dec 2021 02:52:55 +0900
Subject: [PATCH 03/11] Use different VPATH in test_init_pybuilddir_win32
---
Lib/test/test_embed.py | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py
index 3620a7619601df..0ff7ea2037c7e3 100644
--- a/Lib/test/test_embed.py
+++ b/Lib/test/test_embed.py
@@ -1292,11 +1292,17 @@ def test_init_pybuilddir(self):
def test_init_pybuilddir_win32(self):
# Test path configuration with pybuilddir.txt configuration file
- with self.tmpdir_with_python(r'PCbuild\arch') as tmpdir:
+ if os.path.basename(os.path.dirname(sys.executable)) == 'instrumented':
+ subdir = r'PCbuild\arch\instrumented'
+ vpath = r'..\..\..'
+ else:
+ subdir = r'PCbuild\arch'
+ vpath = r'..\..'
+ with self.tmpdir_with_python(subdir) as tmpdir:
# The prefix is dirname(executable) + VPATH
- prefix = os.path.normpath(os.path.join(tmpdir, r'..\..'))
+ prefix = os.path.normpath(os.path.join(tmpdir, vpath))
# The stdlib dir is dirname(executable) + VPATH + 'Lib'
- stdlibdir = os.path.normpath(os.path.join(tmpdir, r'..\..\Lib'))
+ stdlibdir = os.path.normpath(os.path.join(tmpdir, vpath, 'Lib'))
filename = os.path.join(tmpdir, 'pybuilddir.txt')
with open(filename, "w", encoding="utf8") as fp:
From 737cedba901f80c83c7ff640eb87919423fbbffd Mon Sep 17 00:00:00 2001
From: neonene <53406459+neonene@users.noreply.github.com>
Date: Fri, 10 Dec 2021 18:20:07 +0900
Subject: [PATCH 04/11] VPATH definition for MSBuild
---
PCbuild/python.props | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/PCbuild/python.props b/PCbuild/python.props
index 7b85ad1c94f16e..ce860764e445fb 100644
--- a/PCbuild/python.props
+++ b/PCbuild/python.props
@@ -53,6 +53,10 @@
$(BuildPath)\
$(BuildPath)instrumented\
+
+ ..\\..
+ ..\\..\\..
+
$(EXTERNALS_DIR)
$([System.IO.Path]::GetFullPath(`$(PySourcePath)externals`))
From 78e1fdbbaf6f4e068ff174f9c5292be6edd66ff4 Mon Sep 17 00:00:00 2001
From: neonene <53406459+neonene@users.noreply.github.com>
Date: Fri, 10 Dec 2021 18:26:32 +0900
Subject: [PATCH 05/11] VPATH for sysmodule.c / getpath.c
---
PCbuild/pythoncore.vcxproj | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj
index ab56256a3d47a7..934f4746aaa9d3 100644
--- a/PCbuild/pythoncore.vcxproj
+++ b/PCbuild/pythoncore.vcxproj
@@ -119,8 +119,7 @@
PLATLIBDIR="DLLs";
%(PreprocessorDefinitions)
- VPATH="..\\..";%(PreprocessorDefinitions)
- VPATH="..\\..\\..";%(PreprocessorDefinitions)
+ VPATH="$(PyVPath)";%(PreprocessorDefinitions)
@@ -520,7 +519,9 @@
-
+
+ VPATH="$(PyVPath)";%(PreprocessorDefinitions)
+
From 678a40889f22d5c1f668627e9a83f2e8ae3a38b3 Mon Sep 17 00:00:00 2001
From: neonene <53406459+neonene@users.noreply.github.com>
Date: Fri, 10 Dec 2021 18:30:11 +0900
Subject: [PATCH 06/11] VPATH for sysmodule.c (freezed)
---
PCbuild/_freeze_module.vcxproj | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/PCbuild/_freeze_module.vcxproj b/PCbuild/_freeze_module.vcxproj
index 2c06a8956ae451..2beb425647407a 100644
--- a/PCbuild/_freeze_module.vcxproj
+++ b/PCbuild/_freeze_module.vcxproj
@@ -226,7 +226,9 @@
-
+
+ VPATH="$(PyVPath)";%(PreprocessorDefinitions)
+
From bf34c4f3a77022031c321ff73ae18fed83a60a91 Mon Sep 17 00:00:00 2001
From: neonene <53406459+neonene@users.noreply.github.com>
Date: Fri, 10 Dec 2021 18:33:10 +0900
Subject: [PATCH 07/11] Implement sys._vpath
---
Python/sysmodule.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index af4f926f0e4080..f912115560704c 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -2823,6 +2823,8 @@ _PySys_InitCore(PyThreadState *tstate, PyObject *sysdict)
goto type_init_failed;
}
}
+
+ SET_SYS_FROM_STRING("_vpath", VPATH);
#endif
/* float repr style: 0.03 (short) vs 0.029999999999999999 (legacy) */
From 7f8e0e39dcbf4f6a67a308561338635cbc8ed9b5 Mon Sep 17 00:00:00 2001
From: neonene <53406459+neonene@users.noreply.github.com>
Date: Fri, 10 Dec 2021 18:36:02 +0900
Subject: [PATCH 08/11] sysconfig.get_config_var('VPATH')
---
Lib/sysconfig.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py
index da918b7ba19041..ef335c69421f5e 100644
--- a/Lib/sysconfig.py
+++ b/Lib/sysconfig.py
@@ -616,6 +616,7 @@ def get_config_vars(*args):
if os.name == 'nt':
_init_non_posix(_CONFIG_VARS)
+ _CONFIG_VARS['VPATH'] = sys._vpath
if os.name == 'posix':
_init_posix(_CONFIG_VARS)
# For backward compatibility, see issue19555
From ee17a52dcc4d8483955ee3a72fcc1404f563ada2 Mon Sep 17 00:00:00 2001
From: neonene <53406459+neonene@users.noreply.github.com>
Date: Fri, 10 Dec 2021 18:41:02 +0900
Subject: [PATCH 09/11] Use VPATH in test_embed
---
Lib/test/test_embed.py | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py
index da37c580c1ac26..2c0593f318376d 100644
--- a/Lib/test/test_embed.py
+++ b/Lib/test/test_embed.py
@@ -1300,12 +1300,11 @@ def test_init_pybuilddir(self):
def test_init_pybuilddir_win32(self):
# Test path configuration with pybuilddir.txt configuration file
- if os.path.basename(os.path.dirname(sys.executable)) == 'instrumented':
- subdir = r'PCbuild\arch\instrumented'
- vpath = r'..\..\..'
- else:
+ vpath = sysconfig.get_config_var("VPATH")
subdir = r'PCbuild\arch'
- vpath = r'..\..'
+ if os.path.normpath(vpath).count(os.sep) == 2:
+ subdir = os.path.join(subdir, 'instrumented')
+
with self.tmpdir_with_python(subdir) as tmpdir:
# The prefix is dirname(executable) + VPATH
prefix = os.path.normpath(os.path.join(tmpdir, vpath))
From f3ac09c942fb7588a3eeec2d2a885d6f72472183 Mon Sep 17 00:00:00 2001
From: neonene <53406459+neonene@users.noreply.github.com>
Date: Fri, 10 Dec 2021 18:47:20 +0900
Subject: [PATCH 10/11] Fix indent in test_embed
---
Lib/test/test_embed.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py
index 2c0593f318376d..879952413374ec 100644
--- a/Lib/test/test_embed.py
+++ b/Lib/test/test_embed.py
@@ -1301,7 +1301,7 @@ def test_init_pybuilddir_win32(self):
# Test path configuration with pybuilddir.txt configuration file
vpath = sysconfig.get_config_var("VPATH")
- subdir = r'PCbuild\arch'
+ subdir = r'PCbuild\arch'
if os.path.normpath(vpath).count(os.sep) == 2:
subdir = os.path.join(subdir, 'instrumented')
From 2513c67190abab1a732666d193e387498fed7401 Mon Sep 17 00:00:00 2001
From: neonene <53406459+neonene@users.noreply.github.com>
Date: Fri, 10 Dec 2021 19:22:17 +0900
Subject: [PATCH 11/11] Fix a redundant definition
---
PCbuild/pythoncore.vcxproj | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj
index 934f4746aaa9d3..33abfaf53652f9 100644
--- a/PCbuild/pythoncore.vcxproj
+++ b/PCbuild/pythoncore.vcxproj
@@ -115,11 +115,11 @@
PREFIX=NULL;
EXEC_PREFIX=NULL;
VERSION=NULL;
+ VPATH="$(PyVPath)";
PYDEBUGEXT="$(PyDebugExt)";
PLATLIBDIR="DLLs";
%(PreprocessorDefinitions)
- VPATH="$(PyVPath)";%(PreprocessorDefinitions)