summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormattip <matti.picus@gmail.com>2024-01-10 16:11:03 +0200
committermattip <matti.picus@gmail.com>2024-01-10 16:11:03 +0200
commit471ad498f3ee0fb78ea45a34705eac7c5c7e3099 (patch)
tree7da569cb6dab2cae512679dcef5d3667cc61c029
parentMerge pull request #4846 from mattip/issue-4348 (diff)
downloadpypy-471ad498f3ee0fb78ea45a34705eac7c5c7e3099.tar.gz
pypy-471ad498f3ee0fb78ea45a34705eac7c5c7e3099.tar.bz2
pypy-471ad498f3ee0fb78ea45a34705eac7c5c7e3099.zip
subtle fix for 'pypy -m venv --copies <target>' where the source is a symlinked venv
-rw-r--r--lib-python/3/venv/__init__.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib-python/3/venv/__init__.py b/lib-python/3/venv/__init__.py
index c526a5d3b4..afcf58631b 100644
--- a/lib-python/3/venv/__init__.py
+++ b/lib-python/3/venv/__init__.py
@@ -186,9 +186,6 @@ class EnvBuilder:
Try symlinking a file, and if that fails, fall back to copying.
"""
force_copy = not self.symlinks
- if os.path.islink(src):
- os.symlink(src, dst)
- return
if not force_copy:
try:
if not os.path.islink(dst): # can't link to itself!
@@ -203,6 +200,12 @@ class EnvBuilder:
if force_copy:
if os.path.isdir(src):
shutil.copytree(src, dst)
+ elif os.path.islink(src):
+ # On PyPy, creating a copy of a symlinked-venv must still
+ # point back to the original file since the exe needs
+ # libpypy* and perhaps other 'portable' shared objects
+ final = os.path.realpath(src)
+ os.symlink(final, dst)
else:
shutil.copyfile(src, dst)
else: