Nested virtual environment support in site/venv modules
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Feature or enhancement
Proposal:
It's a bit of a niche use case, but it would be helpful if you could have one virtual environment be created that references another as its parent. If you currently attempt to do this, the pyvenv.cfg of the child virtual environment only indirectly references the parent through the command variable (which doesn't appear to be used). The code in site.venv could be enhanced to infer the prefix of the parent environment and add those site packages after the current virtual environment. This would ensure that the order of sys.path entries would be appropriate.
This would allow you to create a group virtual environment with a lot of common packages and still allow users to have their own child environments with additional or newer packages.
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in Lib/site.py at the site.venv implementation referenced by the issue, and inspect how pyvenv.cfg and the command variable are currently handled. Define how a child environment should infer its parent prefix and order the parent site packages after the child’s entries; done means nested environments expose the intended sys.path ordering.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- developer-experience
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100