I have built a package (let's call it mypackage) that depends on a well-known third-party module (namely pandas), available on PyPi. I've uploaded mypackage on a custom PyPi-like server (pypicustom). I'm struggling to install it on environments where all I have access to is a mirror to PyPi (let's call it pypiproxy).
pip install --index-url http://custompypi/ mypackage
does not work as pandas can't obviously be found.
pip install --index-url http://pypiproxy/ --extra-index-url http://custompypi/ mypackage
works until somebody uploads a package named mypackage on PyPi.
Closest I could come with is:
pip install --index-url http://custompypi/ --no-dependencies mypackage
pip install --index-url http://pypiproxy/ --extra-index-url http://custompypi/ mypackage
which does not feel right.
Any idea?
Probably not the answer you’re wanting, but Poetry (a Python dependency/environment tool) handles your requirement really well.
Not only can you configure sources with different priorities but you can explicitly set the source for a package so then when you do a poetry install it pulls all the dependencies from the sources you specify. A pyproject.toml for your example:
[tool.poetry.dependencies]
...
mypackage = { version = "^0.22", source = "custompypi" }
[[tool.poetry.source]]
name = "custompypi"
url = http://custompypi/
priority = "explicit"
[[tool.poetry.source]]
name = "pypi-proxy"
url = http://pypiproxy/
priority = "default"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With