Utilities for packing multiple pyx files into a single Cython extension
Project description
snakehouse
snakehouse is a tool to pack mutiple .pyx files into a single extension.
There's a MANDATORY READING part at the end of this README. Read it or you will be sure to run into trouble.
Inspired by this StackOverflow discussion.
Tested and works on CPython 3.5-3.9, both Windows and Linux. It doesn't work on PyPy.
Contributions most welcome! If you contribute, feel free to attach a change to CONTRIBUTORS.md as a part of your pull request as well! Note what have you changed in CHANGELOG.md as well!
Accelerating builds
distutils by default compiles using a single process. To enable faster, multiprocess compilations just type:
from snakehouse import monkey_patch_parallel_compilation
monkey_patch_parallel_compilation()
Before your setup()
call.
Usage notes - MANDATORY READING
Take a look at example on how to multi-build your Cython extensions.
Don't place modules compiled that way in root .py file's top level imports. Wrap them in a layer of indirection instead!
This applies to unit tests as well!
When something goes wrong (eg. the application throws an unhandled exception)
the built module has a tendency to dump core.
Try to debug it first by passing dont_snakehouse=True
to your
modules in the debug mode.
Also note that if you are compiling in dont_snakehouse
mode then your modules should have at least one of the following:
- a normal Python
def
- a normal Python class (not
cdef class
) - a line of Python initialization, eg.
a = None
or
import logging
logger = logging.getLogger(__name__)
Otherwise PyInit
won't be generated by Cython
and such module will be unimportable in Python. Normal import won't suffice.
Further streamlining your builds
If you add a MANIFEST.in file with contents:
include requirements.txt
Then you can write the following in your setup.py:
from snakehouse import read_requirements_txt
setup(install_requires=read_requirements_txt())
This will read in your requirements.txt and extract packages from there. Be sure to entertain it's pydoc!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for snakehouse-1.3.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76fbc10b2b28d21821bd83e8646367841dc8adf6431ca0d43865fe91d31566f7 |
|
MD5 | 3f5411a95c02d319d2943b50c75030df |
|
BLAKE2b-256 | e30053a5cc9552dcc41cb2700aa0235fce54addde31a653ae5b374db280f865c |