Skip to content

Build a Custom rapidocr Wheel

RapidOCR uses pyproject.toml and setuptools-scm to build wheels. The build environment requires Python >=3.9; the resulting wheel supports Python >=3.8.

1. Enter the Python package directory

git clone https://github.com/RapidAI/RapidOCR.git
cd RapidOCR/python

2. Install build dependencies

python -m pip install --upgrade pip
python -m pip install build setuptools wheel setuptools-scm PyYAML

Install the complete requirements if you also need to run tests:

python -m pip install -r requirements.txt

3. Prepare bundled model assets

python tools/prepare_wheel_assets.py

This command resolves the default Det, Cls and Rec models, verifies their SHA256 checksums and generates MANIFEST.in. To verify already prepared assets without downloading them:

python tools/prepare_wheel_assets.py --check

4. Set the version and build

SETUPTOOLS_SCM_PRETEND_VERSION_FOR_RAPIDOCR=3.1.0 python -m build --wheel

The wheel is written to dist/, for example:

dist/rapidocr-3.1.0-py3-none-any.whl

5. Verify the wheel

Check its version:

unzip -p dist/rapidocr-3.1.0-py3-none-any.whl "*/METADATA" | grep "^Version:"

Check that the default models are included:

python -m zipfile -l dist/rapidocr-3.1.0-py3-none-any.whl | grep "rapidocr/models"

Alternatively, build from a Git tag. When the current commit is exactly at v3.1.0, setuptools-scm derives version 3.1.0; otherwise it generates a development version.

Comments