Python setuptools:如何在install_requires下列出私有存储库? [英] Python setuptools: How can I list a private repository under install_requires?

查看:145
本文介绍了Python setuptools:如何在install_requires下列出私有存储库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为一个依赖于私有GitHub存储库的项目创建一个 setup.py 文件。该文件的相关部分如下所示:

  from setuptools import setup 
setup(name ='my_project',
...,
install_requires = [
'public_package',
'other_public_package',
'private_repo_1',$ b $'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 /',
],
...,

我使用 setuptools 而不是 distutils ,因为后者不支持 install_requires dependency_links 参数per 这个答案。



上述设置文件无法访问404错误 - 这是预料之中的,因为GitHub将404传回私人存储库的未授权请求。但是,我无法弄清楚如何使 setuptools 进行身份验证。



以下是一些我尝试过的:


  1. 使用 git + ssh:// 而不是 https:// dependency_links 中,如果安装带有 pip 。这个失败是因为setuptools不能识别这个协议(未知的url类型:git + ssh),尽管发布文档说它应该。同上 git + https git + http


  2. https://<用户名>:<密码> @ github.com / ... - 仍然得到404(此方法不起作用在命令行中使用 curl wget - 虽然 curl -u< username> < / li>
  3. 升级setuptools(0.9.7)和virtualenv(1.10 )到最新版本。还尝试安装发布虽然这个概述说,它被合并回setuptools 。无论哪种方式,没有骰子。


目前我只有 setup.py 打印出私人回购站必须单独下载的警告。这显然不够理想。我觉得有些事情显而易见,但我想不出它会是什么。 :)

没有答案的重复问题 here。



  install_requires = [
'private_package_name == 1.1',
],
dependency_links = [
'git + ssh://git@github.com/username/private_repo.git#egg=private_package_name-1.1',
]

请注意,您必须在egg名称中包含版本号,否则会说它找不到包裹。


I am creating a setup.py file for a project which depends on private GitHub repositories. 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.

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. However, I can't figure out how to make setuptools authenticate.

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. This fails because setuptools doesn't recognize this protocol ("unknown url type: git+ssh"), though the distribute documentation says it should. Ditto git+https and git+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.)

  3. Upgrading setuptools (0.9.7) and virtualenv (1.10) to the latest versions. Also tried installing distribute though this overview says it was merged back into setuptools. Either way, no dice.

Currently I just have setup.py print out a warning that the private repos must be downloaded separately. 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.

解决方案

Here's what worked for me:

  install_requires=[
      'private_package_name==1.1',
  ],
  dependency_links=[
      'git+ssh://git@github.com/username/private_repo.git#egg=private_package_name-1.1',
  ]

Note that you have to have the version number in the egg name, otherwise it will say it can't find the package.

这篇关于Python setuptools:如何在install_requires下列出私有存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