peps icon indicating copy to clipboard operation
peps copied to clipboard

PEP 796: Relative Virtual Environments

Open rickeylev opened this issue 6 months ago • 10 comments

Basic requirements (all PEP Types)

  • [x] Read and followed PEP 1 & PEP 12
  • [x] File created from the latest PEP template
  • [x] PEP has next available number, & set in filename (pep-NNNN.rst), PR title (PEP 123: <Title of PEP>) and PEP header
  • [x] Title clearly, accurately and concisely describes the content in 79 characters or less
  • [x] Core dev/PEP editor listed as Author or Sponsor, and formally confirmed their approval
  • [x] Author, Status (Draft), Type and Created headers filled out correctly
  • [x] PEP-Delegate, Topic, Requires and Replaces headers completed if appropriate
  • [x] Required sections included
    • [x] Abstract (first section)
    • [x] Copyright (last section; exact wording from template required)
  • [x] Code is well-formatted (PEP 7/PEP 8) and is in code blocks, with the right lexer names if non-Python
  • [x] PEP builds with no warnings, pre-commit checks pass and content displays as intended in the rendered HTML
  • [x] Authors/sponsor added to .github/CODEOWNERS for the PEP

Standards Track requirements

  • [x] PEP topic discussed in a suitable venue with general agreement that a PEP is appropriate
  • [x] Suggested sections included (unless not applicable)
    • [x] Motivation
    • [x] Rationale
    • [x] Specification
    • [x] Backwards Compatibility
    • [x] Security Implications
    • [x] How to Teach This
    • [x] Reference Implementation
    • [x] Rejected Ideas
    • [x] Open Issues
  • [x] Python-Version set to valid (pre-beta) future Python version, if relevant
  • [x] Any project stated in the PEP as supporting/endorsing/benefiting from the PEP formally confirmed such
  • [ ] Right before or after initial merging, PEP discussion thread created and linked to in Discussions-To and Post-History

Work towards https://github.com/python/cpython/issues/136051


📚 Documentation preview 📚: https://pep-previews--4476.org.readthedocs.build/

rickeylev avatar Jun 30 '25 17:06 rickeylev

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:

  • https://peps.python.org/pep-0001/#start-with-an-idea-for-python
  • https://peps.python.org/pep-0001/#submitting-a-pep

hugovk avatar Jun 30 '25 19:06 hugovk

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.

discussed on Discourse?

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:

  • The thread didn't go totally off the rails (i.e. voracious disapproval)
  • Positive statements from @ncoghlan in https://discuss.python.org/t/making-venvs-relocatable-friendly/96177/21 and https://github.com/python/cpython/pull/135831#issuecomment-3003590650

Sponsor needed to assign number

Thanks for clarifying that part! Yes, finding a sponsor is my next big step.

rickeylev avatar Jun 30 '25 20:06 rickeylev

I used a draft PR to see the CI results to further clean it up

Tip: you can enable GitHub Actions at https://github.com/rickeylev/peps/actions and run the CI on your fork.

Yes, finding a sponsor is my next big step.

Good luck!

hugovk avatar Jun 30 '25 21:06 hugovk

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:

  • Sponsor formally confirms they're a sponsor
  • Sponsor approves this PR

I'm not entirely sure on process, so I'll just leave this PR in draft state until those are done / imminent.

rickeylev avatar Jul 02 '25 03:07 rickeylev

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.

ncoghlan avatar Jul 02 '25 07:07 ncoghlan

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.

hugovk avatar Jul 02 '25 17:07 hugovk

Hello -- just stopping by with an idea and some prior art 👋

Last year I implemented 'relocatable' venv support in uv. It, too, was controlled by way of a pyvenv.cfg item, namely relocatable. Though of course this config item isn't really canonical -- as of now, it is just a uv-ism.

I think this PEP is a good opportunity to standardise this capability. One notable difference being:

  • PEP 796 relative: affects home resolution within pyvenv.cfg, when home is a relative path
  • uv venv --relocatable: affects the Python executable resolution within script-executables (the mostly-autogen stuff you see in bin//Scripts/ on Windows)

I may be biased 😊, but I do think that you'd probably want to include the latter in this PEP. The intent here is for a relative virtual environment to be freely movable. And without relocatable/relative scripts, you'd have a significant usability gap.

P.S. Drat. Only just saw the discussion on Discourse. I imagine this is more controversial than I'd thought.

paveldikov avatar Aug 05 '25 21:08 paveldikov

@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

AA-Turner avatar Aug 06 '25 00:08 AA-Turner

Belatedly removed the DO-NOT-MERGE label (that was added pending the Discourse discussion and sponsorship of the PEP)

ncoghlan avatar Aug 18 '25 14:08 ncoghlan

@rickeylev I went ahead and applied the straightforward markup & grammar fixes in https://github.com/python/peps/pull/4476/commits/ae5a67f971c43ccc4e1aa26b96ea11f1b444702a, so the remaining comments are the ones that aren't as simple to address.

@AA-Turner This will need a re-review from you at some point for the "Changes requested" flag.

ncoghlan avatar Oct 07 '25 14:10 ncoghlan