Packaging CGAL-Python for Ubuntu Lucid

Jurjen Bokma

July 2010


[Warning]Warning

This section only half complete

A mathematician has a Python file that has a line:

from CGAL.Kernel import *
    

And when I run the program it complains:

jurjen@machine:~/test$ python solution1B.py
    ======================================================
    example 1
    ======================================================

    Traceback (most recent call last):
    File "solution1B.py", line 15, in <module>
    from CGAL.Kernel import *
    ImportError: No module named CGAL.Kernel

I think we are in need of the CGAL Python Bindings, so I set out to pacakge them.

Procedure 23.  Trying to use the CGAL-python without packaging
  1. user@machine:~$ wget https://gforge.inria.fr/frs/download.php/3521/cgal-python-0.9.3.tar.gz
    user@machine:~$ tar zxf cgal-python-0.9.3.tar.gz
    user@machine:~$ cd cgal-python

  2. When trying to compile according to the README.txt, we run into a version dependency that needs a patch:

    <snip>
    user@machine:~$ make
    <snip>
    Kernel_module.cpp: In function 'void init_module_Kernel()':
    Kernel_module.cpp:74: error: 'set_error_handler' is not a member of 'CGAL'
    <snip>

    ... so we patch it (for all modules, since we encounter it in all modules):

    user@machine:~$ find -iname \*module.cpp -exec sed -i.bak '/===$/ a #include <CGAL/assertions_behaviour.h>' {} \;

  3. When we then try to use the package, we run into a missing symbol, as described here and here.

  4. user@machine:~$ cd cgal-python
    user@machine:~$ wget http://lists.gforge.inria.fr/pipermail/cgal-python-users/attachments/20080910/8d96239f/setup.py
    <snip>
    user@machine:~$ sed -i.bak "/include_dirs/ s%\.\./\.\.%${PWD}%" setup.py
    <snip>
    user@machine:~$ time python ./setup.py build
    <snippety-snip>
    user@machine:~$ sudo python ./setup.py install
    running install
    running build
    running build_py
    running build_ext
    running install_lib
    creating /usr/local/lib/python2.6/dist-packages/CGAL
    copying build/lib.linux-x86_64-2.6/CGAL/Triangulations_2.so -> /usr/local/lib/python2.6/dist-packages/CGAL
    copying build/lib.linux-x86_64-2.6/CGAL/pythonstartup.py -> /usr/local/lib/python2.6/dist-packages/CGAL
    copying build/lib.linux-x86_64-2.6/CGAL/Mesh_2.so -> /usr/local/lib/python2.6/dist-packages/CGAL
    copying build/lib.linux-x86_64-2.6/CGAL/__init__.py -> /usr/local/lib/python2.6/dist-packages/CGAL
    copying build/lib.linux-x86_64-2.6/CGAL/Triangulations_3.so -> /usr/local/lib/python2.6/dist-packages/CGAL
    copying build/lib.linux-x86_64-2.6/CGAL/Polyhedron.so -> /usr/local/lib/python2.6/dist-packages/CGAL
    copying build/lib.linux-x86_64-2.6/CGAL/Geometric_Optimisation.so -> /usr/local/lib/python2.6/dist-packages/CGAL
    copying build/lib.linux-x86_64-2.6/CGAL/Convex_hull_2.so -> /usr/local/lib/python2.6/dist-packages/CGAL
    copying build/lib.linux-x86_64-2.6/CGAL/Alpha_shapes_3.so -> /usr/local/lib/python2.6/dist-packages/CGAL
    copying build/lib.linux-x86_64-2.6/CGAL/Alpha_shapes_2.so -> /usr/local/lib/python2.6/dist-packages/CGAL
    copying build/lib.linux-x86_64-2.6/CGAL/Kernel.so -> /usr/local/lib/python2.6/dist-packages/CGAL
    byte-compiling /usr/local/lib/python2.6/dist-packages/CGAL/pythonstartup.py to pythonstartup.pyc
    byte-compiling /usr/local/lib/python2.6/dist-packages/CGAL/__init__.py to __init__.pyc
    running install_egg_info
    Writing /usr/local/lib/python2.6/dist-packages/CGAL_Python-0.9.egg-info
    user@machine:~$ 

  5. user@machine:~/test$ python ./solution1B.py
    ======================================================
                    example 1
    ======================================================

    length_polygon  1817.72593479
    <snipped pretty graphics>

Procedure 24.  Packaging the Beasty
  1. jurjen@host:~/cgal-python$ wget https://gforge.inria.fr/frs/download.php/3521/cgal-python-0.9.3.tar.gz
    <snip>
    2010-07-09 12:59:14 (795 KB/s) - `cgal-python-0.9.3.tar.gz' saved [144786/144786]

    jurjen@host:~/cgal-python$ tar zxf cgal-python-0.9.3.tar.gz
    jurjen@host:~/cgal-python$ mv cgal-python cgal-python-0.9.3
    jurjen@host:~/cgal-python$ cd cgal-python-0.9.3
    jurjen@host:~/cgal-python/cgal-python-0.9.3$

  2. jurjen@host:~/cgal-python/cgal-python-0.9.3$ export DEBEMAIL='j.bokma@rug.nl'
    jurjen@host:~/cgal-python/cgal-python-0.9.3$ export DEBFULLNAME="Jurjen Bokma"
    jurjen@host:~/cgal-python/cgal-python-0.9.3$ dh_make -s --dpatch --copyright lgpl -f ../cgal-python-0.9.3.tar.gz
    Maintainer name : Jurjen Bokma
    Email-Address   : j.bokma@rug.nl
    Date            : Fri, 09 Jul 2010 13:07:23 +0200
    Package Name    : cgal-python
    Version         : 0.9.3
    License         : lgpl3
    Using dpatch    : yes
    Using quilt     : no
    Type of Package : Single
    Hit <enter> to confirm:
    Done. Please edit the files in the debian/ subdirectory now. You should also
    check that the cgal-python Makefiles install into $DESTDIR and not in / .
    jurjen@host:~/cgal-python/cgal-python-0.9.3$ rm debian/{cron.d.ex,init.d.*,menu.ex,README.source,README.Debian,cgal-python.default.ex,emacsen-*,pre*,post*,cgal-python.doc-base.EX,manpage.*,debian/watch.ex}

  3. [Note]Note

    I'm only just acquiring this skill, so it's still something of a black art to me. Some important files are shown here, some details are also omitted.