- Python 3.10 or newer
- CMake 3.15 or newer
- C compiler (gcc, clang, or MSVC)
- pip
- Install build dependencies:
python -m pip install --upgrade pip
python -m pip install build numpy cython- Build the package:
# From the root directory
python -m build- Install the built package:
pip install dist/*.whlTo create platform-specific binary wheels:
- Navigate to the py_bind directory:
cd py_bind- Clean previous build artifacts:
rm -rf build/ dist/ *.egg-info/
rm -rf optv/*.c # Remove Cython-generated files- Prepare the source files:
python setup.py prepare- Build the wheel:
python -m pip wheel . -w dist/The wheel will be created in the dist/ directory with a platform-specific name like:
- Linux:
openptv-0.3.0-cp311-cp311-linux_x86_64.whl - Windows:
openptv-0.3.0-cp311-cp311-win_amd64.whl - macOS:
openptv-0.3.0-cp311-cp311-macosx_10_9_x86_64.whl
For building wheels for multiple platforms and Python versions, we use cibuildwheel:
- Install cibuildwheel:
pip install cibuildwheel- Build wheels for all supported platforms:
# Linux/macOS
python -m cibuildwheel --platform linux --arch x86_64
# or
python -m cibuildwheel --platform macos --arch x86_64
# or on Windows
python -m cibuildwheel --platform windows --arch AMD64The wheels will be available in the wheelhouse/ directory.
For development, you can install the package in editable mode:
cd py_bind
python setup.py prepare
pip install -e .pytest python/tests- Clean build artifacts before rebuilding:
rm -rf build/
rm -rf *.egg-info/
rm -rf dist/- Rebuild with verbose output:
python -m build -v- Ensure Python headers are installed:
python3-devon Linux - Check Python architecture matches compiler (32/64 bit)
- Verify virtual environment is activated if using one
- Linux: Run
sudo ldconfigafter installation - MacOS: Check
DYLD_LIBRARY_PATH - Windows: Verify PATH includes library directory