从私有的pypiserver安装Python包

7
我已经在nginx代理后面设置了一个pypiserver,并使用htpasswd进行身份验证。目前我可以上传sdists,但是我无法弄清如何下载它们。我希望能够在运行setup.py test时通过使用pip来下载它们。这可能吗?
[distutils]
index-servers =
    private

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

为了让它更加困难,服务器目前正在使用一个未经验证的ssl连接。
我基于http://pythonhosted.org/setuptools/setuptools.html#setuptools-package-index尝试了以下设置,但唯一的文档是“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'])
2个回答

7
为了使用索引在pip中,创建~/.pip/pip.conf文件,并包含以下内容:
[global]
index-url = https://remco:mypass@build.d-centralize.nl/pypi/simple
cert = /etc/ssl/certs/your_cert_CA.pem

关于pip.conf的一些文档可以在这里找到,而有关pypiserver的文档可以在这里找到。

或许你也可以在setup.py中使用package_index='https://user:pass@example.com/pypi/simple来进行尝试。


1
我认为索引URL看起来没问题,但是我收到了有关SSL证书的错误。我应该先解决这个问题。关于package_index kwarg; setuptools抱怨它是无效的参数。我不知道要使用什么替代品。 - Remco Haszing
1
我添加了一行关于让pip知道你的CA的内容,这样它就不会抱怨了。 - knitti

3
服务器证书必须正确设置。 要使用pip上传,必须创建一个有效的~/.pypirc文件:
[distutils]
index-servers = example

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

安装软件包时需要将以下内容添加到.pip/pip.conf文件中:

[global]
extra-index-url = https://myname:mypass@example.com/pypi/simple

正如knitti在之前的回答中指出的那样,您也可以使用index-url而不是extra-index-url。这意味着奶酪商店不会被用作第二个服务器。

为了在setuptools unittesting中使用私有服务器,您需要将以下内容添加到您的setup.py文件中:

from setuptools import setup

setup(
    ...
    dependency_links=[
        'https://myname:mypass@example.com/pypi/packages/'
    ])

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接