Skip to content

pyvenv: venvs cannot be moved because activate scripts hard-code paths #70020

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
moorecm mannequin opened this issue Dec 10, 2015 · 3 comments
Closed

pyvenv: venvs cannot be moved because activate scripts hard-code paths #70020

moorecm mannequin opened this issue Dec 10, 2015 · 3 comments
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@moorecm
Copy link
Mannequin

moorecm mannequin commented Dec 10, 2015

BPO 25833
Nosy @warsaw, @vsajip, @bitdancer

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2016-02-13.09:47:36.194>
created_at = <Date 2015-12-10.15:15:28.900>
labels = ['invalid', 'type-feature', 'library']
title = 'pyvenv: venvs cannot be moved because activate scripts hard-code paths'
updated_at = <Date 2016-02-13.09:47:36.193>
user = 'https://bugs.python.org/moorecm'

bugs.python.org fields:

activity = <Date 2016-02-13.09:47:36.193>
actor = 'vinay.sajip'
assignee = 'none'
closed = True
closed_date = <Date 2016-02-13.09:47:36.194>
closer = 'vinay.sajip'
components = ['Library (Lib)']
creation = <Date 2015-12-10.15:15:28.900>
creator = 'moorecm'
dependencies = []
files = []
hgrepos = []
issue_num = 25833
keywords = []
message_count = 3.0
messages = ['256176', '256177', '260228']
nosy_count = 5.0
nosy_names = ['barry', 'vinay.sajip', 'r.david.murray', 'moorecm', 'Andr\xc3\xa9 Caron']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue25833'
versions = ['Python 3.6']

@moorecm
Copy link
Mannequin Author

moorecm mannequin commented Dec 10, 2015

venv/bin/activate contains an absolute path to the virtual environment. Is it possible to make that relative from activate itself so that the entire venv can be moved elsewhere and still work?

I found this using Jenkins to get a Perforce workspace, then build a virtual environment, and clone that for downstream jobs. The cloned workspaces are extracted elsewhere and when they activate the environment they're actually pointing back to the upstream job's venv.

Feel free to route this request as appropriate. I'm a new tracker user. Thanks!

@moorecm moorecm mannequin added the stdlib Python modules in the Lib dir label Dec 10, 2015
@bitdancer
Copy link
Member

It's been that way since the virtualenv days, and I presume there's a reason for it. virtualenv does have a '--relocatable' option, but it is still marked as experimental. Finding out why that is and addressing the issues would be a prerequisite for adding this enhancement to venv.

@bitdancer bitdancer added the type-feature A feature request or enhancement label Dec 10, 2015
@vsajip
Copy link
Member

vsajip commented Feb 13, 2016

Indeed, and in fact *all* scripts written to a venv's bin directory hard-code the path to that venv's interpreter. This confers the benefit that such scripts never need the venv to be explicitly activated - you can e.g. point crontab entries to them directly.

You're better off making the Jenkins job build the environment in its workspace before using it - venvs are intended to be reproducible and, consequently, disposable.

@vsajip vsajip closed this as completed Feb 13, 2016
@vsajip vsajip added the invalid label Feb 13, 2016
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants