cmake: use cmake to install the python code via 'pip install' instead of configure + fixes to pass on MacOSX
pip install
- Remove the
setup.pybased onconfigure - Rewrite the
pyproject.tomlto use CMake via thepy-build-cmakeAPI : https://tttapa.github.io/py-build-cmake/index.html
Note: I can rewrite a setup.py for cmake if needed, but this ways looks closer to what is recommanded now for python packages.
Installation:
pip install .
If want to have OpenMP support on MacOSX, beed to edit pyproject.toml and replace gcc by gcc-XX in field option.
-options = {"USE_CUDA" = "AUTO", "USE_OPENMP" = "AUTO", "USE_SHARED" = "OFF", "BUILD_FOR_PYTHON" = "ON", "CMAKE_C_COMPILER" = "gcc"}
+options = {"USE_CUDA" = "AUTO", "USE_OPENMP" = "ON", "USE_SHARED" = "OFF", "BUILD_FOR_PYTHON" = "ON", "CMAKE_C_COMPILER" = "gcc-15"}
Technical detail
When doing pip install it calls cmake which is responsible of search python / fftw / cuda / openmp and to build the python shtns lib. (in other words, everything which is C is handled by cmake, the py is handle by pip.
py-build-cmake create a .py-build-cmake_cache directory in the sources in which it builds in. In case of troubles we can remove it.
note: When cmake-3.24 will be common on most systems we can add --fresh to the cmake options. But there is still cmake-22 on ubuntu:22.04 and cmake-18 on some clusters (eg. gricad with debian-11).
MacOSX
Change some behavior of the CMake script
- Make open as
-DUSE_OPENMP=AUTOby default - On MacOSX, it disabled openmp as not found with gcc
- Can be re-enabled by giving
-DCMAKE_C_COMPILER=gcc-XX
Question : to be seen if we make AUTO or ON for the default build of SHTns (eq. if we prefer to have an error and disable by hand or get running build by default => but slower).
Also fix some flags issues by making them optional and detect if we can enable them (as in xshells).
problem
There was a problem with this line on MacOSX, in principe this is fixed in this patch but need a mac to validate.
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^armv7|arm64|ARM64|aarch64")