Python 3 bindings are not installed properly
Amir-Arsalan opened this issue · 1 comments
I compile cgal-swig-bindings and install the Python 3 bindings as follow. However, it seems that the Python bindings are not being installed properly. Can someone help me figure out what I'm doing wrong and how I can properly install CGAL bindings in Python 3?
# gmp installation
cd /
wget https://gmplib.org/download/gmp/gmp-6.1.2.tar.lz
lzip -d gmp-6.1.2.tar.lz
tar -xvf gmp-6.1.2.tar
cd gmp-6.1.2
./configure
make
make check
make install
# mpfr installation
cd /
wget https://www.mpfr.org/mpfr-current/mpfr-4.1.0.tar.gz
tar -xvzf mpfr-4.1.0.tar.gz
cd mpfr-4.1.0
./configure --with-gmp-include=/usr/local/include --with-gmp-lib=/usr/local/lib
make
make check
make install
# CGAL installation
cd /
wget https://github.com/CGAL/cgal/releases/download/v5.1.1/CGAL-5.1.1.zip
unzip CGAL-5.1.1.zip
cd CGAL-5.1.1
mkdir build
cd build
cmake -DCGAL_HEADER_ONLY=OFF -DCMAKE_BUILD_TYPE=Release ..
make
make install
# CGAL Swig Bindings
#python3 -m pip install cgal-bindings
git clone https://github.com/cgal/cgal-swig-bindings
cd cgal-swig-bindings
git checkout e8ee15d
#python3 setup.py install # this gives me some errors during installation
mkdir build
mkdir build/CGAL-5.0_release
cd build/CGAL-5.0_release
cmake ../.. \
-DCGAL_DIR=/usr/lib/CGAL -DCMAKE_BUILD_TYPE=Release \
-DBUILD_JAVA=OFF \
-DPYTHON_SITE_PACKAGES=/usr/local/lib/python3.7/dist-packages \
-DPYTHON_INCLUDE=/usr/include/python3.7/ \
-DPYTHON_LIBRARY=/usr/lib/python3.7/config-3.7m-x86_64-linux-gnu/libpython3.7.so \
-DPYTHON_LIBRARIES=/usr/local/lib/python3.7 \
-DPYTHON_VERSION=3.7
make -j 8
make install
Here's the output of CMake (v.3.14.4):
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- 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
-- Boost version: 1.65.1
-- Boost include dirs: /usr/include
-- Boost libraries:
-- Found SWIG: /usr/bin/swig3.0 (found version "3.0.12")
-- Build type: Release
-- USING CXXFLAGS = ' -O3 -DNDEBUG'
-- USING EXEFLAGS = ' '
-- Targetting Unix Makefiles
-- Using /usr/bin/c++ compiler.
-- Requested component: ImageIO
-- Requested component: MPFR
-- Requested component: GMP
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Release mode with g++: using -fno-strict-aliasing flags
-- BUILD_RUBY is set to OFF: no CGAL-bindings for Ruby will be generated.
-- Found Python: /usr/bin/python3.7 (found version "3.7.10") found components: Interpreter Development
-- BUILD_JAVA is set to OFF: no CGAL-bindings for Java will be generated.
-- Found Python libs.
-- CGAL-SWIG Python files and libraries will be written in /cgal-swig-bindings/build/CGAL-5.0_release/build-python/CGAL.
-- Now adding packages
-- NOTICE : LAS IO requires LASlib and will not be available.
-- Found Eigen3: /usr/include/eigen3 (found suitable version "3.3.4", minimum required is "3.1.0")
CMake Deprecation Warning at /usr/local/lib/cmake/CGAL/UseEigen3.cmake:11 (message):
This file UseEigen.cmake is deprecated, and the imported target
`CGAL::Eigen_support` from CGAL_Eigen_support.cmake should be used instead.
Call Stack (most recent call first):
SWIG_CGAL/Point_set_processing_3/CMakeLists.txt:6 (include)
CMake Deprecation Warning at /usr/local/lib/cmake/CGAL/UseEigen3.cmake:11 (message):
This file UseEigen.cmake is deprecated, and the imported target
`CGAL::Eigen_support` from CGAL_Eigen_support.cmake should be used instead.
Call Stack (most recent call first):
SWIG_CGAL/Shape_detection/CMakeLists.txt:6 (include)
-- Boost version: 1.65.1
-- Found the following Boost libraries:
-- serialization
-- iostreams
-- regex
CMake Deprecation Warning at /usr/local/lib/cmake/CGAL/UseEigen3.cmake:11 (message):
This file UseEigen.cmake is deprecated, and the imported target
`CGAL::Eigen_support` from CGAL_Eigen_support.cmake should be used instead.
Call Stack (most recent call first):
SWIG_CGAL/Classification/CMakeLists.txt:34 (include)
-- Found Eigen3: /usr/include/eigen3 (found suitable version "3.3.4", minimum required is "3.2.0")
CMake Deprecation Warning at /usr/local/lib/cmake/CGAL/UseEigen3.cmake:11 (message):
This file UseEigen.cmake is deprecated, and the imported target
`CGAL::Eigen_support` from CGAL_Eigen_support.cmake should be used instead.
Call Stack (most recent call first):
CMakeLists.txt:225 (include)
-- Configuring done
-- Generating done
CMake Warning:
Manually-specified variables were not used by the project:
PYTHON_INCLUDE
PYTHON_LIBRARIES
PYTHON_LIBRARY
PYTHON_SITE_PACKAGES
PYTHON_VERSION
-- Build files have been written to: /cgal-swig-bindings/build/CGAL-5.0_release
After installation, in Python I do import CGAL
and then type CGAL.
and press tab I see the followings. Is this normal or should I see the CGAL classes here?
import CGAL
>>> CGAL.__
CGAL.__cached__ CGAL.__dir__( CGAL.__format__( CGAL.__hash__( CGAL.__loader__ CGAL.__new__( CGAL.__reduce_ex__( CGAL.__spec__
CGAL.__class__( CGAL.__doc__ CGAL.__ge__( CGAL.__init__( CGAL.__lt__( CGAL.__package__ CGAL.__repr__( CGAL.__str__(
CGAL.__delattr__( CGAL.__eq__( CGAL.__getattribute__( CGAL.__init_subclass__( CGAL.__name__ CGAL.__path__ CGAL.__setattr__( CGAL.__subclasshook__(
CGAL.__dict__ CGAL.__file__ CGAL.__gt__( CGAL.__le__( CGAL.__ne__( CGAL.__reduce__( CGAL.__sizeof__( CGAL.__version__
However, it seems that I can import some of the classes such as Point_3
or Triangle_3
but not AABB_tree_Triangle_3_soup
:
>>> from CGAL.CGAL_Kernel import Point_3
>>> from CGAL.CGAL_Kernel import Triangle_3
>>> from CGAL.CGAL_AABB_tree import AABB_tree_Triangle_3_soup
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/CGAL/CGAL_AABB_tree.py", line 17, in swig_import_helper
return importlib.import_module(mname)
File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 670, in _load_unlocked
File "<frozen importlib._bootstrap>", line 583, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 1043, in create_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: /usr/local/lib/python3.7/dist-packages/CGAL/_CGAL_AABB_tree.so: undefined symbol: _ZN3tbb8internal25concurrent_vector_base_v3D2Ev
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.7/dist-packages/CGAL/CGAL_AABB_tree.py", line 20, in <module>
_CGAL_AABB_tree = swig_import_helper()
File "/usr/local/lib/python3.7/dist-packages/CGAL/CGAL_AABB_tree.py", line 19, in swig_import_helper
return importlib.import_module('_CGAL_AABB_tree')
File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_CGAL_AABB_tree'
I get the same errors if I do cd cgal-swig-bindings/build/CGAL-5.0_release/build-python/
and import CGAL from there.
Hey Amir-Arsalan,
Thanks for your attempts, which gave me many tips. Now I manage to install cgal-swig-bindings
.
-
First of all, you need to downgrade
gmp-6.1.2
togmp-6.1.0
because if you usegmp-6.1.2
, you will get an errorThe versions of gmp.h (6.1.2) and libgmp (6.1.0) do not match
when installingmpfr-4.1.0
. -
Second, I found out your boost version was 1.65.1. However,
CGAL
needs1.66
or greater. -
Third, some dependencies are required:
sudo apt-get install libgmp-dev
sudo apt-get install libmpfr-dev libmpfr-doc libmpfr4 libmpfr4-dbg
- Fourth, there is a bug in the
CMakeLists.txt
. You should modify the line 119:
change
"from distutils import sysconfig; print(sysconfig.get_python_lib(plat_specific=True, prefix='${CMAKE_INSTALL_PREFIX}'))"
to
"import site;print(site.getsitepackages()[0])"
otherwise, CGAL
will always be installed into /usr/local/lib/python3/dist-packages
rather than /usr/local/lib/python3.7/dist-packages
- Fifth, when cmake
cgal-swig-bindings
, you should use following command instead:
cmake -DCGAL_DIR=/usr/local/lib/cmake/CGAL -DBUILD_JAVA=OFF -DCMAKE_BUILD_TYPE=Release ../..
Hope my solution could help you out :)
Oliver