Hi, I’ve had this idea come across my mind recently about supporting multiple versions of libraries in pip. Sorry in advance if this sounds unprofessional or vague, or if any PEPs or discussions already exists with the same idea, I’m new to the community, and wanted to raise what I think of would be a revolutionary idea.
So the proposal:
In simple terms, it’s just enabling pip to install and manage multiple versions side by side. Here’s a small snippet in action.
pip install mylib@1.2.3
What I am trying to raise with this change is the ability to install and use multiple versions of the same library in python scripts.
What’s the use for this new behaviour?
One potential use case might be reducing usage of venv and it’s siblings by installing the specific versions of the dependencies needed globally, while staying out of the forced lock in, enabling multiple projects
For example, say I use a “lib” package in two projects x and y, and i use the same computer for both
On x, the version of lib used is 1.2 but on y, 1.3 is used. This is where venv came into to the picture.
The change I’m proposing is that we could pull this off with a simple manifest file instead (I’ve heard there’s something called .toml files now, which could be used), which could massively simplify the user side setup with just a single script. This approach can even enable “use git to control dependency versions” type of workflows, which appears to ve be common in CI/CD environments.
And now what about older versions?
We could add a --keep-old-versions
flag on pip install/upgrade, which will keep the older versions and install the newer ones seperately, and keep track of versions properly.
Resolving behaviour with import xyz
A version resolution order can be implemented which goes like
- Version manifest files
- Latest version installed (considering more than 1 version is installed)
- The default version (legacy behaviour)
This is what I have for now. I also thought about a phase 2 which touches the import statement’s semantics, will bring it up and write a seperate proposal if there’s interest from the community.
(Sneek peek - import lib@1.2
)
I’m also open to rethink any changes which I might have missed.
Thanks for reading, and I’m hoping for favourable replies from the core devs. Appreciate the work you guys put to maintain the world’s easiest computer language.