python - 如何使用 pip 单独安装 python 包及其依赖项以允许单独的 pip 选项?
问题描述
我有(一个分支)一个 python 包,需要一个额外的选项才能安装。我发现这可以使用--global-option
pip 选项来完成:
pip install --global-option="cythonize" git+https://github.com/blaiseli/pybedtools.git@fix_missing_headers
但是,此选项会使此软件包的依赖项的安装失败,因为它也适用于它们,并且无法识别。
如何先单独安装依赖项?
类似的东西pip install --only-deps <some package>
似乎不存在。
编辑
正如这个答案中所建议的,我尝试在我的包的分支中设置一个别名,以便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'
解决方案
与您的其他问题相同,我怀疑cythonize
是setuptools命令而不是全局选项。
如果确实如此,那么您最好在setup.cfg
. 如果您运行python setup.py alias install cythonize install
,这应该将以下内容添加到您的setup.cfg
:
[aliases]
install = cythonize install
稍后运行时pip install
,pip将遵循此别名,并且该cythonize
命令将在该install
命令之前执行。
推荐阅读
- python - 如何在 Heroku 服务器上重置托管应用程序的密码?
- sql - 带有 Where 子句和其他运算符的 Select 语句的程序顺序
- python - 打破列表的多个输入的While循环......用于嵌套列表
- javascript - 如何为导航按钮设置动画以使用 JavaScript 执行分配给它的正确动画?
- c++ - 使用 std::variant 的静态多态性
- properties - 属性视图中的框太小
- python - 这个循环的大(O)复杂性是什么?
- php - 参数类型“String”不能分配给参数类型“Uri”。扑
- performance - Common Lisp:在不使用 &rest 参数的情况下有效地处理提供的 p 参数
- java - 使用 Jackson 将 Tree 转换为 Json 而没有方括号和字段名称