Allowing Multiple Versions of Same Python Package in PYTHONPATH

It has been tried before. setuptools started out with multi version support, and, in some ways, that was the USP of it.

The tooling for this still exists in setuptools and is still documented at Multi-version installs — Python Packaging User Guide.

The thing is, this approach is somewhat incompatible with Python’s import mechanisms (there’s a single global import cache), causes subtle/difficult to reason about failures (see numpy example above, and think about how you’d debug a failure there — remember, repr and type aren’t going to include versions) and all the other things mentioned already.

This is so baked into setuptools that pip calls it with --single-version-externally-managed whenever it uses setuptools as an installation mechanism to avoid hitting any of the multi-version support code paths.

This will likely also be unsupported by now, because there’s absolutely not enough interest to keep that working — and even if it does work for you, unless you want to step forward and start maintaining that code while being mindful of backwards compatibility, I don’t think anything is going to change here.

2 Likes