Skip to content
Snippets Groups Projects
usage.rst 1.49 KiB

Usage

To use snakehouse just use the following in your setup.py:

from snakehouse import Multibuild, build

extensions = build([
                Multibuild('example_module', list_of_pyx_files)
                ], compiler_directives={
                   'language_level': '3',
                })

setup(name='example_module',
  version='0.1',
  packages=['example_module'],
  ext_modules=extensions
)

You can pass also setuptools's Extensions objects, as detailed in example.

Full pydoc of Multibuild and build is here

You should use dont_snakehouse for debugging and unit tests, as snakehouse has a sad tendency to dump core on unhandled exceptions. To prevent that from happening remember to handle your exceptions and debug using this flag.

If you need to locate all .pyx files in a certain directory, you can do the following:

from snakehouse import Multibuild, build, find_all

extensions = build([
                Multibuild('example_module', find_all('src'))
                ], compiler_directives={
                   'language_level': '3',
                })

The documentation to :class:`~snakehouse.find_all` is as follows: