[Python-checkins] cpython (merge 3.4 -> default): Issue #23399: pyvenv creates relative symlinks where possible.
barry.warsaw
python-checkins at python.org
Fri Feb 6 18:01:47 CET 2015
https://hg.python.org/cpython/rev/9e6f79495e0b
changeset: 94543:9e6f79495e0b
parent: 94539:367f5e98ffbb
parent: 94542:6b8d95c12eaf
user: Barry Warsaw <barry at python.org>
date: Fri Feb 06 11:58:06 2015 -0500
summary:
Issue #23399: pyvenv creates relative symlinks where possible.
files:
Lib/venv/__init__.py | 14 ++++++++------
Misc/NEWS | 2 ++
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/Lib/venv/__init__.py b/Lib/venv/__init__.py
--- a/Lib/venv/__init__.py
+++ b/Lib/venv/__init__.py
@@ -141,10 +141,9 @@
# Issue 21197: create lib64 as a symlink to lib on 64-bit non-OS X POSIX
if ((sys.maxsize > 2**32) and (os.name == 'posix') and
(sys.platform != 'darwin')):
- p = os.path.join(env_dir, 'lib')
link_path = os.path.join(env_dir, 'lib64')
if not os.path.exists(link_path): # Issue #21643
- os.symlink(p, link_path)
+ os.symlink('lib', link_path)
context.bin_path = binpath = os.path.join(env_dir, binname)
context.bin_name = binname
context.env_exe = os.path.join(binpath, exename)
@@ -178,7 +177,7 @@
result = f.startswith('python') and f.endswith('.exe')
return result
- def symlink_or_copy(self, src, dst):
+ def symlink_or_copy(self, src, dst, relative_symlinks_ok=False):
"""
Try symlinking a file, and if that fails, fall back to copying.
"""
@@ -186,7 +185,11 @@
if not force_copy:
try:
if not os.path.islink(dst): # can't link to itself!
- os.symlink(src, dst)
+ if relative_symlinks_ok:
+ assert os.path.dirname(src) == os.path.dirname(dst)
+ os.symlink(os.path.basename(src), dst)
+ else:
+ os.symlink(src, dst)
except Exception: # may need to use a more specific exception
logger.warning('Unable to symlink %r to %r', src, dst)
force_copy = True
@@ -201,7 +204,6 @@
being processed.
"""
binpath = context.bin_path
- exename = context.python_exe
path = context.env_exe
copier = self.symlink_or_copy
copier(context.executable, path)
@@ -214,7 +216,7 @@
if not os.path.exists(path):
# Issue 18807: make copies if
# symlinks are not wanted
- copier(context.env_exe, path)
+ copier(context.env_exe, path, relative_symlinks_ok=True)
if not os.path.islink(path):
os.chmod(path, 0o755)
else:
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -235,6 +235,8 @@
Library
-------
+- Issue #23399: pyvenv creates relative symlinks where possible.
+
- Issue #20289: cgi.FieldStorage() now supports the context management
protocol.
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list