aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Tools/patchcheck/patchcheck.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2023-09-27 12:32:12 +0200
committerGitHub <noreply@github.com>2023-09-27 12:32:12 +0200
commitb89ed9df39851348fbb1552294644f99f6b17d2c (patch)
tree71b0a04c09ee2ed373dff487f7ce64da965c426f /Tools/patchcheck/patchcheck.py
parent91fb8daa2494df4dd6a841ca8c742a03175c7ecd (diff)
downloadcpython-b89ed9df39851348fbb1552294644f99f6b17d2c.tar.gz
cpython-b89ed9df39851348fbb1552294644f99f6b17d2c.zip
gh-109615: Fix support test_copy_python_src_ignore() (#109958)
Fix the test when run on an installed Python: use "abs_srcdir" of sysconfig, and skip the test if the Python source code cannot be found. * Tools/patchcheck/patchcheck.py, Tools/freeze/test/freeze.py and Lib/test/libregrtest/utils.py now first try to get "abs_srcdir" from sysconfig, before getting "srcdir" from sysconfig. * test.pythoninfo logs sysconfig "abs_srcdir".
Diffstat (limited to 'Tools/patchcheck/patchcheck.py')
-rwxr-xr-xTools/patchcheck/patchcheck.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/Tools/patchcheck/patchcheck.py b/Tools/patchcheck/patchcheck.py
index fa3a43af6e6..e3959ce428c 100755
--- a/Tools/patchcheck/patchcheck.py
+++ b/Tools/patchcheck/patchcheck.py
@@ -11,6 +11,13 @@ import reindent
import untabify
+def get_python_source_dir():
+ src_dir = sysconfig.get_config_var('abs_srcdir')
+ if not src_dir:
+ src_dir = sysconfig.get_config_var('srcdir')
+ return os.path.abspath(src_dir)
+
+
# Excluded directories which are copies of external libraries:
# don't check their coding style
EXCLUDE_DIRS = [
@@ -18,7 +25,7 @@ EXCLUDE_DIRS = [
os.path.join('Modules', 'expat'),
os.path.join('Modules', 'zlib'),
]
-SRCDIR = sysconfig.get_config_var('srcdir')
+SRCDIR = get_python_source_dir()
def n_files_str(count):