-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Out-of-tree builds can't find lib SofaComponentGeneral #137
Comments
You need to add I added it to my PR #136 as a quick fix |
Hi Pho, |
Hi Damien, |
Hi Pho, @damienmarchal is right, you will need to build the development version of SOFA as SofaPython3 is still isn't released yet. Before starting, let's define some environment variables that will help us: $ export SOFA_SRC=$HOME/sources/sofa
$ export SOFA_BLD=$HOME/sources/sofa/build Here You can do the same thing for SofaPython3 source code and built directories. $ export SP3_SRC=$HOME/sources/plugin.SofaPython3
$ export SP3_BLD=$HOME/sources/plugin.SofaPython3/build (Make sure those paths are good) 1. Building the development version of SOFACheckout the master branch of sofa and build it $ cd $SOFA_SRC
$ git checkout master
$ git pull
$ cd $SOFA_BLD
$ cmake $SOFA_SRC
$ make
$ make install (The last step 2. Building the plugin SofaPython3It is in this step that we need to give CMake the path to SOFA's installation path of the last step. $ cd $SP3_SRC
$ git pull
$ cd $SP3_BLD
$ cmake -DCMAKE_PREFIX_PATH=$SOFA_BLD/install/lib/cmake $SP3_SRC
$ make At this point, make sure you can find the file $ mkdir -p $(python3 -m site --user-site) Linux $ ln -sFfv $(find $SP3_BLD/lib/site-packages -maxdepth 1 -mindepth 1 -not -name "*.py") $(python3 -m site --user-site) Mac OSX $ ln -sFfv $(find $SP3_BLD/lib/site-packages ! -name *.py -d 1) $(python3 -m site --user-site) 3. Running SOFA with the pluginFinally, launch SOFA with $ ./$SOFA_BLD/bin/runSofa -l $SP3_BLD/lib/libSofaPython3.so 4.. Running SOFA directly in pythonYou should also be able to load SOFA directly into your python 3 interpreter: $ python3 >>> import SofaRuntime
>>> import Sofa
>>> SofaRuntime.importPlugin('SofaComponentAll')
>>> root = Sofa.Core.Node("root")
>>> root.addObject("MechanicalObject", position=[0, 0, 0, 5, 5, 5]) |
Thank you for pointing the weakness of the out-of-source build documentation. So here is a more detailled one that I just tested and that work. Sofa
git clone https://github.com/sofa-framework/sofa.git sofa/src/
make install or with ninja (if you use it) ninja install Now you should have a directory called "install" /home/ho-lab/Documents/MySofa/P-sofa/build/install At this point you are ready to make an out-of-tree build of the python plugin. SofaPython3You can keep the organization of your directory (the one you are specifying in the pdf file you send). With SofaPython3 next to the P-sofa folder. So
git clone [email protected]:SofaDefrost/plugin.SofaPython3.git
CMAKE_PREFIX_PATH=/home/ho-lab/Documents/MySofa/P-sofa/build/install When you click on generate you shouldn't have error/failure and you normally don't need to specify the PYTHON_ROOT_DIR or Python_EXECUTABLE. This only happens if you have already compiled your sofa version with python2.7 enabled. So by default don't do that. At this step you now can compile the python plugin.
When the compilation is done you should have in the SofaPython3 build directory a subdirectory called "lib" with this content: |
Haha :@jnbrunet & I responded at he same time ;) But Jean Nicolas, on my system If I start runSofa and try to load the plugin loaded it fails to load because the site-packages is not yet registered. So I assume that one additional step is needed to copy the configuration file from the python3 etc/ directory into the sofa one ? |
Damn @damienmarchal , 1 minute between our replies! Indeed, I forgot about the python package. There are many ways to do it, mine is:
I'll edit my answer to add this step |
Thank you so much @jnbrunet and @damienmarchal "The sofa cannot detect .py file" Could you please help me to solve it? |
Hi Pho, There is an [Error] message saying that it cannot load /lib/SofaPython3.so When you are typing: /$SOFA_BLD/bin/runSofa -l $SP3_BLD/lib/libSofaPython3.so Did you set the environment variable $SP3_BLD before ? Otherwise it is empty, so it would not be surprising that the plugin does not load. If you don't know how to do this in Linux here is a starting point: DM. |
Hey Pho, My bad, I was on Mac osx when testing. Try with
instead. |
Then simply create it... $ mkdir -p $HOME/.local/lib/python3.7/site-packages site-packages isn't a package. It is the directory where python looks to find packages. |
Hi Jnbrunet and Damien, |
Can you provide more details (screenshot) on the two results because I d'ont understand yet what you are saying; |
hey @ngvpho Do not delete the file plugin_list.conf.default. It seems you are missing the ".so" extension to your plugin. Change $ ./runSofa $SP3_BLD/lib/libSofaPython3 for $ ./runSofa $SP3_BLD/lib/libSofaPython3.so Next, your are loading the the old SofaPython plugin. This plugin is incompatible with the plugin SofaPython3. To remove it, first unset the SofaPython option in the compilation of Sofa. $ cd $SOFA_BLD
$ cmake-gui . and uncheck the PLUGIN_SOFAPYTHON option. $ make install And make sure the SofaPython plugin isn't in the file |
Hi @jnbrunet, |
I think the -l is missing in: $ ./runSofa $SP3_BLD/lib/libSofaPython3.so Shouldn't it be: $ ./runSofa -l $SP3_BLD/lib/libSofaPython3.so |
Hi @damienmarchal and @jnbrunet , |
Alright, I think we can close this issue now. The initial bug of this issue was fixed by #136 . |
Hello @ngvpho, Thanks for reporting the problem. Instead of loading the plugin with the -I option in the command line can you load it manually using the menu "View/PluginManager..." ? Then try to load the scene. In that case does it work ? If it is not the case then maybe it is a bug somewere that we need to investigate. @jnbrunet does it ring a bell to you ? |
Hi @ngvpho , It cannot find it because it isn't in the SOFA's plugins directory ( Since you already loaded the plugin with the runSofa's |
In general at Defrost we recommand to always put all the required plugin in every scenes. Doing so clearly states what are the needs for the scene to run and makes them much more robust (and sharable) because they makes no assumption on how is configure/initialized the execution environment. If doing so rises a warning/error message then I think we should fix this behavior instead of fixing the scene. But I'm surprise this the case ? |
Hi @damienmarchal , Of course. However, here you need the plugin to be able to load the scene (.py). In this case, @ngvpho explicitly stated the complete path to the plugin via the |
@jnbrunet it is unclear to me if you think:
|
Hey @damienmarchal , The error message is legitimate: you asked SOFA to find the plugin SofaPython3 via a SOFA has no way to tell if the plugin is already loaded (in this case, via the |
Ok, on my side I don't think RequiredPlugin is equivalent to FindPlugin neither LoadPlugin, it is just saying it is required and consequently if it is already "there", the requierement is fullfill and I see no good reason why to should print an error. About the fact that "SOFA has no way to tell if the plugin is already loaded"... EDIT: If I have some time I will try to make some tests to see if it is doable. |
Unfortunately, the bool PluginManager::pluginIsLoaded(const std::string& plugin)
{
std::string pluginPath = plugin;
if (!FileSystem::isFile(plugin)) {
pluginPath = findPlugin(plugin);
}
return m_pluginMap.find(pluginPath) != m_pluginMap.end();
} I agree that |
Hey @ngvpho , The "-l" parameter expects a path to a plugin library (.so), example JN |
Hi @jnbrunet, Ok, I can load it. Best, |
When building SofaPython3 as out-of-tree build, linker can't find SofaComponentGeneral.
Though, CMAKE_PREFIX_PATH is properly set to SOFA's install dir, SofaPython3's CMakeLists.txt performs the SofaGeneral findPackage and target_link_libraries does include SofaComponentGeneral.
The text was updated successfully, but these errors were encountered: