从私有pypiserver安装python包 [英] Install python package from private pypiserver
问题描述
我已经在使用htpasswd进行身份验证的nginx代理后面设置了pypiserver.我目前可以上传sdists,但是我不知道如何下载它们.我希望能够在运行setup.py test
时以及通过使用pip
某种方式下载它们.这可能吗?
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
为了使服务器更加困难,当前服务器正在使用未经验证的ssl连接.
To make it extra hard the server is currently using a non verified ssl connection.
我尝试了基于 http://pythonhosted.org/setuptools的以下设置/setuptools.html#setuptools-package-index ,但是唯一的文档是"XXX"
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'])
推荐答案
必须正确设置服务器证书.
要使用pip上传文件,必须创建一个有效的~/.pypirc
文件:
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
要安装软件包,需要将以下部分添加到.pip/pip.conf
For installing packages one needs to add the following section to .pip/pip.conf
[global]
extra-index-url = https://myname:mypass@example.com/pypi/simple
正如knitti在先前的回答中指出的那样,也可以使用用户index-url
代替extra-index-url
.这确实意味着奶酪店不被用作第二台服务器.
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.
要使用带有setuptools unittest的专用服务器,您需要在setup.py
中添加以下内容:
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:mypass@example.com/pypi/packages/'
])
这篇关于从私有pypiserver安装python包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!