Pip可以在安装时安装setup.py中未指定的依赖项吗? [英] Can Pip install dependencies not specified in setup.py at install time?

查看:105
本文介绍了Pip可以在安装时安装setup.py中未指定的依赖项吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望pip安装一个我在GitHub上具有的依赖项,当用户发出命令来安装原始软件时(同样从GitHub上的源代码).这些软件包都不在PyPi上(而且永远不会).

I'd like pip to install a dependency that I have on GitHub when the user issues the command to install the original software, also from source on GitHub. Neither of these packages are on PyPi (and never will be).

用户发出命令:

pip -e git+https://github.com/Lewisham/cvsanaly@develop#egg=cvsanaly

此存储库有一个requirements.txt文件,另外一个依赖于GitHub:

This repo has a requirements.txt file, with another dependency on GitHub:

-e git+https://github.com/Lewisham/repositoryhandler#egg=repositoryhandler

我想要的是一个单个命令,用户可以发出该命令来安装原始软件包,让pip找到需求文件,然后再安装依赖项.

What I'd like is a single command that a user can issue to install the original package, have pip find the requirements file, then install the dependency too.

推荐答案

This answer helped me solve the same problem you're talking about.

setup.py似乎没有一种直接使用需求文件来定义其依赖项的简便方法,但是可以将相同的信息放入setup.py本身.

There doesn't seem to be an easy way for setup.py to use the requirements file directly to define its dependencies, but the same information can be put into the setup.py itself.

我有这个要求.txt:

I have this requirements.txt:

PIL
-e git://github.com/gabrielgrant/django-ckeditor.git#egg=django-ckeditor

但是,当安装该requirements.txt的包含软件包时,pip会忽略这些要求.

But when installing that requirements.txt's containing package, the requirements are ignored by pip.

这个setup.py似乎迫使pip安装了依赖项(包括我的django-ckeditor的github版本):

This setup.py seems to coerce pip into installing the dependencies (including my github version of django-ckeditor):

from setuptools import setup

setup(
    name='django-articles',
    ...,
    install_requires=[
        'PIL',
        'django-ckeditor>=0.9.3',
    ],
    dependency_links = [
        'http://github.com/gabrielgrant/django-ckeditor/tarball/master#egg=django-ckeditor-0.9.3',
    ]
)

此答案还包含一些有用的信息.

This answer also contains some useful information.

需要将版本指定为"#egg = ..."的一部分,以标识链接上可用的软件包版本. 但是请注意,如果您始终要依赖最新版本,则可以在install_requires,dependency_links和其他软件包的setup.py

Specifying the version as part of the "#egg=..." is required to identify which version of the package is available at the link. Note, however, that if you always want to depend on your latest version, you can set the version to dev in install_requires, dependency_links and the other package's setup.py

编辑:根据以下注释,使用dev作为版本不是一个好主意.

using dev as the version isn't a good idea, as per comments below.

这篇关于Pip可以在安装时安装setup.py中未指定的依赖项吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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