]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Installation d'un fichier salome.pth permettant d'étendre automatiquement le PYTHONPA...
authorGilles DAVID <gilles-g.david@edf.fr>
Wed, 23 Oct 2024 09:31:01 +0000 (11:31 +0200)
committerGilles DAVID <gilles-g.david@edf.fr>
Sat, 26 Oct 2024 11:07:20 +0000 (13:07 +0200)
src/KERNEL_PY/CMakeLists.txt
src/KERNEL_PY/salome.pth [new file with mode: 0644]
src/KERNEL_PY/salome_pth.py [new file with mode: 0644]

index e9cc0213c43e7b556f0605809ff1357ac3d87afb..dd166e8c4acdaf10c517738563cb3a5d69e13d65 100644 (file)
@@ -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 (file)
index 0000000..7f3b8b0
--- /dev/null
@@ -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 (file)
index 0000000..c537022
--- /dev/null
@@ -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}")