Hi,
do someone manage to setup VScode to access Salome API? I mean to have acces to the prototype and docs of methods.
I cannot get Pylance to find “import salome” even when I try to add PYTHONPATH to python.analysis.extraPaths
Best
Hi,
do someone manage to setup VScode to access Salome API? I mean to have acces to the prototype and docs of methods.
I cannot get Pylance to find “import salome” even when I try to add PYTHONPATH to python.analysis.extraPaths
Best
Development concerning this is underway. In the meantime, here’s a tested solution (Ubuntu 24.04) that I use and which might help you. In addition, hovering over a method will also bring up a help pop-up…
# [APPLI variables]
. Moving to the end is needed otherwise, SALOME won’t run. #[SALOMEBOOTSTRAP]
context.setVariable(r"SALOMEBOOTSTRAP_ROOT_DIR", out_dir_Path + r"/BINARIES-UB24.04/SALOMEBOOTSTRAP", overwrite=True)
context.setVariable(r"SALOME_APPLICATION_DIR", out_dir_Path + r"/BINARIES-UB24.04/SALOMEBOOTSTRAP", overwrite=True)
context.addToPythonPath(out_dir_Path + r"/BINARIES-UB24.04/SALOMEBOOTSTRAP/__SALOME_BOOTSTRAP__")
context.addToPythonPath(out_dir_Path + r"/BINARIES-UB24.04/SALOMEBOOTSTRAP/__RUN_SALOME__/lib/salome")
context.addToLdLibraryPath(out_dir_Path + r"/BINARIES-UB24.04/SALOMEBOOTSTRAP/__RUN_SALOME__/lib/salome")
#[KERNEL]
context.setVariable(r"KERNEL_ROOT_DIR", out_dir_Path + r"/BINARIES-UB24.04/KERNEL", overwrite=True)
context.addToPath(r"${KERNEL_ROOT_DIR}/bin/salome")
context.addToLdLibraryPath(r"${KERNEL_ROOT_DIR}/lib/salome")
context.addToPythonPath(r"${KERNEL_ROOT_DIR}/bin/salome")
context.addToPythonPath(r"${KERNEL_ROOT_DIR}/lib/salome")
context.addToPythonPath(r"${KERNEL_ROOT_DIR}/${PYTHON_LIBDIR}/salome")
__init__.py
is present, if not, create it:cd SALOME-9.14.0-native-UB24.04-SRC
for d in $(find . -name salome -type d); do if [[ $(dirname $d) == *site-packages* ]]; then if [ ! -f $d/__init__.py ]; then touch $d/__init__.py; fi; fi; done
.env
file containing PYTHONPATH
PYTHONPATH=;for d in $(find . -name salome -type d); do if [[ $(dirname $d) == *site-packages* ]]; then if [ -f $d/__init__.py ]; then PYTHONPATH+="$PWD/$d:"; fi; fi; done; echo PYTHONPATH=$PYTHONPATH > .env
settings.json
(File "workbench.settings.applyToAllProfiles": ["python.envFile"], # optional
"python.envFile": "${workspaceFolder}/.env", # here you can also set a full path
We are currently investigating why this hack about moving the KERNEL section to the end is required.
HTH