diff --git a/cmake/python_binding.cmake b/cmake/python_binding.cmake index ed2101c..0d9d22e 100644 --- a/cmake/python_binding.cmake +++ b/cmake/python_binding.cmake @@ -1,33 +1,18 @@ -# Version 0.7 (26/11/24, support Python 2/Python 3, répertoire d'installation des modules python fourni par le python utilisé) - -# On utilise Python 3 sauf si python 2 est demandé +# Version 0.8 (03/12/24, Python > 3.10, répertoire d'installation des modules python fourni par le python utilisé) include (GNUInstallDirs) -find_package (SWIG 3 REQUIRED) +find_package (SWIG 4 REQUIRED) -#find_package (Python REQUIRED COMPONENTS Interpreter Development) # Rem : Python3 a la priorité => inutilisé car empêche l'accès à Python2 -if (USE_PYTHON_2) - message (STATUS "========================================= UTILISATION DE PYTHON 2 =========================================") - find_package (Python2 REQUIRED COMPONENTS Interpreter Development) - set (Python_INCLUDE_DIRS ${Python2_INCLUDE_DIRS}) - set (Python_EXECUTABLE ${Python2_EXECUTABLE}) - set (Python_VERSION ${Python2_VERSION}) - set (Python_LIBRARIES ${Python2_LIBRARIES}) - set (Python_LIBRARY_DIRS ${Python2_LIBRARY_DIRS}) - set (PYTHON_MAJOR_VERSION 2) -else ( ) - message (STATUS "========================================= UTILISATION DE PYTHON 3 =========================================") - set (USE_PYTHON_3 ON) - set (Python3_FIND_STRATEGY LOCATION) # Nécessaire pour python >= 3.10 - find_package (Python3 REQUIRED COMPONENTS Interpreter Development) - set (Python_INCLUDE_DIRS ${Python3_INCLUDE_DIRS}) - set (Python_EXECUTABLE ${Python3_EXECUTABLE}) - set (Python_VERSION ${Python3_VERSION}) - set (Python_LIBRARIES ${Python3_LIBRARIES}) - set (Python_LIBRARY_DIRS ${Python3_LIBRARY_DIRS}) - set (PYTHON_MAJOR_VERSION 3) -endif (USE_PYTHON_2) +message (STATUS "========================================= UTILISATION DE PYTHON 3 =========================================") +set (Python3_FIND_STRATEGY LOCATION) # Nécessaire pour python >= 3.10 +find_package (Python3 REQUIRED COMPONENTS Interpreter Development) +set (Python_INCLUDE_DIRS ${Python3_INCLUDE_DIRS}) +set (Python_EXECUTABLE ${Python3_EXECUTABLE}) +set (Python_VERSION ${Python3_VERSION}) +set (Python_LIBRARIES ${Python3_LIBRARIES}) +set (Python_LIBRARY_DIRS ${Python3_LIBRARY_DIRS}) +set (PYTHON_MAJOR_VERSION 3) # Recherche du répertoire d'installation des modules (procédure spack organizer) : @@ -44,12 +29,12 @@ macro (_set_from_python outvar python_code) endif ( ) endmacro ( ) -if (USE_PYTHON_3) # ATTENTION, ne marche peut être pas pour 3.0 <= python < 3.12. Le cas échéant la commande du else doit convenir. - _set_from_python (_GET_PYTHON_SITEARCH "import os, sys, sysconfig; sitepackages=os.path.relpath (sysconfig.get_path('platlib'), sys.base_prefix); sys.stdout.write (sitepackages)") -else (USE_PYTHON_3) - _set_from_python (_GET_PYTHON_SITEARCH "import sys; from distutils import sysconfig; sys.stdout.write (sysconfig.get_python_lib (plat_specific=True, standard_lib=False, prefix=''))") -endif (USE_PYTHON_3) - +# REM : en l'état actuel, sous ubuntu/debian, et avec un python installé dans le système, le répertoire est du type local/lib/python3.12/dist-packages +# => installer un python dans /opt, ou utiliser un venv (mais pose problème avec omniidl ...). +_set_from_python( + _GET_PYTHON_SITEARCH + "import sysconfig; print(sysconfig.get_path('platlib', vars=dict(base='', platbase='', prefix='')).lstrip('/\/\/\/\'))" +) set (PYTHON_BINDING_DIR ${_GET_PYTHON_SITEARCH}) set (CMAKE_PYTHON_RPATH_DIR ${CMAKE_INSTALL_PREFIX}/${_GET_PYTHON_SITEARCH}) diff --git a/cmake/version.cmake b/cmake/version.cmake index 5eff441..bf7d368 100644 --- a/cmake/version.cmake +++ b/cmake/version.cmake @@ -4,7 +4,7 @@ set (LIMA_MAJOR_VERSION "7") set (LIMA_MINOR_VERSION "11") -set (LIMA_RELEASE_VERSION "1") +set (LIMA_RELEASE_VERSION "2") set (LIMA_VERSION ${LIMA_MAJOR_VERSION}.${LIMA_MINOR_VERSION}.${LIMA_RELEASE_VERSION}) diff --git a/installation.txt b/installation.txt index ce5acb0..0d07ae0 100644 --- a/installation.txt +++ b/installation.txt @@ -2,7 +2,7 @@ # INSTALLATION DE LA BIBLIOTHEQUE Lima++ # -Elle requiert une version supérieure ou égale à la version 3.20.0 de cmake. La version 3.24.2 est recommandée si le choix du python utilisé est important. +Elle requiert une version supérieure ou égale à la version 3.20.0 de cmake (version >= 3.24.2 recommandée). CONFIGURATION DE BASE : lecteurs mali mli mli2 ideas gibi castem modulef [icemcfd] dyna2d dyna3d abaqus @@ -22,7 +22,7 @@ cmake -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++ -DCMAKE_ -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_VERBOSE_MAKEFILE=ON -DBUILD_XLMLIMA=ON -DBUILD_TESTS:BOOL=ON -DBUILD_SCRIPTING:BOOL=ON -DMACHINE_TYPES:BOOL=OFF -DSUMESH:BOOL=OFF -DFORMAT_MLI:BOOL=OFF -DFORMAT_MLI2:BOOL=ON -DFORMAT_MLI2:BOOL=ON \ -DBUILD_SHARED_LIBS:BOOL=ON -DINT_8:BOOL=ON -DREAL_8:BOOL=ON \ -DSWIG_EXECUTABLE=/opt/swig/4.1.1/bin/swig -DPython3_ROOT_DIR=/usr/lib/python3 -DHDF5_ROOT=/opt/HDF5/1.12.0 \ - -B /tmp/lima_build_dir -DCMAKE_INSTALL_PREFIX=/opt/Lima/7.11.1 + -B /tmp/lima_build_dir -DCMAKE_INSTALL_PREFIX=/opt/Lima/7.11.2 cmake --build /tmp/lima_build_dir cmake --install /tmp/lima_build_dir @@ -32,7 +32,7 @@ cmake -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++ -DCMAKE_ -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_VERBOSE_MAKEFILE=ON -DBUILD_XLMLIMA=ON -DBUILD_TESTS:BOOL=ON -DBUILD_SCRIPTING:BOOL=ON -DMACHINE_TYPES:BOOL=ON -DSUMESH:BOOL=ON -DFORMAT_MLI:BOOL=ON -DFORMAT_MLI2:BOOL=ON \ -DBUILD_SHARED_LIBS:BOOL=ON -DINT_8:BOOL=ON -DREAL_8:BOOL=ON \ -DSWIG_EXECUTABLE=/opt/swig/4.1.1/bin/swig -DPython3_ROOT_DIR=/usr/lib/python3 -DHDF5_ROOT=/opt/HDF5/1.12.0 -DHDF145_INCLUDE_DIR=/opt/hdf145/1.3.0/include -DHDF145CPP_LIBRARY=/opt/hdf145/1.3.0/lib/libhdf145_cpp.so -DHDF145_LIBRARY=/opt/hdf145/1.3.0/lib/libhdf145.so \ - -B /tmp/lima_build_dir -DCMAKE_INSTALL_PREFIX=/opt/Lima/7.11.1 + -B /tmp/lima_build_dir -DCMAKE_INSTALL_PREFIX=/opt/Lima/7.11.2 cmake --build /tmp/lima_build_dir cmake --install /tmp/lima_build_dir @@ -85,24 +85,14 @@ target_link_libraries (code_fortran PUBLIC Lima::Lima Lima::lima_fortran_compile Le script build.sh et les fichiers du répertoire configurations - à adapter - permettent d'installer lima à moindre coût. -BINDINGS PYTHON 2/3 : -===================== +BINDINGS PYTHON 3 : +=================== -Pour avoir un binding python il faut en plus utiliser la directive cmake -DBUILD_SCRIPTING=ON et affecter la variable SWIG_EXECUTABLE. - -A noter que si cmake croise sur son chemin une version 3 de python celle-ci sera retenue, même si python 2 est demandé et renseigné. C'est -pour cette raison que la directive find_package (Python VERSION) n'est pas utilisée dans les fichiers cmake. - -Une version récente de cmake (ex : 3.24) est recommandée afin de s'assurer que le Python utilisé correspond bien à celui demandé (Python2_ROOT_DIR ou Python3_ROOT_DIR). +A partir de la version 7.11.2 le binding python 2 n'est plus supporté. +Pour avoir un binding python il faut en plus utiliser la directive cmake -DBUILD_SCRIPTING=ON et affecter la variable SWIG_EXECUTABLE. -Binding python 2 : ------------------- - -Affecter Python2_ROOT_DIR (testé avec swig v 3.0.12/Python 2.7.*) - -Binding python 3 : -------------------- +Une version récente de cmake (ex : 3.24) est recommandée afin de s'assurer que le Python utilisé correspond bien à celui demandé (Python3_ROOT_DIR). Affecter Python3_ROOT_DIR (testé avec swig v 3.0.12/Python 3.7.3).