[Python-checkins] gh-103224: Use the realpath of the Python executable in `test_venv` (GH-103243)

vsajip webhook-mailer at python.org
Thu Jun 1 05:40:06 EDT 2023


https://github.com/python/cpython/commit/85b0b0cd947c5218260fb2bc2014c8c8de172d33
commit: 85b0b0cd947c5218260fb2bc2014c8c8de172d33
branch: main
author: Artem Mukhin <artem.m.mukhin at gmail.com>
committer: vsajip <vinay_sajip at yahoo.co.uk>
date: 2023-06-01T10:39:59+01:00
summary:

gh-103224: Use the realpath of the Python executable in `test_venv` (GH-103243)

Co-authored-by: Oleg Iarygin <oleg at arhadthedev.net>

files:
M Lib/test/test_venv.py

diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py
index 5205604c2c71..3d19b2b2e905 100644
--- a/Lib/test/test_venv.py
+++ b/Lib/test/test_venv.py
@@ -208,7 +208,8 @@ def test_prompt(self):
     def test_upgrade_dependencies(self):
         builder = venv.EnvBuilder()
         bin_path = 'Scripts' if sys.platform == 'win32' else 'bin'
-        python_exe = os.path.split(sys.executable)[1]
+        python_exe_realpath = os.path.realpath(sys._base_executable)
+        python_exe = os.path.split(python_exe_realpath)[1]
         with tempfile.TemporaryDirectory() as fake_env_dir:
             expect_exe = os.path.normcase(
                 os.path.join(fake_env_dir, bin_path, python_exe)
@@ -551,7 +552,8 @@ def test_zippath_from_non_installed_posix(self):
         self.addCleanup(rmtree, non_installed_dir)
         bindir = os.path.join(non_installed_dir, self.bindir)
         os.mkdir(bindir)
-        shutil.copy2(sys.executable, bindir)
+        python_exe_realpath = os.path.realpath(sys._base_executable)
+        shutil.copy2(python_exe_realpath, bindir)
         libdir = os.path.join(non_installed_dir, platlibdir, self.lib[1])
         os.makedirs(libdir)
         landmark = os.path.join(libdir, "os.py")
@@ -595,7 +597,7 @@ def test_zippath_from_non_installed_posix(self):
         # libpython.so
         ld_library_path = sysconfig.get_config_var("LIBDIR")
         if not ld_library_path or sysconfig.is_python_build():
-            ld_library_path = os.path.abspath(os.path.dirname(sys.executable))
+            ld_library_path = os.path.abspath(os.path.dirname(python_exe_realpath))
         if sys.platform == 'darwin':
             ld_library_path_env = "DYLD_LIBRARY_PATH"
         else:



More information about the Python-checkins mailing list