On Wed, Oct 21, 2020 at 6:30 AM Paul Moore <p.f.mo...@gmail.com> wrote: > > On Tue, 20 Oct 2020 at 20:16, Chris Angelico <ros...@gmail.com> wrote: > > > What's the mechanism by which a venv announces its parent, and does > > this work correctly if the binary is invoked directly? Currently, if > > you invoke /.../.../.../env/bin/python3, it will use the lib directory > > from that venv; with this plan, it would need to add the parent also. > > I'd imagine that the "parent" could be put in `pyvenv.cfg`, and the > interpreter startup code would (somehow) add that to `sys.path`. Which > is mostly straightforward, but `sys.path` setup is (I believe) fairly > deeply entangled with interpreter startup. I'd assume that the effect > of the mechanism would be just like any other means of adding entries > to sys.path - that's both the intended layering benefits, and the > potentially bad/confusing ones like different versions of a package > shadowing each other.
That's what I'd have figured too, but interpreter startup does make it more complicated. > It's also worth noting that tools like pip would probably struggle > with managing linked environments like this. I suspect that's actually > a far bigger problem than the core mechanism. Pip is already > struggling with the amount of complexity it has to deal with, I don't > think we'd be able to add something like this. So you might have to > manually manage the "layers", or build a tool that wraps pip and > handles the layering. There's already the --system-site-packages flag to venv; I'm not sure how pip behaves with that - does "pip freeze" list system-installed packages too? Whatever it is, I would just assume that the parent venv is between the current one and the system path, with similar behaviour. What happens if the parent has a parent? What happens if you create circular parentage (by changing the config file on the parent to have the child as a parent - a classic time travel paradox)? Assuming these edge cases can be resolved in some well-defined way (even if that's "throw an error if you try that"), I'm +1 on this proposal. ChrisA _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/4OMO3Q7G6O5WGL7FCK5ZLR3EW6GUQPEX/ Code of Conduct: http://python.org/psf/codeofconduct/