Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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'])
like image 210
Remco Haszing Avatar asked Feb 26 '14 20:02

Remco Haszing


People also ask

How do you install a Python package using pip you use?

Ensure you can run pip from the command lineRun python get-pip.py . 2 This will install or upgrade pip. Additionally, it will install setuptools and wheel if they're not installed already. Be cautious if you're using a Python install that's managed by your operating system or another package manager.

How do I publish a private package in Python?

Build the python package twine : publishes the package on a package registry (a private one or PyPi). Install the requirements. To keep things simple, we will use the python virtual environment. Create a file setup.py and fill it with the information about your package.

Can PyPI be private?

PyPI (Python Package Index) is a public repository of user-submitted packages that can be installed using pip install package . This guide breaks down the basic scaffolding of a Python package, then using PyPiServer, creates a private repository by uploading the package to a Linode.


2 Answers

for using your index with pip create ~/.pip/pip.conf with this content:

[global]
index-url = https://remco:[email protected]/pypi/simple
cert = /etc/ssl/certs/your_cert_CA.pem

A little bit documentation on pip.conf is here and on pypiserver here

Perhaps you can also try using package_index='https://user:[email protected]/pypi/simple in setup.py.

like image 66
knitti Avatar answered Nov 09 '22 23:11

knitti


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/'
    ])
like image 29
Remco Haszing Avatar answered Nov 10 '22 00:11

Remco Haszing