Skip to content

Latest commit

 

History

History
121 lines (92 loc) · 2.32 KB

File metadata and controls

121 lines (92 loc) · 2.32 KB

Building OpenPTV Python Package

Prerequisites

  • Python 3.10 or newer
  • CMake 3.15 or newer
  • C compiler (gcc, clang, or MSVC)
  • pip

Build Steps

  1. Install build dependencies:
python -m pip install --upgrade pip
python -m pip install build numpy cython
  1. Build the package:
# From the root directory
python -m build
  1. Install the built package:
pip install dist/*.whl

Creating Binary Wheels

Local Binary Wheels

To create platform-specific binary wheels:

  1. Navigate to the py_bind directory:
cd py_bind
  1. Clean previous build artifacts:
rm -rf build/ dist/ *.egg-info/
rm -rf optv/*.c  # Remove Cython-generated files
  1. Prepare the source files:
python setup.py prepare
  1. 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

Building Wheels for Multiple Platforms

For building wheels for multiple platforms and Python versions, we use cibuildwheel:

  1. Install cibuildwheel:
pip install cibuildwheel
  1. 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 AMD64

The wheels will be available in the wheelhouse/ directory.

Development Installation

For development, you can install the package in editable mode:

cd py_bind
python setup.py prepare
pip install -e .

Running Tests

pytest python/tests

Troubleshooting

Build Issues

  • Clean build artifacts before rebuilding:
rm -rf build/
rm -rf *.egg-info/
rm -rf dist/
  • Rebuild with verbose output:
python -m build -v

Python Issues

  • Ensure Python headers are installed: python3-dev on Linux
  • Check Python architecture matches compiler (32/64 bit)
  • Verify virtual environment is activated if using one

Library Issues

  • Linux: Run sudo ldconfig after installation
  • MacOS: Check DYLD_LIBRARY_PATH
  • Windows: Verify PATH includes library directory