Building Cython modules with CMake

1,992 views
Skip to first unread message

Matt McCormick

unread,
Oct 30, 2011, 2:48:25 PM10/30/11
to cython-users
Hi,

I have started a repository with utilities for building Cython modules
with CMake. It can be found here:

https://github.com/thewtex/cython-cmake-example

From the readme:

cython-cmake-example
====================


Introduction
------------

Cython_ is hybrid C-Python language to easily write Python C-
extensions. Cython
allows one to write fast Python-ish code and easily integrate C or C++
code.

CMake_ is a cross-platform build system with good support for C/C++.
With
simple projects description scripts, *CMakeLists.txt*, a powerful
configuration
system is available. The configuration can be handled with a command
line
interface, curses interface, or Qt GUI interface.

This repository has CMake utilities for building Cython projects with
CMake.
The rectangle example from the Cython documentation is built to
demonstrate
their use.

The advantages of this build system include:

- Easy configuration of build settings.
- Easy integration of external libraries.
- Implicit Makefile dependency generation for .pxd files.
- Implicit Makefile dependency generation for C/C++ headers.
- Out-of-source builds.


Dependencies
------------

Build Dependencies
^^^^^^^^^^^^^^^^^^

- Python_
- Cython_
- CMake_
- C++ compiler (g++ for instance)

Test Dependencies
^^^^^^^^^^^^^^^^^

- Nose_


Build Instructions
------------------

::

mkdir cython_example_build
cd cython_example_build
cmake /path/to/src/cython-cmake-example
make

To run the tests::

nosetests

.. _Cython: http://cython.org/
.. _CMake: http://cmake.org/
.. _Nose: http://pypi.python.org/pypi/nose/
.. _Python: http://python.org/


Your feedback is welcome.

On the todo list:

-- Investigate easily building an independent executable with embedded
main.
-- Show how to make an setup.py that is installable.

Thanks,
Matt

Robert Bradshaw

unread,
Oct 31, 2011, 2:07:22 PM10/31/11
to cython...@googlegroups.com
Cool. It would be nice if there were a central wiki page that listed
all the different ways (and utilities) people have for building Cython
so they don't get lost in the mailing lists archives.

Matt McCormick

unread,
Nov 1, 2011, 8:22:35 PM11/1/11
to cython-users
Adding to the wiki here:

http://wiki.cython.org/tutorials/numpy?highlight=%28CMake%29

Please let me know if there is a better location.

Thanks,
Matt

On Oct 31, 2:07 pm, Robert Bradshaw <rober...@math.washington.edu>
wrote:

Robert Bradshaw

unread,
Nov 2, 2011, 1:07:34 AM11/2/11
to cython...@googlegroups.com
I was thinking a new page just devoted to the various build options.

Sebastien Binet

unread,
Nov 2, 2011, 4:02:19 AM11/2/11
to Robert Bradshaw, cython...@googlegroups.com
On Tue, 1 Nov 2011 22:07:34 -0700, Robert Bradshaw <robe...@math.washington.edu> wrote:
> I was thinking a new page just devoted to the various build options.

note this (old but still working) example on how to compile C and C++
libraries together with Cython:
https://bitbucket.org/binet/cy-cxxfwk/overview

-s

Reply all
Reply to author
Forward
0 new messages