somoclu icon indicating copy to clipboard operation
somoclu copied to clipboard

Numpy requirement in setup.py

Open yanzastro opened this issue 2 years ago • 5 comments

I'm trying to use somoclu in a project. When I make a PR of my project to a github repo, it failed the codecov test and the readthedoc build because to install somoclu I need numpy in the first place (as there is a line import numpy in the setup.py file of somoclu)

This is not a problem of somoclu itself, but that codecov and Read the Docs do not have numpy. I'm wondering if any small modification could be made to handle this problem? Thanks in advance!

yanzastro avatar Sep 27 '22 16:09 yanzastro

Cannot add deps first? https://github.com/codecov/example-python/actions/runs/2456178653/workflow

xgdgsc avatar Sep 28 '22 01:09 xgdgsc

Thanks for your reply! We tried to modify workflow and codecov works fine now, but read-the-docs still raises an error:

Collecting numpy
  Downloading numpy-1.23.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (17.1 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 17.1/17.1 MB 77.3 MB/s eta 0:00:00
Requirement already satisfied: sphinx in /home/docs/checkouts/readthedocs.org/user_builds/my/project/lib/python3.9/site-packages (from -r docs/requirements.txt (line 5)) (5.2.2)
...
Collecting somoclu
  Downloading somoclu-1.7.5.1.tar.gz (6.1 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 6.1/6.1 MB 154.0 MB/s eta 0:00:00
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'error'
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [6 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-yjrktktm/somoclu_f38134a40b7747e6a0372e4bc55abcef/setup.py", line 4, in <module>
          import numpy
      ModuleNotFoundError: No module named 'numpy'
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

We are confused since numpy is explicitly included in our requirements.txt, and the build also installed numpy before somoclu (please see the error message above)...

yanzastro avatar Sep 28 '22 09:09 yanzastro

https://github.com/readthedocs/readthedocs.org/issues/1639#issuecomment-139237619

xgdgsc avatar Sep 28 '22 09:09 xgdgsc

This issue is keeping us from being able to use somoclu. We are not able to install numpy first (Databricks Model Serving).

@yanzastro Did you perhaps find a solution?

Tesax123 avatar Dec 08 '23 09:12 Tesax123

As I see it the issue could be avoided if wheels were uploaded of somoclu to pypi. Other solution is adding a pyproject.toml file next to setup.py with the contents:

[build-system]
# Minimum requirements for the build system to execute.
requires = ["setuptools", "wheel", "numpy"]  # PEP 508 specifications.

I.e. numpy is explicitly added to the required packages for building. I have not tested these changes but something similar should work.

nialov avatar Dec 20 '23 11:12 nialov