I'm developing a Python package my_package
that depends upon some other package foo_package
.
There's a few versions of foo_package
that are used in the community, and unfortunately they're not backwards compatible with each other. (Because of changes to the C interface that my code is compiled against).
So I'd like to distribute multiple copies of my_package
, corresponding to the different versions of foo_package
.
I can distinguish these different copies of my_package
from each other using post-release tags. For example I can give my_package
the version 1.1.4-foo_package1.2
, corresponding to version 1.1.4
of my_package
compiled against version 1.2
of foo_package
.
So far so good. The caveat now is that when it comes to installing this with pip
, end users have to specify this full version string to be able to get the correct version of my_package
. That is, they have to know that the latest release of my_package
is 1.1.4
and that the release of foo_package
that they're using is 1.2
and thus use the command pip install my_package==1.1.4-foo_package1.2
.
Obviously this isn't ideal for all sorts of reasons. (End user friendliness, avoiding dependency hell... ) After all, all of this can be determined programmatically!
Is there any sensible way to handle this issue, so that an end user can just run pip install my_package
and have the correct copy downloaded automatically?
There is one unsatisfactory answer to a similar question here.
FWIW the best solution I've come up with so far is to create another package my_package_installer
which as part of its setup.py
checks what version of foo_package
is installed and then specifies the relevant version of my_package
as the install_requires
argument to setuptools.setup
. But that's completely asinine and seems quite fragile. I can't be the only one with this issue.