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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章