在setup.py或pip要求文件中,如何控制安装包依赖关系的顺序? [英] In setup.py or pip requirements file, how to control order of installing package dependencies?

查看:702
本文介绍了在setup.py或pip要求文件中,如何控制安装包依赖关系的顺序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Python包,其setup.py具有通过常规方式声明的依赖关系,在install_requires = [...]中。其中一个包,scikits.timeseries,有一个setup.py,希望已经安装了numpy,因此,我想要一些方法首先安装numpy。对于这种情况,一般来说,依赖安装的顺序是否可以控制?怎么样?

I've got a Python package with its setup.py having dependencies declared via the usual way, in install_requires=[...]. One of the packages there, scikits.timeseries, has a setup.py expecting numpy to already be installed, thus, I'd like some way to have numpy installed first. For this case and in general, can the order of dependency installation be controlled? How?

目前,setup.py拉下依赖关系的顺序(在arg install_requires中列出)似乎几乎是随机的。此外,在setup.py设置(...)中,我尝试使用arg:

Currently the order in which setup.py pulls down dependencies (as listed in the arg install_requires) seems practically random. Also, in the setup.py setup(...) I tried using the arg:

extras_require={'scikits.timeseries': ['numpy']}

...没有成功,安装依赖关系的顺序不受影响

...without success, the order of installing dependencies was unaffected.

我也尝试设置一个pip需求文件,但是pip的安装依赖关系的顺序与要求文件的行顺序不符,所以没有

I also tried setting up a pip requirements file, but there too, pip's order of installing dependencies didn't match the line-order of the requirements file, so no luck.

另一种可能性是在setup.py顶部附近有一个系统调用,在安装(...)调用之前安装numpy,但是我希望有一个更好的方法。感谢提前获得任何帮助。

Another possibility would be to have a system call near the top of setup.py, to install numpy before the setup(...) call, but I hope there's a better way. Thanks in advance for any help.

推荐答案

如果 scikits.timeseries 需要 numpy ,那么它应该将其声明为依赖关系。如果这样做,那么 pip 会处理你的事情(我很确定 setuptools 也会,但我长时间没有使用它)。如果您控制 scikits.timeseries ,那么您应该修复它的依赖关系声明。

If scikits.timeseries needs numpy, then it should declare it as a dependency. If it did, then pip would handle things for you (I'm pretty sure setuptools would, too, but I haven't used it in a long while). If you control scikits.timeseries, then you should fix it's dependency declarations.

这篇关于在setup.py或pip要求文件中,如何控制安装包依赖关系的顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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