python安装选项_如何使用pip单独安装python软件包及其依赖项,以允许使用单独的pip选项?...

1586010002-jmsa.png

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.

How can I separately install the dependencies first?

Something like pip install --only-deps does not seem to exist.

Edit

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

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 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"

# ...

And install like this:

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值