Search code examples
pythonpippypi

How do I ensure pip gets package from internal pypi?


I have an application with a requirements.txt which includes a number of third party libraries along with one internal package which must be downloaded from a private pypi instance. Something like:

boto3
flask
flask-restplus
gunicorn
an_internal_package

The problem is that an_internal_package is named something quite common and occludes a package already available on the global pypi. For example, let's call it twisted. The problem I've run into is that setting --extra-index-url within requirements.txt seems to still grab twisted from the global pypi.

--extra-index-url=https://some.internal.pypi.corp.lan
boto3
flask
flask-restplus
gunicorn
twisted # actually an internal package

How can I indicate that twisted should be loaded exclusively from the private pypi and not from the global one?


Solution

  • You could link directly to the package on your internal index instead:

    boto3
    flask
    flask-restplus
    gunicorn
    https://some.internal.pypi.corp.lan/simple/twisted/Twisted-19.2.0.tar.bz2
    

    This has the effect of pinning the dependency, but this is generally considered best practice anyways.