Python setuptools: How can I list a private repository under install_requires?

问题:

I am creating a setup.py file for a project which depends on private GitHub repositories.我正在为一个依赖于私有 GitHub 存储库的项目创建一个setup.py文件。 The relevant parts of the file look like this:文件的相关部分如下所示:

from setuptools import setup
setup(name='my_project',
    ...,
    install_requires=[
        'public_package',
        'other_public_package',
        'private_repo_1',
        'private_repo_2',
    ],
    dependency_links=[
        'https://github.com/my_account/private_repo_1/master/tarball/',
        'https://github.com/my_account/private_repo_2/master/tarball/',
    ],
    ...,
)

I am using setuptools instead of distutils because the latter does not support the install_requires and dependency_links arguments per this answer.我使用setuptools而不是distutils因为后者不支持每个这个答案的install_requiresdependency_links参数。

The above setup file fails to access the private repos with a 404 error - which is to be expected since GitHub returns a 404 to unauthorized requests for a private repository.上面的设置文件无法访问私有存储库并出现 404 错误 - 这是意料之中的,因为 GitHub 向未授权的私有存储库请求返回 404。 However, I can't figure out how to make setuptools authenticate.但是,我不知道如何使setuptools身份验证。

Here are some things I've tried:以下是我尝试过的一些事情:

  1. Use git+ssh:// instead of https:// in dependency_links as I would if installing the repo with pip .dependency_links使用git+ssh://而不是https:// ,就像我使用pip安装 repo 一样。 This fails because setuptools doesn't recognize this protocol ("unknown url type: git+ssh"), though the distribute documentation says it should.这失败是因为 setuptools 无法识别此协议(“未知 url 类型:git+ssh”),尽管分发文档说它应该。 Ditto git+https and git+http .同上git+httpsgit+http

  2. https://<username>:<password>@github.com/... - still get a 404. (This method doesn't work with curl or wget from the command line either - though curl -u <username> <repo_url> -O <output_file_name> does work.) https://<username>:<password>@github.com/... - 仍然得到 404。(此方法也不适用于curlwget从命令行中使用 - 尽管curl -u <username> <repo_url> -O <output_file_name>确实有效。)

  3. Upgrading setuptools (0.9.7) and virtualenv (1.10) to the latest versions.将 setuptools (0.9.7) 和 virtualenv (1.10) 升级到最新版本。 Also tried installing distribute though this overview says it was merged back into setuptools.还尝试安装分发,尽管此概述说它已合并回 setuptools。 Either way, no dice.无论哪种方式,都没有骰子。

Currently I just have setup.py print out a warning that the private repos must be downloaded separately.目前我只有setup.py打印出一个警告,必须单独下载私有存储库。 This is obviously less than ideal.这显然不太理想。 I feel like there's something obvious that I'm missing, but can't think what it might be.我觉得我缺少一些明显的东西,但无法想象它可能是什么。 :) :)

Duplicate-ish question with no answers here . 这里没有答案的重复问题。


解决方案:

参考: https://stackoom.com/en/question/1Dddk
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章