如何使用pip单独安装python软件包及其依赖项,以允许使用单独的pip选项? [英] How to install separately a python package and its dependencies using pip in order to allow separated pip options?

查看:399
本文介绍了如何使用pip单独安装python软件包及其依赖项,以允许使用单独的pip选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个python软件包(一个分支),需要额外的选项才能安装.我发现可以使用pip的--global-option选项完成此操作:

I have (a fork of) a python package that needs an extra option in order to be installed. I found out that this could be done using the --global-option option of pip:

pip install --global-option="cythonize" git+https://github.com/blaiseli/pybedtools.git@fix_missing_headers

但是,此选项使此软件包的依赖项安装失败,因为它也适用于它们,并且无法识别.

However, this option makes the installation of this package's dependencies fail, because it also applies to them, and is not recognized.

如何首先分别安装依赖项?

似乎不存在像pip install --only-deps <some package>这样的东西.

Something like pip install --only-deps <some package> does not seem to exist.

按照此答案中的建议,我尝试在程序包的分支中设置别名,以便cythonize命令在安装前运行:

As suggested in this answer, I tried setting up an alias in my fork of the package, in order to have the cythonize command run before install:

$ cat setup.cfg 
[wheel]
universal = 1
[nosetests]
detailed-errors = 1
doctest-extension = .pyx .py
[aliases]
install = cythonize install

奇怪的是,正确地处理了cythonize命令:

Strangely, the cythonize command is handled correctly:

$ python3.7 setup.py cythonize
running cythonize
Compiling pybedtools/cbedtools.pyx because it changed.
Compiling pybedtools/featurefuncs.pyx because it changed.
[1/2] Cythonizing pybedtools/cbedtools.pyx
/usr/local/lib/python3.7/site-packages/Cython/Compiler/Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /home/bli/src/pybedtools/pybedtools/cbedtools.pxd
  tree = Parsing.p_module(s, pxd, full_module_name)
[2/2] Cythonizing pybedtools/featurefuncs.pyx
/usr/local/lib/python3.7/site-packages/Cython/Compiler/Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /home/bli/src/pybedtools/pybedtools/featurefuncs.pyx
  tree = Parsing.p_module(s, pxd, full_module_name)

但是当它是别名的一部分时无法识别:

But it is not recognized when it is part of an alias:

$ python3.7 setup.py install
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: setup.py --help [cmd1 cmd2 ...]
   or: setup.py --help-commands
   or: setup.py cmd --help

error: invalid command 'cythonize'

推荐答案

pip 在某种程度上支持带有内联选项的requirements.txt文件.因此,您可以使用这样的requirements.txt:

pip somewhat supports requirements.txt files with inline options. So you could go with a requirements.txt like this:

# ...
cython
git+https://github.com/blaiseli/pybedtools.git@fix_missing_headers --global-option="cythonize"
# ...

并这样安装:

pip install --requirement requirements.txt

我说有点,因为它似乎仍然对其他要求的安装有(显然没有破坏作用).特别是,它似乎为其他要求和依赖项禁用了轮子,这对我来说毫无意义.

I say somewhat because it still seems to have (apparently non damaging) effects on the installation of the other requirements. In particular it seems to disable wheels for the other requirements and dependencies, which doesn't make sense to me.

这篇关于如何使用pip单独安装python软件包及其依赖项,以允许使用单独的pip选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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