- Use the Bazel build system when interacting with this repository.
- The CMake build system is available to help users who need it.
- Keep both the CMake and Bazel builds working at all times.
To build all code with bazel:
bazel build src:allTo build the Tesseract and Simplex main binaries:
bazel build src:tesseract src:simplexbazel test src/...In case you need to, when building with CMake, use parallel flags to speed up the process.
- When using
cmake --build, add the--parallelflag. - When using
make, add the-jflag (e.g.,make -j$(nproc)).
To run the tests, execute the following commands from the root of the repository:
mkdir -p build
cd build
cmake ..
cmake --build . --parallel
ctestTo build the Python wheel for tesseract_decoder locally, you will need to use the bazel build command and provide the version and Python target version as command-line arguments. This is because the py_wheel rule in the BUILD file uses "Make" variable substitution, which expects these values to be defined at build time.
Use the following command:
bazel build //:tesseract_decoder_wheel --define=VERSION=0.1.1 --define=TARGET_VERSION=py313--define=VERSION=0.1.1: Sets the version of the wheel. You should replace0.1.1with the current version from the_version.pyfile.--define=TARGET_VERSION=py313: Sets the Python version tag for the wheel. Replacepy313with the appropriate tag for the Python version you are targeting (e.g.,py312for Python 3.12).
The resulting wheel file will be located in the bazel-bin/ directory.
If you change the Python version in MODULE.bazel, you will need to regenerate the requirements_lock.txt file to ensure all dependencies are compatible. To do this, run the following command:
bazel run //src/py:requirements.updateThis will update the src/py/requirements_lock.txt file with the correct dependency versions for the new Python environment.