【发布时间】:2019-10-14 15:38:49
【问题描述】:
我有一个 python 包(一个分支),它需要一个额外的选项才能安装。我发现这可以使用 pip 的--global-option 选项来完成:
pip install --global-option="cythonize" git+https://github.com/blaiseli/pybedtools.git@fix_missing_headers
但是,此选项会导致安装此包的依赖项失败,因为它也适用于它们,并且无法识别。
如何先单独安装依赖?
pip install --only-deps <some package> 之类的东西似乎不存在。
编辑
按照this answer 中的建议,我尝试在我的包的fork 中设置一个别名,以便在安装之前运行cythonize 命令:
$ cat setup.cfg
[wheel]
universal = 1
[nosetests]
detailed-errors = 1
doctest-extension = .pyx .py
[aliases]
install = cythonize install
奇怪的是,cythonize 命令处理正确:
$ 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)
但是当它是别名的一部分时无法识别:
$ 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'
【问题讨论】:
-
看起来你滥用了
--global-option,但如果它对你有用,那就好。实际上cythonize似乎不是一个setuptools 全局选项,它看起来更像是一个你想在install命令之前运行的setuptools 命令。您是否尝试过在setup.cfg中设置 别名?python setup.py alias install cythonize install