取决于setup.py中的git存储库

时间:2016-07-12 08:27:30

标签: python git pip setuptools

我正在尝试使项目依赖于git依赖项。但是,我似乎无法让它发挥作用。我基本上想要实现的是以下内容,但它不起作用:

#!/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,但这没有什么区别。

以下情况有效,但仅在使用已弃用的pip标记--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'
    ])

输出:

$ 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

以下工作正常:

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

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

是否有任何非弃用方法依赖于使用setup.py文件的git网址?

1 个答案:

答案 0 :(得分:5)

Pip> = 9.1 (commit 6ec559)将支持PEP508中所述的新map' f xs = foldr (\x acc -> f x : acc) [] xs 语法,其格式为:map' f = foldr (\x acc -> f x : acc) [] - 例如:

@

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

pkgname@url#sum

您可以使用最新提交pip install --no-index packaging@https://files.pythonhosted.org/packages/2f/2b/c681de3e1dbcd469537aefb15186b800209aa1f299d933d23b48d85c9d56/packaging-15.3-py2.py3-none-any.whl#sha256=ce1a869fe039fbf7e217df36c4653d1dbe657778b2d41709593a0003584405f4 master(更新pip'错误'方式)尝试此操作:

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