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.