【问题标题】:Install python package from private pypiserver从私有 pypiserver 安装 python 包
【发布时间】:2014-03-29 22:11:17
【问题描述】:

我在 nginx 代理后面设置了一个 pypiserver,它使用 htpasswd 进行身份验证。我目前能够上传 sdist,但我不知道如何下载它们。我希望能够在运行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'])

【问题讨论】:

    标签: python pip setuptools pypi


    【解决方案1】:

    将您的索引与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 上的一些文档是 here 和 pypiserver here

    也许您也可以尝试使用package_index='https://user:pass@example.com/pypi/simplesetup.py

    【讨论】:

    • 我认为 index-url 似乎没问题,但我收到有关 ssl 证书的错误。无论如何,我可能应该先解决这个问题。关于 package_index kwarg; setuptools 抱怨这是一个无效的参数。我不知道该用什么来代替
    • 我添加了关于让你的 CA 被 pip 知道的行,这样它就不会抱怨了。
    【解决方案2】:

    必须正确设置服务器证书。 要使用 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 单元测试的私有服务器,您需要将以下内容添加到您的 setup.py

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

    【讨论】:

      猜你喜欢
      • 2020-11-17
      • 1970-01-01
      • 2016-11-15
      • 1970-01-01
      • 2013-12-03
      • 1970-01-01
      • 2018-12-30
      • 1970-01-01
      • 2022-08-11
      相关资源
      最近更新 更多