Skip to content

Commit 2264e15

Browse files
Merge pull request #16 from LIHPC-Computational-Geometry/nopython2
Nopython2
2 parents 1368684 + f92d2e2 commit 2264e15

File tree

3 files changed

+26
-51
lines changed

3 files changed

+26
-51
lines changed

cmake/python_binding.cmake

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,18 @@
1-
# Version 0.7 (26/11/24, support Python 2/Python 3, répertoire d'installation des modules python fourni par le python utilisé)
2-
3-
# On utilise Python 3 sauf si python 2 est demandé
1+
# Version 0.8 (03/12/24, Python > 3.10, répertoire d'installation des modules python fourni par le python utilisé)
42

53
include (GNUInstallDirs)
6-
find_package (SWIG 3 REQUIRED)
4+
find_package (SWIG 4 REQUIRED)
75

86

9-
#find_package (Python REQUIRED COMPONENTS Interpreter Development) # Rem : Python3 a la priorité => inutilisé car empêche l'accès à Python2
10-
if (USE_PYTHON_2)
11-
message (STATUS "========================================= UTILISATION DE PYTHON 2 =========================================")
12-
find_package (Python2 REQUIRED COMPONENTS Interpreter Development)
13-
set (Python_INCLUDE_DIRS ${Python2_INCLUDE_DIRS})
14-
set (Python_EXECUTABLE ${Python2_EXECUTABLE})
15-
set (Python_VERSION ${Python2_VERSION})
16-
set (Python_LIBRARIES ${Python2_LIBRARIES})
17-
set (Python_LIBRARY_DIRS ${Python2_LIBRARY_DIRS})
18-
set (PYTHON_MAJOR_VERSION 2)
19-
else ( )
20-
message (STATUS "========================================= UTILISATION DE PYTHON 3 =========================================")
21-
set (USE_PYTHON_3 ON)
22-
set (Python3_FIND_STRATEGY LOCATION) # Nécessaire pour python >= 3.10
23-
find_package (Python3 REQUIRED COMPONENTS Interpreter Development)
24-
set (Python_INCLUDE_DIRS ${Python3_INCLUDE_DIRS})
25-
set (Python_EXECUTABLE ${Python3_EXECUTABLE})
26-
set (Python_VERSION ${Python3_VERSION})
27-
set (Python_LIBRARIES ${Python3_LIBRARIES})
28-
set (Python_LIBRARY_DIRS ${Python3_LIBRARY_DIRS})
29-
set (PYTHON_MAJOR_VERSION 3)
30-
endif (USE_PYTHON_2)
7+
message (STATUS "========================================= UTILISATION DE PYTHON 3 =========================================")
8+
set (Python3_FIND_STRATEGY LOCATION) # Nécessaire pour python >= 3.10
9+
find_package (Python3 REQUIRED COMPONENTS Interpreter Development)
10+
set (Python_INCLUDE_DIRS ${Python3_INCLUDE_DIRS})
11+
set (Python_EXECUTABLE ${Python3_EXECUTABLE})
12+
set (Python_VERSION ${Python3_VERSION})
13+
set (Python_LIBRARIES ${Python3_LIBRARIES})
14+
set (Python_LIBRARY_DIRS ${Python3_LIBRARY_DIRS})
15+
set (PYTHON_MAJOR_VERSION 3)
3116

3217

3318
# Recherche du répertoire d'installation des modules (procédure spack organizer) :
@@ -44,12 +29,12 @@ macro (_set_from_python outvar python_code)
4429
endif ( )
4530
endmacro ( )
4631

