pyradiomics
pyradiomics copied to clipboard
[BUG] numpy required in setup.py
Describe the bug Module numpy is imported in setup.py. This causes "pip install pyradiomics" to fail if numpy is not yet installed. The issue implies that pyradiomics can not be listed as a project dependency in requirements.txt together with numpy, but numpy must be previously installed. This is e.g. the case of fresh installations.
PyRadiomics configuration Default - no customization.
PyRadiomics log file None
To Reproduce "pip install pyradiomics" from a fresh environment with no numpy installed.
Expected behavior Numpy should be pulled as dependency when installing pyradiomics and not halting the installation.
Version (please complete the following information): Python 3.8 under Ubuntu 20.04, pyradiomics 3.0.1
Additional context None
It seems to be a common problem of packages depending on numpy.
There probably is a proper fix to this type of dependency issues, apparently addressed with PEP 518; an example is here: https://github.com/SciTools/cartopy/issues/1112#issuecomment-418400367 Could the same apply to pyradiomics?
This is indeed the case, though it only applies to the case where PyRadiomics needs to be built from source (for pre-distributed wheels, setup.py is not executed on install, but rather when the wheel is built).
PyRadiomics needs numpy to be installed, as the C-headers are needed to compile the C-extensions.
The suggestion in your second comment may help, but as mentioned in that thread, can cause some unexpected behaviour (like pip re-installing numpy if it's already installed). This has the potential to break stuff in special environments (like 3D slicer), so I don't wan't to add it to PyRadiomics just yet.
We did, however, add a 'setup-requires.txt' file which is also passed in the setup function. The problem is that setup.py
tries to import numpy, and therefore does not have the chance to indicate numpy should be installed first.
I'll run some tests to see if I can fix this problem in some other way.
This is falling on my feet in a project that I am working on, i.e. my CI pipelines crashes when including pyradiomics.
In other words: I'd like to install pyradiomics
through pip+requirements.txt
with python 3.9, but the numpy problem holds me back.
I see on pypi that wheels for python 3.7 are available. But your setup.py
suggests compatibility for up to 3.6 only. This confuses me a bit.
What is your timeline including more python versions?
PEP 518 addresses how dependencies are installed for building the sdist and wheel packages that are ultimately pushed to PyPI. As far as I can tell, it doesn't quite help with the setup_requires
dilemma during pip install
. I've opened PR #761 which should work around the issue by deferring the import until the second pass of setup.py
(after the setup requirements have actually been installed).
It is now impossible to install pyradiomics
properly using poetry
. See https://github.com/python-poetry/poetry/issues/6484#issuecomment-1243720822
Can't install pyradiomics in a virtual environment (python 3.11) even with previousy installed numpy. Still complains that it there is no numpy