classification
Title: venv should create relative symlinks where possible
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.5, Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: vinay.sajip Nosy List: barry, dstufft, python-dev, vinay.sajip
Priority: normal Keywords: patch

Created on 2015-02-06 00:03 by barry, last changed 2015-02-14 17:39 by berker.peksag. This issue is now closed.

Files
File name Uploaded Description Edit
venv.patch barry, 2015-02-06 00:03 review
Messages (3)
msg235457 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2015-02-06 00:03
There is a subtle behavior difference between virtualenv and pyvenv.  When you create a venv with virtualenv, the symbolic links files <venv>/bin are relative, while they are absolute with pyvenv.  This means that virtual environments created with virtualenv can be relocated (modulo the #! lines of the script, but let's not worry about that for now), but virtual environments created with pyvenv cannot be relocated.

With pyvenv, you also have <venv>/lib64 pointing to an absolute path.

AFAICT, there's no good reason why the symlink targets must be absolute paths.  Relative paths work just fine for virtualenv and they should work fine for pyvenv.

This patch changes the lib64 and <venv>/bin/* symlinks to be relative.  There should be no change when symlinks are disabled or are unavailable.

One remaining question is whether <venv>/bin/python itself should be relative.  In virtualenv, even with something like `-p /usr/bin/python3.4` you still get a relative link.  <venv>/bin/python points outside of the venv, so the question is whether the $PATH-dependent behavior of virtualenv is worthwhile or not.  My patch does not change this symlink.
msg235473 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2015-02-06 09:00
LGTM.
msg235489 - (view) Author: Roundup Robot (python-dev) Date: 2015-02-06 17:01
New changeset 6b8d95c12eaf by Barry Warsaw in branch '3.4':
Issue #23399: pyvenv creates relative symlinks where possible.
https://hg.python.org/cpython/rev/6b8d95c12eaf

New changeset 9e6f79495e0b by Barry Warsaw in branch 'default':
Issue #23399: pyvenv creates relative symlinks where possible.
https://hg.python.org/cpython/rev/9e6f79495e0b

New changeset 7a82b1539401 by Barry Warsaw in branch '3.4':
Issue #23399: pyvenv creates relative symlinks where possible.
https://hg.python.org/cpython/rev/7a82b1539401
History
Date User Action Args
2015-02-14 17:39:00berker.peksagsetstage: patch review -> resolved
2015-02-06 17:04:11barrysetstatus: open -> closed
resolution: fixed
2015-02-06 17:01:48python-devsetnosy: + python-dev
messages: + msg235489
2015-02-06 09:00:34vinay.sajipsetmessages: + msg235473
2015-02-06 00:03:01barrycreate