47-
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.
48-
_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)")
49-
else (USE_PYTHON_3)
50-
_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=''))")
51-
endif (USE_PYTHON_3)
52-
32+
# 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
33+
# => installer un python dans /opt, ou utiliser un venv (mais pose problème avec omniidl ...).
34+
_set_from_python(
35+
_GET_PYTHON_SITEARCH
36+
"import sysconfig; print(sysconfig.get_path('platlib', vars=dict(base='', platbase='', prefix='')).lstrip('/\/\/\/\'))"
37+
)
5338
set (PYTHON_BINDING_DIR ${_GET_PYTHON_SITEARCH})
5439
set (CMAKE_PYTHON_RPATH_DIR ${CMAKE_INSTALL_PREFIX}/${_GET_PYTHON_SITEARCH})
5540

cmake/version.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
set (LIMA_MAJOR_VERSION "7")
66
set (LIMA_MINOR_VERSION "11")
7-
set (LIMA_RELEASE_VERSION "1")
7+
set (LIMA_RELEASE_VERSION "2")
88
set (LIMA_VERSION ${LIMA_MAJOR_VERSION}.${LIMA_MINOR_VERSION}.${LIMA_RELEASE_VERSION})
99

1010

installation.txt

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# INSTALLATION DE LA BIBLIOTHEQUE Lima++
33
#
44

5-
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.
5+
Elle requiert une version supérieure ou égale à la version 3.20.0 de cmake (version >= 3.24.2 recommandée).
66

77

88
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_
2222
-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 \
2323
-DBUILD_SHARED_LIBS:BOOL=ON -DINT_8:BOOL=ON -DREAL_8:BOOL=ON \
2424
-DSWIG_EXECUTABLE=/opt/swig/4.1.1/bin/swig -DPython3_ROOT_DIR=/usr/lib/python3 -DHDF5_ROOT=/opt/HDF5/1.12.0 \
25-
-B /tmp/lima_build_dir -DCMAKE_INSTALL_PREFIX=/opt/Lima/7.11.1
25+
-B /tmp/lima_build_dir -DCMAKE_INSTALL_PREFIX=/opt/Lima/7.11.2
2626
cmake --build /tmp/lima_build_dir
2727
cmake --install /tmp/lima_build_dir
2828

@@ -32,7 +32,7 @@ cmake -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++ -DCMAKE_
3232
-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 \
3333
-DBUILD_SHARED_LIBS:BOOL=ON -DINT_8:BOOL=ON -DREAL_8:BOOL=ON \
3434
-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 \
35-
-B /tmp/lima_build_dir -DCMAKE_INSTALL_PREFIX=/opt/Lima/7.11.1
35+
-B /tmp/lima_build_dir -DCMAKE_INSTALL_PREFIX=/opt/Lima/7.11.2
3636
cmake --build /tmp/lima_build_dir
3737
cmake --install /tmp/lima_build_dir
3838

@@ -85,24 +85,14 @@ target_link_libraries (code_fortran PUBLIC Lima::Lima Lima::lima_fortran_compile
8585
Le script build.sh et les fichiers du répertoire configurations - à adapter - permettent d'installer lima à moindre coût.
8686

8787

88-
BINDINGS PYTHON 2/3 :
89-
=====================
88+
BINDINGS PYTHON 3 :
89+
===================
9090

91-
Pour avoir un binding python il faut en plus utiliser la directive cmake -DBUILD_SCRIPTING=ON et affecter la variable SWIG_EXECUTABLE.
92-
93-
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
94-
pour cette raison que la directive find_package (Python VERSION) n'est pas utilisée dans les fichiers cmake.
95-
96-
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).
91+
A partir de la version 7.11.2 le binding python 2 n'est plus supporté.
9792

93+
Pour avoir un binding python il faut en plus utiliser la directive cmake -DBUILD_SCRIPTING=ON et affecter la variable SWIG_EXECUTABLE.
9894

99-
Binding python 2 :
100-
------------------
101-
102-
Affecter Python2_ROOT_DIR (testé avec swig v 3.0.12/Python 2.7.*)
103-
104-
Binding python 3 :
105-
-------------------
95+
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).
10696

10797
Affecter Python3_ROOT_DIR (testé avec swig v 3.0.12/Python 3.7.3).
10898

0 commit comments

Comments
 (0)