Skip to content
efifogel edited this page Jun 23, 2020 · 120 revisions

About CGAL TAU Python Bindings

This repository contains software for binding CGAL TAU components (written in C++) with Python. it also contains examples, tests, and benchmarks.

Installing

Naturally, you need to install Python and CGAL before attempting to use the bindings.

Python & Pip

We use Python 3.7.

Ubuntu

If Python 3.7 is the default version for you Ubuntu distribution, proceed to install Python via the standard apt-get installation procedure. Otherwise, jump to install Python from a PPA.

Install via apt-get

Install Pip once via a dedicated procedure and then upgrade via Pip. Install Python modules via Pip.

#!bash

# Install Python 3
> sudo apt-get install python3
# Verify
> python3 --version
# Set up your system to build binary Python packages
> sudo apt-get install -y python3-dev
# Install Pip
> curl -LO https://bootstrap.pypa.io/get-pip.py
> python3 get-pip.py --user
# Upgrade (not really necessary---already up-to-date)
> pip3 install -U pip --user
# Verify
> pip3 --version
> which pip3
# Install popular Python packages
> pip3 install --user numpy
> pip3 install --user pipenv
> pip3 install --user pytest
> pip3 install --user pybind11

Binding Products

We have compared three different products to create Python bindings, namely:

  1. **Boost Python **
  2. Pybind11
  3. **Swig **

In order to use Boost Python you need to install it. Boost is a dependency of CGAL. When you install CGAL, it is recommended installing all Boost components. If not installed already though, install the Python component python35.

Pybind11 is a header-only product.

Ubuntu

Python bindings require Boost version 1.64 or higher. This version does not come by default with Ubuntu 16.04, so you need to install it from sources. The following installs version 6.8 to /usr/local. While only the Boost libraries bellow are required, it is recommended that you install all.

#!bash

# Install Boost
> mkdir -p ~/tmp/src/boost
> cd ~/tmp/src
> curl -SL boost_1_68_0.tar.gz https://sourceforge.net/projects/boost/files/boost/1.68.0/boost_1_68_0.tar.gz | tar -xzC boost
> cd ~/tmp/src/boost/boost_1_68_0
> ./bootstrap.sh --with-python-version=3.5
> ./b2 --with=all -j4
# Install to /usr/local
> sudo ./b2 install
# Clean
> rm -rf ~/tmp/src/boost

# Obtain the pybind11 sources
> git clone https://github.com/pybind/pybind11.git
# Set the PYBIND11_DIR  environment variable to point at the header directory
> export PYBIND11_DIR <pybind11-root-directory>/include

The PYBIND11_DIR environment variable is used by the CMakeLists.txt file to build the Pybind11 bindings.

Benchmarks

Bindings

Tests

Clone this wiki locally