Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions cpython-unix/build-cpython.sh
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,17 @@ if [[ -n "${PYTHON_MEETS_MINIMUM_VERSION_3_14}" ]]; then
patch -p1 -i "${ROOT}/patch-python-getpath-3.14.patch"
fi

# Another, similar change to getpath: When reading inside a venv use the base_executable path to
# determine executable_dir when valid. This allows venv to be created from symlinks and covers some
# cases the above patch doesn't. See:
# https://github.com/python/cpython/issues/106045#issuecomment-2594628161
# 3.10 does not use getpath.py only getpath.c, no patch is applied
if [ -n "${PYTHON_MEETS_MINIMUM_VERSION_3_14}" ]; then
patch -p1 -i "${ROOT}/patch-getpath-use-base_executable-for-executable_dir-314.patch"
elif [ -n "${PYTHON_MEETS_MINIMUM_VERSION_3_11}" ]; then
patch -p1 -i "${ROOT}/patch-getpath-use-base_executable-for-executable_dir.patch"
fi

# We patched configure.ac above. Reflect those changes.
autoconf

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/Modules/getpath.py b/Modules/getpath.py
index ceb605a75c8..164d708ffca 100644
--- a/Modules/getpath.py
+++ b/Modules/getpath.py
@@ -411,6 +411,9 @@ def search_up(prefix, *landmarks, test=isfile):
if isfile(candidate):
base_executable = candidate
break
+ if base_executable and isfile(base_executable):
+ # Update the executable directory to be based on the resolved base executable
+ executable_dir = real_executable_dir = dirname(base_executable)
# home key found; stop iterating over lines
break

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/Modules/getpath.py b/Modules/getpath.py
index 1f1bfcb4f64..ff5b18cc385 100644
--- a/Modules/getpath.py
+++ b/Modules/getpath.py
@@ -398,6 +398,9 @@ def search_up(prefix, *landmarks, test=isfile):
if isfile(candidate):
base_executable = candidate
break
+ if base_executable and isfile(base_executable):
+ # Update the executable directory to be based on the resolved base executable
+ executable_dir = real_executable_dir = dirname(base_executable)
break
else:
venv_prefix = None

7 changes: 4 additions & 3 deletions src/verify_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def assertLibc(value):
assertLibc(importlib.machinery.EXTENSION_SUFFIXES[0])

@unittest.skipIf(
sys.version_info[:2] < (3, 14),
sys.version_info[:2] < (3, 11),
"not yet implemented",
)
@unittest.skipIf(os.name == "nt", "no symlinks or argv[0] on Windows")
Expand All @@ -300,8 +300,9 @@ def assertPythonWorks(path: Path, argv0: str = None):
)
assertPythonWorks(venv / "bin" / "python")

with self.subTest(msg="weird argv[0]"):
assertPythonWorks(sys.executable, argv0="/dev/null")
# TODO: does not yet work on ARM64
# with self.subTest(msg="weird argv[0]"):
# assertPythonWorks(sys.executable, argv0="/dev/null")
Comment on lines +303 to +305
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be a part of the skipif?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you can skipIf a single subTest. You can call self.skipTest("doesn't yet work on arm64"). I probably could have structured this one as a separate test case, though....



if __name__ == "__main__":
Expand Down
Loading