Search code examples
pythonpipsetuptoolspypi

Install python package from private pypiserver


I have setup a pypiserver behind an nginx proxy which uses htpasswd for authentication. I am currently able to upload sdists, but I can't figure out how to download them. I want to be able to download them when running setup.py test and somehow by using pip. Is this possible?

[distutils]
index-servers =
    private

[private]
repository = https://example.com/pypi
username = remco
password = mypass

To make it extra hard the server is currently using a non verified ssl connection.

I tried the following setup based on http://pythonhosted.org/setuptools/setuptools.html#setuptools-package-index, but the only documentation on this is 'XXX'

#!/usr/bin/env python2.7

from setuptools import setup


setup(
    name='asd',
    version='0.0.1',
    package_index='https://example.com/pypi/simple',
    test_suite='test',
    tests_require=['foo==0.0.1'])

Solution

  • The server certificate had to be setup properly. For uploading using pip one must create a valid ~/.pypirc file:

    [distutils]
    index-servers = example
    
    [example]
    repository = https://example.com/pypi
    username = myname
    password = mypass
    

    For installing packages one needs to add the following section to .pip/pip.conf

    [global]
    extra-index-url = https://myname:[email protected]/pypi/simple
    

    As knitti noted in a previous answer it is also possible to user index-url instead of extra-index-url. This does mean that the cheese shop is not used as a second server.

    For using a private server with setuptools unittesting you need to add the following to your setup.py:

    from setuptools import setup
    
    setup(
        ...
        dependency_links=[
            'https://myname:[email protected]/pypi/packages/'
        ])