如何让setuptools从另一个来源(也可以在pypi上使用相同版本号)安装软件包? [英] How can I make setuptools install a package from another source that's also available on pypi with the same version number?

查看:70
本文介绍了如何让setuptools从另一个来源(也可以在pypi上使用相同版本号)安装软件包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

类似的问题如何让setuptools安装不在PyPI上的软件包?但不相同.

正如我想使用某些软件包的分叉版本一样,setuptools会忽略依赖项链接(因为它具有相同的版本号).

As I would like to use the forked version of some package, setuptools ignore the dependency link (as it has the same version number).

是否有一种方法可以强制使用dependency_links中的链接?还是更改分叉存储库中版本号的唯一方法?

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?

requires = [
    ...
    'pyScss==1.1.3'
    ...

dependencies = [
    'https://github.com/nadavshatz/pyScss/zipball/master#egg=pyScss-1.1.3'
]


更新

很奇怪,如果此软件包是所需列表中唯一的软件包(尚未安装),显然可以使用.如果还有另一个缺少的软件包,它将从pypi下载.

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.

推荐答案

我相信您可以按照问题中的说明使用dependency_links:

I believe you can just use dependency_links as described in that question:

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'
      ]
    )

使用python setup.py develop

您可能想重命名鸡蛋以强调它是叉子 http://www .python.org/dev/peps/pep-0386/

You probably want to rename the egg to emphasize it's a fork http://www.python.org/dev/peps/pep-0386/

在setup.py之外,您可以使用requirements.txtpip在本地实施此操作.尽管这不会使您的软件包依赖于fork,但您可以轻松地将其记录为安装方式.

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.

$ cat requirements.txt
https://github.com/nadavshatz/pyScss/zipball/master#egg=pyScss-1.1.3
$ pip install -r requirements.txt

这篇关于如何让setuptools从另一个来源(也可以在pypi上使用相同版本号)安装软件包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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