Skip to content

Problem importing Sofa.Core, SofaRuntime and Sofa.Simulation #16

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

Closed
EtienneMenager opened this issue Jun 18, 2020 · 11 comments
Closed

Problem importing Sofa.Core, SofaRuntime and Sofa.Simulation #16

EtienneMenager opened this issue Jun 18, 2020 · 11 comments
Assignees
Labels
issue: bug Something isn't working

Comments

@EtienneMenager
Copy link

EtienneMenager commented Jun 18, 2020

Configuration:

When I open python3.7 and run import Sofa I get the error:

ImportError: generic_type: type "BoundingBox" does not have a non-default holder type while its base "sofa::core::objectmodel::BaseData" does
@marques-bruno marques-bruno added the issue: bug Something isn't working label Jun 18, 2020
@marques-bruno marques-bruno self-assigned this Jun 18, 2020
@marques-bruno
Copy link
Member

@jnbrunet maybe you have a clue? I'm out of ideas on this one.. I've read that up/downcasts from derived types can be an issue when using unique_ptrs (pybind/pybind11#1317)
But then it works fine on most machines, so...

@jnbrunet
Copy link
Contributor

jnbrunet commented Jun 19, 2020

I just tried on the pybind11 2.3 branch, and I cannot reproduce.

Can you give me some more information:

  1. Go in the directory of SofaPython3 and do git rev-parse HEAD
  2. Go in the build directory of SofaPython3 and do grep PYTHON CMakeCache.txt
  3. Go in the build directory of SofaPython3 and do grep -i pybind CMakeCache.txt
  4. which python3.7
  5. python3.7 -c "import sys;print(sys.path)"

@EtienneMenager
Copy link
Author

EtienneMenager commented Jun 19, 2020

Hi,

Thank you for the answer. Here is what you asked for:

  1. For the first element I didn't use git, I took the zip here: https://github.com/sofa-framework/plugin.SofaPython3/tree/fix_Sofa.Simulation. I got the zip (master) from yesterday.

2-3. I build in-tree, so I realise the command in the build of Sofa.

for grep PYTHON CMakeCache.txt:

PLUGIN_SOFAPYTHON:BOOL=OFF
PLUGIN_SOFAPYTHON3:BOOL=ON
PYTHON_EXECUTABLE:FILEPATH=/usr/bin/python3.7
PYTHON_LIBRARY:FILEPATH=/usr/lib/x86_64-linux-gnu/libpython3.7m.so
// directory path can be changed by setting SP3_PYTHON_PACKAGES_LINK_DIRECTORY.
SP3_PYTHON_PACKAGES_DIRECTORY:PATH=site-packages
SP3_PYTHON_PACKAGES_LINK_DIRECTORY:PATH=/home/etiennemenager/.local/lib/python3.7/site-packages
//Details about finding PYTHON
FIND_PACKAGE_MESSAGE_DETAILS_PYTHON:INTERNAL=/usr/bin/python3.7
//ADVANCED property for variable: PYTHON_EXECUTABLE
PYTHON_EXECUTABLE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: PYTHON_LIBRARY
PYTHON_LIBRARY-ADVANCED:INTERNAL=1

for grep -i pybind CMakeCache.txt:

//The directory containing a CMake configuration file for pybind11.
pybind11_DIR:PATH=/usr/lib/cmake/pybind11
PYBIND11_LTO_CXX_FLAGS:INTERNAL=-flto;-fno-fat-lto-objects
PYBIND11_LTO_LINKER_FLAGS:INTERNAL=-flto

  1. /usr/bin/python3.7

  2. ['', '/home/etiennemenager/Desktop/dev/sofa/master/build', '/home/etiennemenager/Desktop/dev/sofa/master/build/lib/site-packages', '/usr/lib/python37.zip', '/usr/lib/python3.7', '/usr/lib/python3.7/lib-dynload', '/home/etiennemenager/.local/lib/python3.7/site-packages', '/usr/local/lib/python3.7/dist-packages', '/usr/lib/python3/dist-packages']

Thank's

@jnbrunet
Copy link
Contributor

Just to be sure, can you run grep -i pybind11_version /usr/include/pybind11/detail/common.h

@EtienneMenager
Copy link
Author

Yes:

/usr/include/pybind11/detail/common.h
#define PYBIND11_VERSION_MAJOR 2
#define PYBIND11_VERSION_MINOR 3
#define PYBIND11_VERSION_PATCH dev0

@jnbrunet
Copy link
Contributor

Just tried with that exact version (2.3.0) and I still cannot reproduce.

Can you start-up clean with out-of-source?

SOFA

  1. cd /home/etiennemenager/Desktop/dev/sofa/master/build
  2. rm -rf lib/site-packages lib/libSofaPython3.so*
  3. rm -rf install 2> /dev/null
  4. cmake -DPLUGIN_SOFAPYTHON3=OFF .
  5. cmake --build .
  6. cmake --install .

SP3

  1. Set the environment variable SP3_SRC to the directory where the source of SofaPython3 is
export SP3_SRC=/home/etiennemenager/.../plugin.SofaPython3
  1. rm -rf $SP3_SRC
  2. git clone https://github.com/sofa-framework/plugin.SofaPython3.git $SP3_SRC
  3. cd $SP3_SRC && mkdir build && cd build
  4. cmake -DCMAKE_PREFIX_PATH=/home/etiennemenager/Desktop/dev/sofa/master/build/install/lib/cmake ..
  5. cmake --build .
  6. cmake --install .

PYTHON
Remove these from your python sys paths (you probably had set them with PYTHONPATH in your bashrc or something) :

  1. /home/etiennemenager/Desktop/dev/sofa/master/build
  2. /home/etiennemenager/Desktop/dev/sofa/master/build/lib/site-packages

So that python3.7 -c "import sys;print(sys.path)" gives you

['','/usr/lib/python37.zip', '/usr/lib/python3.7', '/usr/lib/python3.7/lib-dynload', '/home/etiennemenager/.local/lib/python3.7/site-packages', '/usr/local/lib/python3.7/dist-packages', '/usr/lib/python3/dist-packages']

and finally,

$ python3.7
>>> import Sofa

@EtienneMenager
Copy link
Author

I tried, but I have this error:

etiennemenager@ubuntu:~/Desktop/dev/plugin/plugin.SofaPython3/build$ cmake -DCMAKE_PREFIX_PATH=/home/etiennemenager/Desktop/dev/sofa/master/build/install/lib/cmake ..
-- The C compiler identification is GNU 9.2.1
-- The CXX compiler identification is GNU 9.2.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonInterp: /usr/bin/python3.7 (found suitable version "3.7.5", minimum required is "3.7")
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython3.7m.so
-- Python version: 3.7.5
-- Python executable: /usr/bin/python3.7
-- Python include dirs: /usr/include/python3.7m
-- Python libraries: /usr/lib/x86_64-linux-gnu/libpython3.7m.so
-- Python user site: /home/etiennemenager/.local/lib/python3.7/site-packages
-- pybind11 version: 2.3.dev1
-- pybind11 config: /usr/local/share/cmake/pybind11/pybind11Config.cmake
CMake Error at Plugin/CMakeLists.txt:36 (find_package):
By not providing "FindSofaFramework.cmake" in CMAKE_MODULE_PATH this
project has asked CMake to find a package configuration file provided by
"SofaFramework", but CMake did not find one.

Could not find a package configuration file provided by "SofaFramework"
with any of the following names:

SofaFrameworkConfig.cmake
sofaframework-config.cmake

Add the installation prefix of "SofaFramework" to CMAKE_PREFIX_PATH or set
"SofaFramework_DIR" to a directory containing one of the above files. If
"SofaFramework" provides a separate development package or SDK, be sure it
has been installed.

@jnbrunet
Copy link
Contributor

Did you run the step 6 (SOFA) in your SOFA build directory?

SOFA
(...)
6. cmake --install .

The directory /home/etiennemenager/Desktop/dev/sofa/master/build/install/lib/cmake should exists and have the following directories:

GTest  Newmat  QGLViewer  SofaAdvanced  SofaBase  SofaCommon  SofaComponentAll  SofaFramework  SofaGeneral  SofaGTestMain  SofaGui  SofaMisc  SofaSimulation  TinyXML

@EtienneMenager
Copy link
Author

Yes I did:

etiennemenager@ubuntu:~/Desktop/dev/sofa/master/build$ cmake --install .
-- Install prefix: /home/etiennemenager/Desktop/dev/sofa/master/build/install
-- Boost version: 1.67.0
-- Found the following Boost libraries:
-- system
-- filesystem
-- program_options
-- thread
-- chrono
-- date_time
-- atomic
CMake Warning (dev) at /usr/share/cmake-3.13/Modules/FindOpenGL.cmake:270 (message):
Policy CMP0072 is not set: FindOpenGL prefers GLVND by default when
available. Run "cmake --help-policy CMP0072" for policy details. Use the
cmake_policy command to set the policy and suppress this warning.

FindOpenGL found both a legacy GL library:

OPENGL_gl_LIBRARY: /usr/lib/x86_64-linux-gnu/libGL.so

and GLVND libraries for OpenGL and GLX:

OPENGL_opengl_LIBRARY: /usr/lib/x86_64-linux-gnu/libOpenGL.so
OPENGL_glx_LIBRARY: /usr/lib/x86_64-linux-gnu/libGLX.so

OpenGL_GL_PREFERENCE has not been set to "GLVND" or "LEGACY", so for
compatibility with CMake 3.10 and below the legacy GL library will be used.
Call Stack (most recent call first):
SofaKernel/SofaFramework/SofaMacros.cmake:514 (find_package)
SofaKernel/modules/SofaHelper/CMakeLists.txt:20 (sofa_find_package)
This warning is for project developers. Use -Wno-dev to suppress it.

Adding module SofaExporter
-- SofaPython disabled, will not compile python bindings.
Adding module SofaSparseSolver
-- SofaSparseSolver: metis library not found, will use built-in metis library.
Adding module SofaPreconditioner
Adding module SofaHaptics
Adding module SofaValidation
Adding module SofaDenseSolver
Adding module SofaNonUniformFem
Adding module SofaOpenglVisual
-- SofaGuiQt: QtCharts not found, SofaWindowProfiler will not be built.
-- SofaGuiQt: Qt5WebEngine not found, QDocBrowser will not be built.
CMake Deprecation Warning at SofaAdvanced/CMakeLists.txt:15 (message):
SofaAdvanced is deprecated.
You should now explicitely find (find_package) and link (target_link_library) each module you need within:
SofaNonUniformFem

Adding collection SofaComponentAll
-- SofaTest: optional dependency SofaPython NOT found, Python_test won't be built
Adding plugin CImgPlugin
-- CImgPlugin: TIFF Image Format enabled
-- CImgPlugin: JPEG Image Format enabled
-- CImgPlugin: PNG Image Format enabled
Adding plugin SofaMiscCollision
-- SofaMiscModule: build all maintained sofa components.
-- SofaMiscCollision: optional dependency SofaSphFluid not found de-activing:
Adding plugin SofaDistanceGrid
-- SofaDistanceGrid: MiniFlowVR not found, some features will not be compiled.
Adding plugin SofaImplicitField
-- PSL is an experimental feature, use it at your own risk.
Adding application runSofa
Write Plugin list at /home/etiennemenager/Desktop/dev/sofa/master/build/lib/plugin_list.conf.default
Adding external directory: plugin (/home/etiennemenager/Desktop/dev/plugin)
Adding plugin BeamAdapter
-- Install prefix: /home/etiennemenager/Desktop/dev/sofa/master/build/install
Adding plugin SoftRobots
-- Install prefix: /home/etiennemenager/Desktop/dev/sofa/master/build/install
-- The higly recommanded 'STLIB' plugin is missing. You can compile SoftRobots but most of the provided examples will not work.
Adding plugin SofaCV
CMake Warning (dev) at /home/etiennemenager/Desktop/dev/plugin/SofaCV/CMakeLists.txt:186:
Syntax Warning in cmake code at column 179

Argument not separated from preceding token by whitespace.
This warning is for project developers. Use -Wno-dev to suppress it.

-- Found OpenCV: /usr/local (found suitable version "3.2.0", minimum required is "3.2")
CMake Warning (dev) at /usr/share/cmake-3.13/Modules/FindBoost.cmake:1006 (if):
Policy CMP0054 is not set: Only interpret if() arguments as variables or
keywords when unquoted. Run "cmake --help-policy CMP0054" for policy
details. Use the cmake_policy command to set the policy and suppress this
warning.

Quoted variables like "chrono" will no longer be dereferenced when the
policy is set to NEW. Since the policy is not set the OLD behavior will be
used.
Call Stack (most recent call first):
/usr/share/cmake-3.13/Modules/FindBoost.cmake:1670 (_Boost_MISSING_DEPENDENCIES)
/home/etiennemenager/Desktop/dev/sofa/master/build/cmake/SofaFrameworkConfig.cmake:72 (find_package)
/home/etiennemenager/Desktop/dev/sofa/master/build/cmake/SofaSimulationConfig.cmake:31 (find_package)
/home/etiennemenager/Desktop/dev/sofa/master/build/cmake/SofaBaseConfig.cmake:32 (find_package)
/home/etiennemenager/Desktop/dev/sofa/master/build/cmake/SofaCommonConfig.cmake:32 (find_package)
/home/etiennemenager/Desktop/dev/sofa/master/build/cmake/SofaGeneralConfig.cmake:33 (find_package)
/home/etiennemenager/Desktop/dev/sofa/master/build/cmake/SofaGuiConfig.cmake:42 (find_package)
/home/etiennemenager/Desktop/dev/plugin/SofaCV/CMakeLists.txt:10 (find_package)
This warning is for project developers. Use -Wno-dev to suppress it.

Adding plugin ImageProcessing
CMake Warning (dev) at /usr/share/cmake-3.13/Modules/FindBoost.cmake:1006 (if):
Policy CMP0054 is not set: Only interpret if() arguments as variables or
keywords when unquoted. Run "cmake --help-policy CMP0054" for policy
details. Use the cmake_policy command to set the policy and suppress this
warning.

Quoted variables like "chrono" will no longer be dereferenced when the
policy is set to NEW. Since the policy is not set the OLD behavior will be
used.
Call Stack (most recent call first):
/usr/share/cmake-3.13/Modules/FindBoost.cmake:1670 (_Boost_MISSING_DEPENDENCIES)
/home/etiennemenager/Desktop/dev/sofa/master/build/cmake/SofaFrameworkConfig.cmake:72 (find_package)
/home/etiennemenager/Desktop/dev/sofa/master/build/cmake/SofaSimulationConfig.cmake:31 (find_package)
/home/etiennemenager/Desktop/dev/sofa/master/build/cmake/SofaBaseConfig.cmake:32 (find_package)
/home/etiennemenager/Desktop/dev/sofa/master/build/cmake/SofaCommonConfig.cmake:32 (find_package)
/home/etiennemenager/Desktop/dev/sofa/master/build/cmake/SofaGeneralConfig.cmake:33 (find_package)
/home/etiennemenager/Desktop/dev/plugin/ImageProcessing/CMakeLists.txt:13 (find_package)
This warning is for project developers. Use -Wno-dev to suppress it.

-- Found OpenCV: /usr/local (found suitable version "3.2.0", minimum required is "3.0")
found opencv contrib
CMake Deprecation Warning at CMakeLists.txt:324 (message):
Deprecated components are activated (SOFA_WITH_DEPRECATED_COMPONENTS
variable is ON)

-- Configuring done
-- Generating done
-- Build files have been written to: /home/etiennemenager/Desktop/dev/sofa/master/build

But I have nothing except SofaPython3 in /home/etiennemenager/Desktop/dev/sofa/master/build/install/lib/cmake ...

@jnbrunet
Copy link
Contributor

Hi @EtienneMenager , did you solved your issue?

@EtienneMenager
Copy link
Author

Hi, sorry for the late update. I did not solve the problem but I downloaded an image for my VM with everything already install! Thank's.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants