jfowkes / pycutest

Python interface to CUTEst
https://jfowkes.github.io/pycutest/
GNU General Public License v3.0
27 stars 11 forks source link

Error finding CUTEst installation (new meson build) #89

Open AndrewLister-STFC opened 1 week ago

AndrewLister-STFC commented 1 week ago

Describe the bug I get the following error on import:

root@31fb1c5ea579:/home/fitbenchmarking# python
Python 3.12.7 (main, Oct  8 2024, 00:20:25) [Clang 18.1.8 ] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pycutest
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/venv/lib/python3.12/site-packages/pycutest/__init__.py", line 7, in <module>
    from .build_interface import import_problem, clear_cache, all_cached_problems
  File "/opt/venv/lib/python3.12/site-packages/pycutest/build_interface.py", line 13, in <module>
    from .install_scripts import get_setup_script
  File "/opt/venv/lib/python3.12/site-packages/pycutest/install_scripts.py", line 95, in <module>
    """ % get_cutest_path()  # will probably get the homebrew location, but may revert to environment variables
          ^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.12/site-packages/pycutest/system_paths.py", line 49, in get_cutest_path
    raise RuntimeError('Could not find CUTEST installation - have CUTEST and MYARCH environment variables been set correctly?')
RuntimeError: Could not find CUTEST installation - have CUTEST and MYARCH environment variables been set correctly?

I have installed CUTEst using the meson build system, so the path is not at the expected location:

$CUTEST/objects/$MYARCH/double/libcutest.a

and is instead installed and on the standard path

ls /usr/local/lib/libcutest_*
/usr/local/lib/libcutest_double.a  /usr/local/lib/libcutest_single.a

To Reproduce I built CUTEst as part of a container here. (I plan to update SIFDecode to the meson build too).

Information about your installation:

jfowkes commented 4 days ago

@lindonroberts I guess we should now also check the standard /usr/local/lib/ path? This is so that we can also support the newly released CUTEst meson installer that installs to /usr/local/lib/ by default. The old makefile based CUTEst installer still uses the path that we currently have so we should probably retain it for now.

lindonroberts commented 3 days ago

@jfowkes that makes sense to me. So the new meson installer just puts everything in a standard location and doesn't set the environment variables? Is it the same default path for Mac and Linux?

jfowkes commented 3 days ago

@lindonroberts good question, the meson docs are rather vague on the specifics:

There is usually no need to specify install paths or the like. Meson will automatically install to the standards-conforming location.

I'll do some testing and see what the default Mac and Linux install locations are (for both CUTEst and SIFDecode).

AndrewLister-STFC commented 3 days ago

You can add a prefix when you set up the meson build to give it a custom install directory. It might be enough to check for existence on the PATH env var?

Would something like this do the job?

import pathlib
import os
cutest_double_path = None
for p in os.environ["PATH"].split(":"):
    candidate = pathlib.Path(p)/'libcutest_double.so'
    if candidate.exists():
        cutest_path = candidate
        break
jfowkes commented 3 days ago

@AndrewLister-STFC no because /usr/local/lib/ is not on PATH (path is for binaries not libraries). It is sometimes on LD_LIBRARY_PATH on Linux but this is not guaranteed, especially on Mac.

jfowkes commented 1 day ago

@lindonroberts after some testing here are the default meson install directories (for SIFDecode and CUTEst):

Linux

/usr/local/lib/
/usr/local/bin/

macOS (Silicon)

/opt/homebrew/lib/
/opt/homebrew/bin/

It looks like we already have the macOS paths so we just need to add the local Linux paths.