-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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! |
Brief update: I have a sponsor: @ncoghlan has offered to sponsor this PEP. I've updated the PEP text accordingly. So, IIUC, next steps are:
I'm not entirely sure on process, so I'll just leave this PR in draft state until those are done / imminent. |
Confirming my sponsorship (the parts of the proposal I felt were at best premature, and potentially entirely infeasible, have been removed). Completing a pre-publication review now. |
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.
Generally looks good to me. Thanks for writing this up!
Assorted more detailed comments inline.
Co-authored-by: Alyssa Coghlan <[email protected]>
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]>
|
||
Second, such relative paths are a building block to enable portable virtual | ||
environments, i.e. copying a virtual environment as-is between hosts of | ||
compatible platforms. Portable venvs are appealing because virtual environments |
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.
I wouldn't abbreviate here if you aren't elsewhere
compatible platforms. Portable venvs are appealing because virtual environments | |
compatible platforms. Portable virtual environments are appealing because virtual environments |
benefits: | ||
|
||
* The closer the development environment is to the non-development environment, | ||
the more reliable software can be achieved, and the easier it is to reproduce |
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.
I think you may want to rephrase "the more reliable software can be achieved", I find the meaning a bit confusing and it's used both here and in the next bullet?
still retain predictable and reliable behavior. Thus, the absolute path | ||
requirement should be relaxed and relative path behavior allowed and defined. | ||
|
||
Second, such relative paths are a building block to enable portable virtual |
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.
It'd be nice to hear more about why and how a relative path makes the virtual environment more portable. A Python installation will still need to exist in a specific location on the new host, right? Is the pitch for a relative path that you'd copy a virtual environment and the Python installation together?
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.
Yep, that's the use case, although even the "copying" may be virtual - while an app embedding a single Python runtime and basing multiple virtual environments on it getting installed to different locations is one possibility, other potential scenarios would be a mounted parent folder in a container, or a mounted network drive on a host.
The key is that the position of the venv and its base runtime relative to each other is consistent, but the path prefix leading to their common parent folder may vary across systems.
.. highlight:: rst | ||
|
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.
Let's remove this, it's the syntax highlighter used for code blocks (default Python) and there aren't any code blocks here.
.. highlight:: rst |
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 |
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.
that, it allows tools like ``bazel`` or ``venvstacks`` to more easily prepare | |
that, it allows tools like Bazel or venvstacks to more easily prepare |
(``bazel``, omitting the ``home`` key entirely to trigger an implementation | ||
dependent fallback to resolving via a symlinked interpreter binary on | ||
non-Windows systems) or by requiring a post-installation script to be executed | ||
after the environment is placed in its target location (``venvstacks``). |
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.
(``bazel``, omitting the ``home`` key entirely to trigger an implementation | |
dependent fallback to resolving via a symlinked interpreter binary on | |
non-Windows systems) or by requiring a post-installation script to be executed | |
after the environment is placed in its target location (``venvstacks``). | |
(Bazel, omitting the ``home`` key entirely to trigger an implementation | |
dependent fallback to resolving via a symlinked interpreter binary on | |
non-Windows systems) or by requiring a post-installation script to be executed | |
after the environment is placed in its target location (venvstacks). |
* ``subdir/whatever/bin`` (a directory within the virtual environment). | ||
* ``./subdir/whatever/bin`` (same as above) | ||
* ``../../../../../elsewhere/runtime/bin`` (a directory outside the virtual | ||
environment). |
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.
* ``subdir/whatever/bin`` (a directory within the virtual environment). | |
* ``./subdir/whatever/bin`` (same as above) | |
* ``../../../../../elsewhere/runtime/bin`` (a directory outside the virtual | |
environment). | |
* ``subdir/whatever/bin`` (a directory within the virtual environment) | |
* ``./subdir/whatever/bin`` (same as above) | |
* ``../../../../../elsewhere/runtime/bin`` (a directory outside the virtual | |
environment) |
Tools that work around the absolute ``home`` key limitation the way ``bazel`` | ||
and ``venvstacks`` currently do (omitting the ``home`` key, or editing it after |
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.
Tools that work around the absolute ``home`` key limitation the way ``bazel`` | |
and ``venvstacks`` currently do (omitting the ``home`` key, or editing it after | |
Tools that work around the absolute ``home`` key limitation the way Bazel | |
and venvstacks currently do (omitting the ``home`` key, or editing it after |
paths. | ||
|
||
A proof-of-concept of this is implemented in | ||
`rickeylev/feat.relative.pyvenv.home <https://github.com/python/cpython/compare/main...rickeylev:cpython:feat.relative.pyvenv.home>`__ |
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.
`rickeylev/feat.relative.pyvenv.home <https://github.com/python/cpython/compare/main...rickeylev:cpython:feat.relative.pyvenv.home>`__ | |
`rickeylev/feat.relative.pyvenv.home <https://github.com/python/cpython/compare/main...rickeylev:cpython:feat.relative.pyvenv.home>`__. |
host-relocatable virtual environments. | ||
* `rules_py <https://github.com/aspect-build/rules_py>`__: implements | ||
host-relocatable virtual environments. | ||
* `python-build-standalone <https://github.com/astral-sh/python-build-standalone>`__: |
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.
Put something after the colon? Or delete the colon?
* `python-build-standalone <https://github.com/astral-sh/python-build-standalone>`__: | |
* `python-build-standalone <https://github.com/astral-sh/python-build-standalone>`__ |
A relocatable Python runtime. | ||
* `PoC for relative home in Python startup <https://github.com/python/cpython/compare/main...rickeylev:cpython:feat.relative.pyvenv.home>`__ | ||
* `Python Ideas "Making venvs relocatable friendly" discussion <https://discuss.python.org/t/making-venvs-relocatable-friendly/96177>`__ | ||
* `GH-136051: relative pyvenv.cfg home <https://github.com/python/cpython/issues/136051>`__ |
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.
Convention is lowercase for issue, uppercase for PR:
* `GH-136051: relative pyvenv.cfg home <https://github.com/python/cpython/issues/136051>`__ | |
* `gh-136051: relative pyvenv.cfg home <https://github.com/python/cpython/issues/136051>`__ |
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/