ecmwf / fckit

A Fortran toolkit for interoperating Fortran with C/C++
https://confluence.ecmwf.int/display/fckit
Apache License 2.0
29 stars 15 forks source link

Failure to detect python #17

Closed DJDavies2 closed 2 years ago

DJDavies2 commented 2 years ago

ecbuild is failing to detect python for me:

CMake Error at /research/data/d03/frwd/installs/cmake/3.19.4/v1/share/cmake-3.19/Modules/FindPackageHandleStandardArgs.cmake:218 (message): Could NOT find PythonInterp: Found unsuitable version "2.7.9", but required is at least "3.4" (found /opt/python/gnu/2.7.9/bin/python) Call Stack (most recent call first): /research/data/d03/frwd/installs/cmake/3.19.4/v1/share/cmake-3.19/Modules/FindPackageHandleStandardArgs.cmake:580 (_FPHSA_FAILURE_MESSAGE) /research/data/d03/frwd/installs/cmake/3.19.4/v1/share/cmake-3.19/Modules/FindPythonInterp.cmake:169 (FIND_PACKAGE_HANDLE_STANDARD_ARGS) /research/data/d03/frwd/installs/ecbuild/3.6.1-v1/share/ecbuild/cmake/ecbuild_find_python.cmake:94 (find_package) fckit/CMakeLists.txt:25 (ecbuild_find_python)

The system python is python 2 so I have installed python 3 in a custom location. However I don't know how to make fckit pick it up. I have set $PATH to pick up my custom python executable but that doesn't seem to be sufficient.

wdeconinck commented 2 years ago

I believe the way is to set -DPYTHON_EXECUTABLE=<path-to-python3> in the cmake command line.

DJDavies2 commented 2 years ago

Thanks, I will try that.

DJDavies2 commented 2 years ago

Hmm, I added -DPYTHON_EXECUTABLE= to the ecbuild line and the stdout says this:

-- [fckit] (0.9.5) [7ec9cf8] -- Feature TESTS enabled -- Found PythonInterp: /home/d03/frwd/cylc-run/CrayIodaFailure/work/1/build_python__lfric_cray/install/bin/python -- Configuring incomplete, errors occurred!

The stderr is the same as above. So it is finding the executable but in the error still refers to the system python. Do I need to point to a library as well?

wdeconinck commented 2 years ago

Perhaps it is time to ditch this ecbuild_find_python and use the in the mean time in CMake 3.12 introduced FindPython3, which is a safe assumption as cmake_minimum_required( VERSION 3.12 FATAL_ERROR )

find_package( Python3 REQUIRED COMPONENTS Interpreter )
set( PYTHON_EXECUTABLE ${Python3_EXECUTABLE} )  # For future use within fckit

If you can make that work, then we can go for that with a PR.

tlmquintino commented 2 years ago

yes good point. I support that direction

wdeconinck commented 2 years ago

And likely to force your python executable, then use -DPython3_EXECUTABLE=<path-to-python3>.

DJDavies2 commented 2 years ago

For what it is worth we have other projects that detect python like this:

find_package( Python3 COMPONENTS Interpreter Development )

and this does work for me, i.e. just by setting $PATH to have my custom python build in front. So I would be happy with this fix.

wdeconinck commented 2 years ago

@DJDavies2 did you manage to overcome this particular problem with the above suggestions?

DJDavies2 commented 2 years ago

I've managed to overcome this, thanks.