From 2056a22c3b986bcd0cd2c8cb583d7e2040ff7587 Mon Sep 17 00:00:00 2001 From: Gilles DAVID Date: Wed, 23 Oct 2024 11:31:01 +0200 Subject: [PATCH] =?utf8?q?Installation=20d'un=20fichier=20salome.pth=20per?= =?utf8?q?mettant=20d'=C3=A9tendre=20automatiquement=20le=20PYTHONPATH=20v?= =?utf8?q?ers=20lib/pythonX.Y/site-packages/salome?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/KERNEL_PY/CMakeLists.txt | 6 +++++- src/KERNEL_PY/salome.pth | 1 + src/KERNEL_PY/salome_pth.py | 6 ++++++ 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 src/KERNEL_PY/salome.pth create mode 100644 src/KERNEL_PY/salome_pth.py 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}") -- 2.39.2