compile with cython

This setup file can be used to manually compile ryvencore to a C extension using Cython, behavior should be the same.

Follow the below process to compile ryvencore with Cython and install it as a regular package. Points 1 - 4 are only necessary if they are not satisfied already. Run all commands from the top level ‘ryvencore’ directory. The process is shown for Ubuntu Linux. Assuming only Python is installed already:

  1. Remove old ryvencore versions

$ pip uninstall ryvencore
  1. Install GCC

$ sudo apt install build-essential
  1. Install Python dev tools

$ sudo apt install python3-dev
  1. Install Python dependencies

$ pip install cython wheel
  1. Compile

$ python -m setup_cython build_ext --inplace
  1. Build wheel

$ python setup_cython.py sdist bdist_wheel
  1. Install package from wheel

$ pip install ./dist/ryvencore-<version>-<platform>.whl

NOTE

  • if you don’t want to keep the source files (.py and compiled .c) in the installed package (only the compiled .so files), simply comment out the line packages = find: in setup.cfg

  • you can remove all the generated files and directories by running python cleanup_cython.py

To verify that the package successfully runs from the compiled C extension modules you can check whether the imported ryvencore package shows the __init__.so file and not __init__.py.

$ python
> import ryvencore as rc
> print(rc)

and to really be sure you can also manually remove all .py files in the installation directory

.../site-packages/ryvencore> find . -name "*.py" -type f -delete

and check whether you can successfully load the package from Python.