mirror of
https://github.com/python/cpython.git
synced 2025-07-09 20:35:26 +00:00
gh-99204: Calculate base_executable by alternate names in POSIX venvs (GH-99206)
Check to see if `base_executable` exists. If it does not, attempt to use known alternative names of the python binary to find an executable in the path specified by `home`. If no alternative is found, previous behavior is preserved. Signed-off-by: Vincent Fazio <vfazio@gmail.com> Signed-off-by: Vincent Fazio <vfazio@gmail.com>
This commit is contained in:
parent
f1680c3fbf
commit
c41b13d39c
3 changed files with 54 additions and 0 deletions
|
@ -382,6 +382,37 @@ class MockGetPathTests(unittest.TestCase):
|
|||
actual = getpath(ns, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_venv_changed_name_copy_posix(self):
|
||||
"Test a venv --copies layout on *nix that lacks a distributed 'python'"
|
||||
ns = MockPosixNamespace(
|
||||
argv0="python",
|
||||
PREFIX="/usr",
|
||||
ENV_PATH="/venv/bin:/usr/bin",
|
||||
)
|
||||
ns.add_known_xfile("/usr/bin/python9")
|
||||
ns.add_known_xfile("/venv/bin/python")
|
||||
ns.add_known_file("/usr/lib/python9.8/os.py")
|
||||
ns.add_known_dir("/usr/lib/python9.8/lib-dynload")
|
||||
ns.add_known_file("/venv/pyvenv.cfg", [
|
||||
r"home = /usr/bin"
|
||||
])
|
||||
expected = dict(
|
||||
executable="/venv/bin/python",
|
||||
prefix="/usr",
|
||||
exec_prefix="/usr",
|
||||
base_executable="/usr/bin/python9",
|
||||
base_prefix="/usr",
|
||||
base_exec_prefix="/usr",
|
||||
module_search_paths_set=1,
|
||||
module_search_paths=[
|
||||
"/usr/lib/python98.zip",
|
||||
"/usr/lib/python9.8",
|
||||
"/usr/lib/python9.8/lib-dynload",
|
||||
],
|
||||
)
|
||||
actual = getpath(ns, expected)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_symlink_normal_posix(self):
|
||||
"Test a 'standard' install layout via symlink on *nix"
|
||||
ns = MockPosixNamespace(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue