取决于setup.py中的git存储库 [英] Depend on git repository in setup.py

查看:130
本文介绍了取决于setup.py中的git存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让一个项目依赖于git依赖。但是,我似乎无法让它工作。我基本上想要实现的是以下内容,但它不起作用:

I'm trying to make a project depend on a git dependency. However, I can't seem to get it to work. What I basically want to achieve is the following, but it doesn't work:

#!/usr/bin/env python3
from setuptools import setup


setup(
    name='spam',
    version='0.0.0',
    install_requires=[
        'git+https://github.com/remcohaszing/pywakeonlan.git'
    ])

我在上面尝试了几个变体,例如添加 @master #egg = wakeonlan-0.2.2 ,但这没有什么区别。

I tried several variations on the above, such as adding @master or #egg=wakeonlan-0.2.2, but this doesn't make a difference.

以下工作,但仅当使用已弃用的 pip flag, - process-dependency-links

The following works, but only when using the deprecated pip flag, --process-dependency-links:

#!/usr/bin/env python3
from setuptools import setup


setup(
    name='spam',
    version='0.0.0',
    install_requires=[
        'wakeonlan'
    ],
    dependency_links=[
        'git+https://github.com/remcohaszing/pywakeonlan.git#egg=wakeonlan-0.2.2'
    ])

p>

This outputs:

$ pip install --no-index -e . --process-dependency-links
Obtaining file:///home/remco/Downloads/spam
  DEPRECATION: Dependency Links processing has been deprecated and will be removed in a future release.
Collecting wakeonlan (from spam==0.0.0)
  Cloning https://github.com/remcohaszing/pywakeonlan.git to /tmp/pip-build-mkhpjcjf/wakeonlan
  DEPRECATION: Dependency Links processing has been deprecated and will be removed in a future release.
Installing collected packages: wakeonlan, spam
  Running setup.py install for wakeonlan ... done
  Running setup.py develop for spam
Successfully installed spam wakeonlan-0.2.2

以下方法可行:

The following does work:

pip install 'git+https://github.com/remcohaszing/pywakeonlan.git'

在需求文件中添加git url也行。

Also adding the git url in a requirements file just works.

有没有不推荐使用的方法来依赖git url使用 setup.py 文件?

Is there any non deprecated way to depend on a git url using a setup.py file?

推荐答案

Pip> = 9.1 (commit 6ec559)将支持新的 @ 语法,如 PEP508 所述,格式: pkgname @ url#sum - 例如:

Pip >= 9.1 (commit 6ec559) will have support for the new @ syntax as described in PEP508, which takes the format: pkgname@url#sum - e.g.:

pip install --no-index packaging@https://files.pythonhosted.org/packages/2f/2b/c681de3e1dbcd469537aefb15186b800209aa1f299d933d23b48d85c9d56/packaging-15.3-py2.py3-none-any.whl#sha256=ce1a869fe039fbf7e217df36c4653d1dbe657778b2d41709593a0003584405f4

这也可以在setup.py中以同样的方式使用,例如:

This will also be useable in setup.py in the same way, e.g.:

install_requires=['packaging@https://files.pythonhosted.org/packages/2f/2b/c681de3e1dbcd469537aefb15186b800209aa1f299d933d23b48d85c9d56/packaging-15.3-py2.py3-none-any.whl#sha256=ce1a869fe039fbf7e217df36c4653d1dbe657778b2d41709593a0003584405f4']

您可以尝试刚刚提供了 pip master(更新pip'错误'的方式!):

You can try this out just now with the latest commit to pip master (updating pip the 'wrong' way!):

$ pip install https://github.com/pypa/pip/archive/master.zip
$ pip install --no-index packaging@https://files.pythonhosted.org/packages/2f/2b/c681de3e1dbcd469537aefb15186b800209aa1f299d933d23b48d85c9d56/packaging-15.3-py2.py3-none-any.whl#sha256=ce1a869fe039fbf7e217df36c4653d1dbe657778b2d41709593a0003584405f4
Collecting packaging@ https://files.pythonhosted.org/packages/2f/2b/c681de3e1dbcd469537aefb15186b800209aa1f299d933d23b48d85c9d56/packaging-15.3-py2.py3-none-any.whl#sha256=ce1a869fe039fbf7e217df36c4653d1dbe657778b2d41709593a0003584405f4 
from https://files.pythonhosted.org/packages/2f/2b/c681de3e1dbcd469537aefb15186b800209aa1f299d933d23b48d85c9d56/packaging-15.3-py2.py3-none-any.whl#sha256=ce1a869fe039fbf7e217df36c4653d1dbe657778b2d41709593a0003584405f4
Downloading https://files.pythonhosted.org/packages/2f/2b/c681de3e1dbcd469537aefb15186b800209aa1f299d933d23b48d85c9d56/packaging-15.3-py2.py3-none-any.whl
Installing collected packages: packaging
Successfully installed packaging-15.3

这篇关于取决于setup.py中的git存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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