LSSTDESC / CCL

DESC Core Cosmology Library: cosmology routines with validated numerical accuracy
BSD 3-Clause "New" or "Revised" License
144 stars 64 forks source link

FindNumpy Error when Installing with Poetry #1180

Open shreyasc30 opened 4 months ago

shreyasc30 commented 4 months ago

Hello, I have verified that I have numpy and cmake installed and am able to get a working version with pip, but I'm getting the following error specifically when I try to install with Poetry, which I have to use, and I've tried multiple versions of CMake and Numpy to no avail:

CMake Error at cmake/Modules/FindNumPy.cmake:70 (list): list GET given empty list Call Stack (most recent call first): pyccl/CMakeLists.txt:9 (find_package)

CMake Error at cmake/Modules/FindNumPy.cmake:71 (list): list GET given empty list Call Stack (most recent call first): pyccl/CMakeLists.txt:9 (find_package)

CMake Error at cmake/Modules/FindNumPy.cmake:74 (string): string sub-command REGEX, mode REPLACE needs at least 6 arguments total to command. Call Stack (most recent call first): pyccl/CMakeLists.txt:9 (find_package)

CMake Error at cmake/Modules/FindNumPy.cmake:77 (string): string sub-command REGEX, mode REPLACE needs at least 6 arguments total to command. Call Stack (most recent call first): pyccl/CMakeLists.txt:9 (find_package)

CMake Error at cmake/Modules/FindNumPy.cmake:81 (string): string sub-command REGEX, mode MATCH regex "[0-9]*" matched an empty string. Call Stack (most recent call first): pyccl/CMakeLists.txt:9 (find_package)

CMake Error at cmake/Modules/FindNumPy.cmake:82 (math): math cannot parse the expression: "(NOTFOUND 10000) + (NOTFOUND 100) + NOTFOUND": syntax error, unexpected exp_TIMES (11). Call Stack (most recent call first): pyccl/CMakeLists.txt:9 (find_package) ... ... -- Configuring incomplete, errors occurred! Traceback (most recent call last): File "/home/shreyasc/poetryenv/lib/python3.10/site-packages/pyproject_hooks/_in_process/_in_process.py", line 353, in main() File "/home/shreyasc/poetryenv/lib/python3.10/site-packages/pyproject_hooks/_in_process/_in_process.py", line 335, in main json_out['return_val'] = hook(hook_input['kwargs']) File "/home/shreyasc/poetryenv/lib/python3.10/site-packages/pyproject_hooks/_in_process/_in_process.py", line 251, in build_wheel return _build_backend().build_wheel(wheel_directory, config_settings, File "/tmp/tmpdpa43iue/.venv/lib/python3.10/site-packages/setuptools/build_meta.py", line 410, in build_wheel return self._build_with_temp_dir( File "/tmp/tmpdpa43iue/.venv/lib/python3.10/site-packages/setuptools/build_meta.py", line 395, in _build_with_temp_dir self.run_setup() File "/tmp/tmpdpa43iue/.venv/lib/python3.10/site-packages/setuptools/build_meta.py", line 487, in run_setup super().run_setup(setup_script=setup_script) File "/tmp/tmpdpa43iue/.venv/lib/python3.10/site-packages/setuptools/build_meta.py", line 311, in run_setup exec(code, locals()) File "", line 82, in File "/tmp/tmpdpa43iue/.venv/lib/python3.10/site-packages/setuptools/init.py", line 104, in setup return distutils.core.setup(attrs) File "/tmp/tmpdpa43iue/.venv/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 184, in setup return run_commands(dist) File "/tmp/tmpdpa43iue/.venv/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 200, in run_commands dist.run_commands() File "/tmp/tmpdpa43iue/.venv/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands self.run_command(cmd) File "/tmp/tmpdpa43iue/.venv/lib/python3.10/site-packages/setuptools/dist.py", line 967, in run_command super().run_command(command) File "/tmp/tmpdpa43iue/.venv/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 988, in run_command cmd_obj.run() File "/tmp/tmpdpa43iue/.venv/lib/python3.10/site-packages/wheel/bdist_wheel.py", line 368, in run self.run_command("build") File "/tmp/tmpdpa43iue/.venv/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 316, in run_command self.distribution.run_command(command) File "/tmp/tmpdpa43iue/.venv/lib/python3.10/site-packages/setuptools/dist.py", line 967, in run_command super().run_command(command) File "/tmp/tmpdpa43iue/.venv/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 988, in run_command cmd_obj.run() File "/tmp/tmpdpa43iue/.venv/lib/python3.10/site-packages/setuptools/_distutils/command/build.py", line 132, in run self.run_command(cmd_name) File "/tmp/tmpdpa43iue/.venv/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 316, in run_command self.distribution.run_command(command) File "/tmp/tmpdpa43iue/.venv/lib/python3.10/site-packages/setuptools/dist.py", line 967, in run_command super().run_command(command) File "/tmp/tmpdpa43iue/.venv/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 988, in run_command cmd_obj.run() File "", line 56, in run File "", line 22, in _compile_ccl Exception: Could not run CMake configuration. Make sure CMake is installed !

Thanks in advance, any help is appreciated!

damonge commented 3 months ago

@shreyasc30 I've been able to reproduce this, and the solution for me was: a) Make sure cmake is able to find python. For this, try inserting the following before line 70 of cmake/Modules/FindNumPy.cmake:

include(CMakePrintHelpers)

cmake_print_variables(PYTHON_EXECUTABLE)

and see what the output is. Check if the corresponding path to the python executable is actually correct.

b) Make sure numpy is installed.

I would suggest removing everything under build and dist before trying to reinstall.

johannesulf commented 1 month ago

I'm having the exact same problem with a pretty vanilla install of Fedora 40. For me, even the installation with pip doesn't work. I looked at cmake/Modules/FindNumPy.cmake and modified it a bit to look at the different variables. PYTHON_EXECUTABLE is set correctly. Additionally, I can execute the command that gets called in line 52 in my terminal and it responds with the numpy version and location, as expected. But in the script, _NUMPY_ERROR_VALUE includes No module named 'numpy'. So for some reason, the command "${PYTHON_EXECUTABLE}" "-c" "import numpy as n; print(n.__version__); print(n.get_include());" finds numpy in my terminal but not in the cmake script. Any ideas what the reason could be?