From: Gilles DAVID Date: Wed, 23 Oct 2024 09:31:01 +0000 (+0200) Subject: Installation d'un fichier salome.pth permettant d'étendre automatiquement le PYTHONPA... X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2056a22c3b986bcd0cd2c8cb583d7e2040ff7587;p=modules%2Fkernel.git Installation d'un fichier salome.pth permettant d'étendre automatiquement le PYTHONPATH vers lib/pythonX.Y/site-packages/salome --- diff --git a/src/KERNEL_PY/CMakeLists.txt b/src/KERNEL_PY/CMakeLists.txt index e9cc0213c..dd166e8c4 100644 --- a/src/KERNEL_PY/CMakeLists.txt +++ b/src/KERNEL_PY/CMakeLists.txt @@ -43,4 +43,8 @@ SET(salomepython_PYTHON ) SALOME_INSTALL_SCRIPTS("${salomepython_PYTHON}" ${SALOME_INSTALL_PYTHON} DEF_PERMS) -SALOME_INSTALL_SCRIPTS(__init__.py ${SALOME_INSTALL_PYTHON}/salome DEF_PERMS) \ No newline at end of file +SALOME_INSTALL_SCRIPTS(__init__.py ${SALOME_INSTALL_PYTHON}/salome DEF_PERMS) +# /!\ Order of next 2 lines is important +# because salome.pth file needs salome_pth.py +SALOME_INSTALL_SCRIPTS(salome_pth.py ${_pydir} DEF_PERMS) +install(FILES salome.pth DESTINATION ${_pydir}) diff --git a/src/KERNEL_PY/salome.pth b/src/KERNEL_PY/salome.pth new file mode 100644 index 000000000..7f3b8b028 --- /dev/null +++ b/src/KERNEL_PY/salome.pth @@ -0,0 +1 @@ +import salome_pth \ No newline at end of file diff --git a/src/KERNEL_PY/salome_pth.py b/src/KERNEL_PY/salome_pth.py new file mode 100644 index 000000000..c53702234 --- /dev/null +++ b/src/KERNEL_PY/salome_pth.py @@ -0,0 +1,6 @@ +"""Append salome prefix to sys.path.""" +import sys +from pathlib import Path + +SALOME_PREFIX = "salome" +sys.path.append(f"{Path(__file__).parent / SALOME_PREFIX}")