Skip to main content

Python bindings for the osrm-backend project

Project description

osrm-bindings

Python bindings for osrm-backend using nanobind.

PyPI

pip install osrm-bindings

[!NOTE] On PyPI we only distribute abi3 wheels for each platform, i.e. one needs at least Python 3.12 to install the wheels. Of course it'll fall back to attempt an installation from source.

Platform Arch
Linux x86_64
MacOS aarch64
MacOS arm64
Windows x86_64

From Source

osrm-bindings requires CPython 3.10+ and can be installed from source (e.g. from an sdist on PyPI) by running the following command in the repository root:

pip install .

The Python bindings are built alongside the OSRM C++ libraries. The version of the bindings matches the version of osrm-backend.

System dependencies

A source/sdist build compiles the full OSRM C++ library, so the usual C++ toolchain (CMake ≥ 3.18, a C++20 compiler, Git) plus OSRM's native dependencies must be available. Also a development Python installation has to be in the PATH.

Debian / Ubuntu

sudo apt-get install -y \
    cmake g++ git pkg-config \
    libboost-all-dev libbz2-dev liblua5.4-dev \
    libtbb-dev libxml2-dev libzip-dev

Fedora / RHEL / Rocky / AlmaLinux

sudo dnf install -y \
    cmake gcc-c++ git pkgconf-pkg-config \
    boost-devel bzip2-devel lua-devel \
    tbb-devel libxml2-devel libzip-devel

macOS (Homebrew)

brew install cmake lua tbb boost@1.90
brew link boost@1.90

Windows (vcpkg + MSVC)

Windows builds use vcpkg to provide OSRM's C++ dependencies and require a recent MSVC toolset (Visual Studio 2022 or later).

Example steps (PowerShell / Developer Command Prompt):

# Clone & bootstrap vcpkg
git clone https://github.com/microsoft/vcpkg.git C:\vcpkg
cd C:\vcpkg
.\bootstrap-vcpkg.bat

cmake --preset release
cmake --build buildß

If installing from a pip sdist, ensure CMake is configured to use the same vcpkg toolchain file (pass the toolchain via CMake args when building the wheel or use the same environment when running pip install).

Example

The following example will showcase the process of calculating routes between two coordinates.

First, import the osrm library, and instantiate an instance of OSRM:

import osrm

# Instantiate osrm_py instance
osrm_py = osrm.OSRM("./test/data/ch/monaco.osrm")

Then, declare RouteParameters, and then pass it into the osrm_py instance:

# Declare Route Parameters
route_params = osrm.RouteParameters(
    coordinates = [(7.41337, 43.72956), (7.41546, 43.73077)]
)

# Pass it into the osrm_py instance
res = osrm_py.Route(route_params)

# Print out result output
print(res["waypoints"])
print(res["routes"])

Type Stubs

The file src/python/osrm/osrm_ext.pyi contains auto-generated type stubs for the C++ extension module. These are used by IDEs for autocompletion and by documentation tools without compiling the extension.

After changing C++ bindings, rebuild the project to regenerate the stubs:

pip install -e .

Then commit the updated .pyi file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

osrm_bindings-26.7.3.tar.gz (36.0 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

osrm_bindings-26.7.3-cp312-abi3-manylinux_2_28_x86_64.whl (19.5 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.28+ x86-64

osrm_bindings-26.7.3-cp312-abi3-manylinux_2_28_aarch64.whl (20.0 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.28+ ARM64

osrm_bindings-26.7.3-cp312-abi3-macosx_15_0_x86_64.whl (6.2 MB view details)

Uploaded CPython 3.12+macOS 15.0+ x86-64

osrm_bindings-26.7.3-cp312-abi3-macosx_15_0_arm64.whl (5.5 MB view details)

Uploaded CPython 3.12+macOS 15.0+ ARM64

File details

Details for the file osrm_bindings-26.7.3.tar.gz.

File metadata

  • Download URL: osrm_bindings-26.7.3.tar.gz
  • Upload date:
  • Size: 36.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for osrm_bindings-26.7.3.tar.gz
Algorithm Hash digest
SHA256 4e47b48347d298993474181e46d2ff376f496995c02149ad0f5b49e33fc6c8ca
MD5 11d614ef2d970e8fc4ba358fa9c88b3c
BLAKE2b-256 433fdbb4e9bf0432e84924ae1351d3e152b26c9d3fc094273c047b9cc1323784

See more details on using hashes here.

Provenance

The following attestation bundles were made for osrm_bindings-26.7.3.tar.gz:

Publisher: release-monthly.yml on Project-OSRM/osrm-backend

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file osrm_bindings-26.7.3-cp312-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for osrm_bindings-26.7.3-cp312-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c4dda220c8e59ae3ead242d2efe24a2389afb70d2bd238052b8a6334c77719f5
MD5 e6bdfabedd37c0708c6a247f72f56c4e
BLAKE2b-256 53127d75aef1283ffdc7aba9d84b613f95c4501d867624261817a7bd4b037a8e

See more details on using hashes here.

Provenance

The following attestation bundles were made for osrm_bindings-26.7.3-cp312-abi3-manylinux_2_28_x86_64.whl:

Publisher: release-monthly.yml on Project-OSRM/osrm-backend

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file osrm_bindings-26.7.3-cp312-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for osrm_bindings-26.7.3-cp312-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 09dee5e6d8fdff04bab717a6a7668c30666bcb6115b2eb2af35c08596e3b35ba
MD5 3c3dd5e2fb53fea687bc61849b590d77
BLAKE2b-256 3acb60e7459c454954508cbdb56487bd04c25391f98567d8d56eca595866aee9

See more details on using hashes here.

Provenance

The following attestation bundles were made for osrm_bindings-26.7.3-cp312-abi3-manylinux_2_28_aarch64.whl:

Publisher: release-monthly.yml on Project-OSRM/osrm-backend

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file osrm_bindings-26.7.3-cp312-abi3-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for osrm_bindings-26.7.3-cp312-abi3-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 bc8014b097ea8bb5d289d38422c790e371b24f0e2b1735c4464de5262e273352
MD5 c7b64705dcebef5ed27378106cdd5dbf
BLAKE2b-256 091ac64fdc72841c7897650d841a527dd2578a741d8572798265a024b4a49fe9

See more details on using hashes here.

Provenance

The following attestation bundles were made for osrm_bindings-26.7.3-cp312-abi3-macosx_15_0_x86_64.whl:

Publisher: release-monthly.yml on Project-OSRM/osrm-backend

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file osrm_bindings-26.7.3-cp312-abi3-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for osrm_bindings-26.7.3-cp312-abi3-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 58ffbae34e94d0afe16c6d1ff5e17d0dc5ec709eb4c629f8965a15fd30312a30
MD5 accbc1530c19b9b1c33e5444c4c380f5
BLAKE2b-256 e81a5c6ab2b16d1c19c2041409e02464377e22df79721113c761c6e52b1cb0eb

See more details on using hashes here.

Provenance

The following attestation bundles were made for osrm_bindings-26.7.3-cp312-abi3-macosx_15_0_arm64.whl:

Publisher: release-monthly.yml on Project-OSRM/osrm-backend

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page