I am developing a package containing Cython extensions.
According to https://github.com/pypa/pip/issues/1958 I shall use setup_requires
and postpone import of Cython
.
The best solution I came up with is to call setup()
twice in setup.py
:
... # initial imports
setup(setup_requires=['cython'])
from Cython.Build import cythonize
bar = Extension('foo.bar', sources = ['bar.pyx'])
setup(name = 'foo',
... # parameters
ext_modules = cythonize([bar]),
... # more parameters
)
However I have a feeling that the name of setup()
suggests it shall be called only once. Is it safe to call it several times like I do?
I can not just distribute wheels because the package shall be available also for Linux users.
[EDIT]
Also I see the question as more general than dealing with compiler-dependencies. One may want to import some package (eg. sphinx
or pweave
) to preprocess the description of ones package.
The simple answer is: No. Once you call setup, it will parse the command line arguments and start doing its job.
As for
Cython
dependency,setup_requires
cannot help here. It will probably try to downloadCython
without installing. As SpotlightKid commented:According to the setuptools
and thus, not for packages like
Cython
.I think the user is responsible to install
Cython
before callingsetup.py
. If you want to provide more friendly error message, try to useThe following posts may help: