I'm trying to package a python library that has setup-time (and also run-time) dependencies: it import
s the modules so that the modules can inform the setup process of the location of some provided C headers:
from distutils.extension import Extension
from pybedtools.helpers import get_includes as pybedtools_get_includes
from pysam import get_include as pysam_get_include
# [...]
extensions = [
Extension(
"bam25prime.libcollapsesam", ["bam25prime/libcollapsesam.pyx"],
include_dirs=pysam_get_include()),
Extension(
"bam25prime.libcollapsebed", ["bam25prime/libcollapsebed.pyx"],
include_dirs=pybedtools_get_includes(),
language="c++"),
]
# [...]
However, one of the dependencies (pybedtools
) needs to be installed with a specific --global-option
pip option (see at the end of the post what happens when the option is not provided).
If I understand correctly, the currently up-to-date way to automatically have some dependencies available before setup.py
is used is to indicate them in the [build-system]
section of a pyproject.toml
file.
I tried the following pyproject.toml
:
[build-system]
requires = [
"pysam",
"pybedtools @ git+https://github.com/blaiseli/pybedtools.git@fix_missing_headers --global-option='cythonize'",
]
build-backend = "setuptools.build_meta"
(By the way, it took me quite some time to figure out how to specify the build-backend
, the documentation is not easily discoverable.)
However, this generates the following error upon pip install
:
ERROR: Invalid requirement: "pybedtools @ git+https://github.com/blaiseli/pybedtools.git@fix_missing_headers --global-option='cythonize'"
Hint: It looks like a path. File 'pybedtools @ git+https://github.com/blaiseli/pybedtools.git@fix_missing_headers --global-option='cythonize'' does not exist.
How can I correctly specify options for dependencies ?
If I simply specify the package and its URL ("pybedtools @ git+https://github.com/blaiseli/pybedtools.git@fix_missing_headers
), the install fails as follows:
Exception:
Cython-generated file 'pybedtools/cbedtools.cpp' not found.
Please install Cython and run
python setup.py cythonize
It was while trying to tackle the above error that I found out about the --global-option
pip option. I can manually run pip install --global-option="cythonize" git+https://github.com/blaiseli/pybedtools.git@fix_missing_headers
, and the install works, provided the dependencies of that package are already installed, otherwise their install fails because of an unrecognized "cythonize"
option (which is another issue...).
from Specify setup time dependency with `--global-option` for a python package
No comments:
Post a Comment