Skip to content

Hyperscan for Python

python-hyperscan is an unofficial CPython extension for Intel's Hyperscan, the open source, high-performance multiple regex matching library.

Quickstart

Building Hyperscan

See the official documentation for detailed installation instructions and dependencies.

The following should work for most use cases, once the prerequisite dependencies have been installed:

$ git clone https://github.com/intel/hyperscan.git
$ mkdir -p hyperscan/build
$ cd hyperscan
$ # PCRE1 (8.xx series) is required for Chimera support
$ wget -qO- https://sourceforge.net/projects/pcre/files/pcre/8.45/pcre-8.45.tar.gz/download | tar xvz
$ git checkout v5.4.0
$ cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr \
    -DBUILD_STATIC_AND_SHARED=ON \
    -DFAT_RUNTIME=ON \
    -DPCRE_SOURCE=../pcre-8.45 \
    ../
$ # Compile with all available cores:
$ # make -j $(( $(nproc) + 1 ))
$ make
$ sudo make install

Note: if you are building v5.4.0 and encounter undefined reference errors when linking, see intel/hyperscan#292 (and more specifically, this comment) for the fix. Per the maintainers, this will be fixed in the next Hyperscan release.

Installing python-hyperscan

Installing via pip is recommended:

$ pip install hyperscan

To build and install from source, using Poetry:

$ pip install poetry
$ git clone https://github.com/darvid/python-hyperscan.git
$ cd python-hyperscan
$ poetry install