SofaPython3
SofaPython3 copied to clipboard
PluginManager does not find "python3" dir
Sofa's PluginManager does not find the "python3" dir
Description The plugin Manager looks for a "python3/" dir inside the folder ../sofa/build/bin but this folder is in fact located in ../sofa/build/ . The path where the plugin manager looks for "python3/" dir is then wrong, generating an error.
Steps to reproduce
- Compile the plugin SofaPython3 in tree, as explained in the documentation of SofaPython3 (the sofapython3.dll is created inside my ../sofa/build/bin/ folder, as it should be)
- Open a terminal/command window (cmd)
- Type runSofa.exe
- Enter the "Edit>PluginManager" tab
Expected behavior The plugin SofaPython3 should have been added to my SofaEnvironment succesfully, and I should have been able to use to load Python3 scenes without doing anything more.
Environment
Context
- System: Windows 10
- Version of SOFA: v20.12 branch at commit ee7664e, v20.12.00 binaries
- State: build directory
Command called
runSofa.exe -l SofaPython3.dll
Env vars
echo "SOFA_ROOT = C:\Users\jducr\Documents\Librairies\sofa\build\bin\Release"
echo "PYTHONPATH = C:\Users\jducr\Documents\Librairies\Python\Python37"
echo "python3 -V = Python 3.7.7"
No python3 dir found in .
No python3 dir found in C:\Users\jducr\Documents\Librairies\\sofa\build\bin
Logs
Full output
Microsoft Windows [version 10.0.19043.985]
(c) Microsoft Corporation. Tous droits réservés.
C:\Users\jducr>cd C:\Users\jducr\Documents\Librairies\sofa\build\bin\Release
C:\Users\jducr\Documents\Librairies\sofa\build\bin\Release>runSofa -l SofaPython3.dll
[INFO] [runSofa] PluginRepository paths = C:/Users/jducr/Documents/Librairies/sofa/build/plugins;C:/Users/jducr/Documents/Librairies/sofa/build/bin;C:/Users/jducr/Documents/Librairies/sofa/build/bin/Release
[INFO] [runSofa] DataRepository paths = C:/Users/jducr/Documents/Librairies/sofa/src/share;C:/Users/jducr/Documents/Librairies/sofa/src/examples;C:/Users/jducr/Documents/Librairies/sofa/build;C:/Users/jducr/Documents/Librairies/sofa/build
[INFO] [runSofa] GuiDataRepository paths = C:/Users/jducr/Documents/Librairies/sofa/src/applications/projects/runSofa/resources;C:/Users/jducr/Documents/Librairies/sofa/src/modules/SofaGuiQt/src/sofa/gui/qt/resources
[INFO] [SofaPython3] Initializing with python version 3.7.7 (tags/v3.7.7:d7c567b08f, Mar 10 2020, 10:41:24) [MSC v.1900 64 bit (AMD64)]
[INFO] [SofaPython3] Registering a scene loader for [.py, .py3, .pyscn, .py3scn] files.
[INFO] [SofaPython3] Intializing python
[INFO] [SofaPython3] Added 'C:/Users/jducr/Documents/Librairies/sofa/src/applications/plugins/SofaTest/python' to sys.path
[INFO] [SofaPython3] No python3 dir found in .
########## SIG 22 - SIGABRT: usually caused by an abort() or assert() ##########
21: sofa::helper::BackTrace::dump - 0x7ffa3156a41020: sofa::helper::BackTrace::sig - 0x7ffa3156a57019: raise - 0x7ffa695816a018: abort - 0x7ffa6958282017: terminate - 0x7ffa69581f8016: terminate - 0x7ffa69581f8015: UnhandledExceptionFilter - 0x7ffa6916b6a014: memset - 0x7ffa6b973ec013: _C_specific_handler - 0x7ffa6b95c6e012: _chkstk - 0x7ffa6b97206011: RtlRaiseException - 0x7ffa6b92102010: RtlRaiseException - 0x7ffa6b9210209: RaiseException - 0x7ffa69094b208: CxxThrowException - 0x7ffa0d1b63f07: sofapython3::PythonEnvironment::Init - 0x7ffa23c737b06: initExternalModule - 0x7ffa23c6fa705: sofa::helper::system::PluginManager::loadPluginByPath - 0x7ffa316052104: sofa::helper::system::PluginManager::loadPlugin - 0x7ffa31604b603: sofa::helper::system::PluginManager::loadPlugin - 0x7ffa31604b602: sofa::helper::system::PluginManager::loadPlugin - 0x7ffa31604b601: BaseThreadInitThunk - 0x7ffa69db70200: RtlUserThreadStart - 0x7ffa6b922630[WARNING] [SofaSimulationTree] the library has not been cleaned up (sofa::simulation::tree::cleanup() has never been called, see sofa/helper/init.h)
[WARNING] [SofaSimulationGraph] the library has not been cleaned up (sofa::simulation::graph::cleanup() has never been called, see sofa/helper/init.h)
[WARNING] [SofaSimulationCore] the library has not been cleaned up (sofa::simulation::core::cleanup() has never been called, see sofa/helper/init.h)
[WARNING] [SofaCore] the library has not been cleaned up (sofa::core::cleanup() has never been called, see sofa/helper/init.h)
Content of build_dir/CMakeCache.txt
A "rough" solution consists in copying the directory sofa/build/python3 to sofa/build/bin/python3. However, a cleaner solution would be to change the path seeked by the pluginManager of Sofa for SofaPython3. @guparan , what is your opinion on that ?
Hi @jducrocq007
First, many thanks for your feedback and all the details you provided :clap:
Your issue is not related to PluginManager.
As you can see in your output, it's SofaPython3 itself that fails finding it's python modules and outputs [SofaPython3] No python3 dir found in .
You are right though, it's a path seeking issue. It was recently fixed by #190 and #192, merged in master and backported in the v21.06 branch. Moreover, we did a lot of changes lately to improve SofaPython3 initialization.
Thus, my best advice would be to upgrade your setup to SOFA v21.06 + SofaPython3 v21.06
If this is not an option for you, you can try adding C:/Users/jducr/Documents/Librairies/sofa/build/python3/site-packages
to PYTHONPATH environment variable (I did not test this option).
Also, your SOFA_ROOT should be C:\Users\jducr\Documents\Librairies\sofa\build
(aka. the root of your binaries).
Hope that helps :crossed_fingers:
Hi @guparan , I'm currently on vacations and not with a proper computer so I'll try to install Sofa 21 and SofaPython3's newest version next week. If the issue is not present on these new versions, I'll keep you in touch.
Anyways, copying the python3/ dir to the location where it should be helped me to use SofaPython3 to create my own python scenes properly, so it's not a hurry.
Thank you for your help :)