It's a similar question to How can I make setuptools install a package that's not on PyPI? but not the same.
这是一个类似的问题我如何让setuptools安装一个不在PyPI上的软件包?但不一样。
As I would like to use the forked version of some package, setuptools ignore the dependency link (as it has the same version number).
由于我想使用某些包的分叉版本,setuptools会忽略依赖关系链接(因为它具有相同的版本号)。
Is there a way to force using the link from the dependency_links? Or is the only way to change the version number in the forked repo?
有没有办法强制使用dependency_links中的链接?或者是更改分叉回购中版本号的唯一方法?
requires = [
...
'pyScss==1.1.3'
...
dependencies = [
'https://github.com/nadavshatz/pyScss/zipball/master#egg=pyScss-1.1.3'
]
Update
Weird, apparently it works if this package is the only one in the required list, that is not installed yet. If there's another missing package it will download it from pypi.
很奇怪,显然它是有效的,如果这个包是所需列表中唯一尚未安装的包。如果有另一个丢失的包,它将从pypi下载。
2 个解决方案
#1
10
I believe you can just use dependency_links
as described in that question:
我相信您可以使用该问题中描述的dependency_links:
from setuptools import setup
setup(name = 'mypkg',
version = '0.0.1',
description = 'Foo',
author = 'bar',
author_email = 'bar@example.com',
install_requires = ['pyScss==1.1.3'],
dependency_links = [
'https://github.com/nadavshatz/pyScss/zipball/master#egg=pyScss-1.1.3'
]
)
Tested using python setup.py develop
使用python setup.py开发测试
You probably want to rename the egg to emphasize it's a fork http://www.python.org/dev/peps/pep-0386/
您可能想要重命名鸡蛋以强调它是一个叉子http://www.python.org/dev/peps/pep-0386/
Outside of the setup.py you can enforce this locally using requirements.txt
and pip
. Whilst this won't make your package depend on the fork you can easily document it as the way to install.
在setup.py之外,您可以使用requirements.txt和pip在本地强制执行此操作。虽然这不会使您的包依赖于fork,但您可以轻松地将其记录为安装方式。
$ cat requirements.txt
https://github.com/nadavshatz/pyScss/zipball/master#egg=pyScss-1.1.3
$ pip install -r requirements.txt
#2
7
I ended up doing something very similar to the answer in *.com/a/17442663/368102.
我最终做了一些非常类似于*.com/a/17442663/368102中的答案。
I need a requests-file
github package that name-conflicts with a different requests-file
package in PyPi. They both have a version 1.0, and the PyPi version has some higher versions.
我需要一个请求文件github包,其名称与PyPi中的不同请求文件包冲突。它们都有1.0版本,而PyPi版本有更高版本。
The workaround in my ias_tools/setup.py
looks like this:
我的ias_tools / setup.py中的解决方法如下所示:
setup(
...
install_requires=[
'requests-file<=99.99',
],
dependency_links=[
'https://github.com/jvantuyl/requests-file/archive/b0a7b34af6e287e07a96bc7e89bac3bc855323ae.zip#egg=requests-file-99.99'
]
)
In my case, I'm using pip
so I also had to use --process-dependency-links
:
在我的情况下,我正在使用pip所以我还必须使用--process-dependency-links:
% pip install --process-dependency-links ./ias_tools
You are using pip version 6.0.6, however version 6.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Processing ./ias_tools
DEPRECATION: Dependency Links processing has been deprecated and will be removed in a future release.
Collecting requests-file<=99.99 (from ias-tools==0.1)
Downloading https://github.com/jvantuyl/requests-file/archive/b0a7b34af6e287e07a96bc7e89bac3bc855323ae.zip
Requirement already satisfied (use --upgrade to upgrade): requests>=1.1.0 in ./venv/lib/python2.7/site-packages (from requests-file<=99.99->ias-tools==0.1)
Installing collected packages: ias-tools, requests-file
Running setup.py install for ias-tools
Running setup.py install for requests-file
Successfully installed ias-tools-0.1 requests-file-1.0
I'm not too worried about the deprecation notice, as a pull request was submitted to pip to deprecate the deprecation (after a discussion about it).
我并不太担心弃用通知,因为提交请求被提交给pip以弃用弃用(在讨论之后)。
#1
10
I believe you can just use dependency_links
as described in that question:
我相信您可以使用该问题中描述的dependency_links:
from setuptools import setup
setup(name = 'mypkg',
version = '0.0.1',
description = 'Foo',
author = 'bar',
author_email = 'bar@example.com',
install_requires = ['pyScss==1.1.3'],
dependency_links = [
'https://github.com/nadavshatz/pyScss/zipball/master#egg=pyScss-1.1.3'
]
)
Tested using python setup.py develop
使用python setup.py开发测试
You probably want to rename the egg to emphasize it's a fork http://www.python.org/dev/peps/pep-0386/
您可能想要重命名鸡蛋以强调它是一个叉子http://www.python.org/dev/peps/pep-0386/
Outside of the setup.py you can enforce this locally using requirements.txt
and pip
. Whilst this won't make your package depend on the fork you can easily document it as the way to install.
在setup.py之外,您可以使用requirements.txt和pip在本地强制执行此操作。虽然这不会使您的包依赖于fork,但您可以轻松地将其记录为安装方式。
$ cat requirements.txt
https://github.com/nadavshatz/pyScss/zipball/master#egg=pyScss-1.1.3
$ pip install -r requirements.txt
#2
7
I ended up doing something very similar to the answer in *.com/a/17442663/368102.
我最终做了一些非常类似于*.com/a/17442663/368102中的答案。
I need a requests-file
github package that name-conflicts with a different requests-file
package in PyPi. They both have a version 1.0, and the PyPi version has some higher versions.
我需要一个请求文件github包,其名称与PyPi中的不同请求文件包冲突。它们都有1.0版本,而PyPi版本有更高版本。
The workaround in my ias_tools/setup.py
looks like this:
我的ias_tools / setup.py中的解决方法如下所示:
setup(
...
install_requires=[
'requests-file<=99.99',
],
dependency_links=[
'https://github.com/jvantuyl/requests-file/archive/b0a7b34af6e287e07a96bc7e89bac3bc855323ae.zip#egg=requests-file-99.99'
]
)
In my case, I'm using pip
so I also had to use --process-dependency-links
:
在我的情况下,我正在使用pip所以我还必须使用--process-dependency-links:
% pip install --process-dependency-links ./ias_tools
You are using pip version 6.0.6, however version 6.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Processing ./ias_tools
DEPRECATION: Dependency Links processing has been deprecated and will be removed in a future release.
Collecting requests-file<=99.99 (from ias-tools==0.1)
Downloading https://github.com/jvantuyl/requests-file/archive/b0a7b34af6e287e07a96bc7e89bac3bc855323ae.zip
Requirement already satisfied (use --upgrade to upgrade): requests>=1.1.0 in ./venv/lib/python2.7/site-packages (from requests-file<=99.99->ias-tools==0.1)
Installing collected packages: ias-tools, requests-file
Running setup.py install for ias-tools
Running setup.py install for requests-file
Successfully installed ias-tools-0.1 requests-file-1.0
I'm not too worried about the deprecation notice, as a pull request was submitted to pip to deprecate the deprecation (after a discussion about it).
我并不太担心弃用通知,因为提交请求被提交给pip以弃用弃用(在讨论之后)。