cgohlke / imagecodecs

Image transformation, compression, and decompression codecs
https://pypi.org/project/imagecodecs
BSD 3-Clause "New" or "Revised" License
111 stars 21 forks source link

Numpy Missing During Setuptools #36

Closed John-P closed 2 years ago

John-P commented 2 years ago

Hi there, I am having an issue where sometimes setuptools is running the finalize_options function but numpy is not installed yet:

...
File "/opt/python/3.7.1/lib/python3.7/distutils/cmd.py", line 107, in ensure_finalized
        self.finalize_options()
File "/tmp/pip-install-9ehdn6oz/imagecodecs/setup.py", line 600, in finalize_options
        import numpy
    ModuleNotFoundError: No module named 'numpy'

This appears to only happen on certain setups, perhaps just if pip tries to install imagecodecs before NumPy.

I found the recommendation to add numpy to setup_requires (see https://github.com/numpy/numpy/issues/2434) in addition to install_requires but I see that you have commented this out here https://github.com/cgohlke/imagecodecs/blob/92a8620ac300fbeb77929cfa72bf78fd74584345/setup.py#L660

I just wanted to check if there is a reason it was commented out or if you have any advice to avoid this issue? I am currently just using a regular pip install from a requirements file.

John-P commented 2 years ago

It appears that I was using python 3.7 which didn't help as you specify 3.8+. Using 3.8 and above I no longer have this issue.