-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
PEP 796: Relative Virtual Environments [initial draft] #4476
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
base: main
Are you sure you want to change the base?
Conversation
Hello, before we go any further with this PR, has the idea been discussed on Discourse? And after that we'll need a sponsor before assigning the PEP number, do you have one yet? Let's unassign 796 for now. Please see: |
Thanks @hugovk and @StanFromIreland for the early review. I used a draft PR to see the CI results to further clean it up -- my apologies for wasting some of your time, but thank you regardless.
Yes: https://discuss.python.org/t/making-venvs-relocatable-friendly/96177 The criteria of "discussed enough with enough support" is vague, but what gave me enough confidence to begin a PEP and start a (draft) PR at this point was:
Thanks for clarifying that part! Yes, finding a sponsor is my next big step. |
Tip: you can enable GitHub Actions at https://github.com/rickeylev/peps/actions and run the CI on your fork.
Good luck! |
Thanks @ncoghlan for sponsoring and approving! Let's continue with PEP number 796. Next steps: a PEP editor to review, then merge, and then the PEP discussion can be opened for this proposal. |
Co-authored-by: Alyssa Coghlan <[email protected]>
This comment has been minimized.
This comment has been minimized.
@paveldikov thank you for the comment, please could you re-post it on Discourse? The peps repo / PR discussion is mainly for editorial discussion, rather than substantive comment on the proposal itself. A |
Co-authored-by: Hugo van Kemenade <[email protected]> Co-authored-by: Zanie Blue <[email protected]>
…to relative.venvs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the reviews! I'm out from under $dayJob and vacation backlogs a bit now and addressed comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some little notes
Belatedly removed the DO-NOT-MERGE label (that was added pending the Discourse discussion and sponsorship of the PEP) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PEP is currently missing a Security Implications section, which I think should be added given that arbitrary directory traversal is permitted -- at the very least explaining why this is fine.
Several editorial notes, I think the Motivation & Rationale sections should be strengthened to focus on the benefits from relative environments, there is currently (I believe) a lot of assumed context.
The PEP also discusses at some length a broader proposal for reloacatable venvs. Is it worth considering making that the proposal here? I don't know the specifics, so it might be that the changes needed for 'relocatable' are too large to tackle in one go.
A
peps/pep-0796.rst
Outdated
Motivation | ||
========== | ||
|
||
There are two main motivations for allowing relative paths in ``pyvenv.cfg``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sentence doesn't add much. It's also somewhat confused by the next para which says that the reason they are wanted is because they're prohibited.
I would first (briefly) explain to the reader what the home
field in pyvenv.cfg
is for, then go on to discuss the benefits of relative paths. Assume the reader is technically competent, but doesn't have all the context you do of the history here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two main motivations for allowing relative paths in ``pyvenv.cfg``. | |
The ``home`` field in ``pyvenv.cfg`` is used on interpreter startup to determine the actual Python | |
interpreter installation that is used to execute code in that virtual environment. Currently, | |
this path is required to be absolute for correct virtual environment operation - as the original PEP | |
adding virtual environments didn't cover any specific way of processing relative paths, their | |
behaviour is implementation dependent. CPython releases up to and including CPython 3.14 | |
resolve them relative to the current process working directory, making them too unreliable to | |
use in practice. |
@AA-Turner has a point that the subsection could benefit from restructuring in general, though:
- move the rationale paragraphs up here to the motivation section
- move some of the technical details motivation text down to the rationale section
- add the rationale for excluding the tool dependent environment portability features (those problems can be solved at the tool level, and need to be solved at the tool level because the right answers are dependent on the exact intended usage model of the relative virtual environments)
For PEP readers that aren't already familiar with the problem, the core points we want to get across are that there are use cases that rely on relative virtual environments (motivation), and while we can deal with most of the challenges involved in setting them up in ways we're happy with, the ways we have to deal with this problem are particularly horrible, and we'd like to ditch them in favour of properly defined interpreter level handling of relative paths in the home
key (rationale).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rewrote large portions of motivation/rationale. PTAL
Co-authored-by: Alyssa Coghlan <[email protected]> Co-authored-by: Adam Turner <[email protected]> Co-authored-by: Stan Ulbrych <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applied suggestions and addressed a few comments; didn't have time to address everything, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, all pending comments addressed (I think. The Github UI frequently tricks me 😂 )
PTAL
re: security section: added. At least, insofar as I understand your concern correctly.
re: motivation and rationale strengthening: Thanks! Yeah, honestly, a big issue I've had writing this that "Motivation" and "Rationale" are, to me at least, practically synonyms. I did my best to better separate "Why do this change at all?" (motivation) and "Implementation decision and why that decision" (rationale).
re: proposing relocatable venv in this pep: I added a section about why this pep limits its scope to just the core interpreter.
peps/pep-0796.rst
Outdated
Motivation | ||
========== | ||
|
||
There are two main motivations for allowing relative paths in ``pyvenv.cfg``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rewrote large portions of motivation/rationale. PTAL
peps/pep-0796.rst
Outdated
Making it simpler to copy a virtual environment from one host to another | ||
mitigates these categories of problems. Additionally, the development tools to | ||
create a virtual environment and install its dependencies aren't needed on the | ||
host that intends to run the program. | ||
|
||
When the virtual environment doesn't require modifications to be usable, it | ||
also allows more advanced deployment mechanisms, e.g. remote mounting and | ||
caching of artifacts. While this PEP on its own isn't sufficient to enable | ||
that, it allows tools like Bazel or venvstacks to more easily prepare | ||
constrained environments that allow for such use cases. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now more directly answered in paragraph 2 of the motivation. I didn't want the start of the motivation to distractingly delve early into details of "why a portable venv" matters, so those details are in a "why portable virtual environments matter" subsection of motivation.
Basic requirements (all PEP Types)
pep-NNNN.rst
), PR title (PEP 123: <Title of PEP>
) andPEP
headerAuthor
orSponsor
, and formally confirmed their approvalAuthor
,Status
(Draft
),Type
andCreated
headers filled out correctlyPEP-Delegate
,Topic
,Requires
andReplaces
headers completed if appropriate.github/CODEOWNERS
for the PEPStandards Track requirements
Python-Version
set to valid (pre-beta) future Python version, if relevantDiscussions-To
andPost-History
Work towards python/cpython#136051
📚 Documentation preview 📚: https://pep-previews--4476.org.readthedocs.build/