Skip to main content

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.

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.8.0.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.8.0-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.8.0-cp312-abi3-manylinux_2_28_aarch64.whl (20.0 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.28+ ARM64

osrm_bindings-26.8.0-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.8.0-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.8.0.tar.gz.

File metadata

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

File hashes

Hashes for osrm_bindings-26.8.0.tar.gz
Algorithm Hash digest
SHA256 ef32c37c6be94db844f7cc0c84bb4e249b62f836791762c2736580a1bb951a8e
MD5 2a758034e709b271491bc63461d65441
BLAKE2b-256 5e3deae861c5afca8a79da9c9f3a40f4bcf7a5793ab694184b6c21ec49ea61e0

See more details on using hashes here.

Provenance

The following attestation bundles were made for osrm_bindings-26.8.0.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.8.0-cp312-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for osrm_bindings-26.8.0-cp312-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a41ea5cceb560b854be937fc7f25243d9037b71d0fe38bd944dcb8b598b3e24b
MD5 390ec5957bb1986ffc3c95251b263d46
BLAKE2b-256 d51d1f4370197602cfb442c497a4c139ae34cd5538af5a5ca0bf23b33c1dac4f

See more details on using hashes here.

Provenance

The following attestation bundles were made for osrm_bindings-26.8.0-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.8.0-cp312-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for osrm_bindings-26.8.0-cp312-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 c98cf346cf8373f565e2b95ca541628b5099f40eb62c9cd6c0be6cd75d6a7fc0
MD5 d8670aed4115de02e606c1b0422f1998
BLAKE2b-256 4f382813692625eb315b641b3c881181866b2eff67af6c1cc6f3068ba889df63

See more details on using hashes here.

Provenance

The following attestation bundles were made for osrm_bindings-26.8.0-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.8.0-cp312-abi3-macosx_15_0_x86_64.whl.

File metadata

File hashes

Hashes for osrm_bindings-26.8.0-cp312-abi3-macosx_15_0_x86_64.whl
Algorithm Hash digest
SHA256 c9d0a0ef4ba0eae69b7c385b7aeff5ba1ee270d10f568ee8eb89f8a7babcda6e
MD5 cb0614ef608a9cb5a747ad7dbdf1c593
BLAKE2b-256 a0a4ce7c19ebd58e6e2b2ea1e83dd39d454bb75e9923a55638cc36e13212b7e8

See more details on using hashes here.

Provenance

The following attestation bundles were made for osrm_bindings-26.8.0-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.8.0-cp312-abi3-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for osrm_bindings-26.8.0-cp312-abi3-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 d0933882f126bbe09216a8d0c180a1a4c540b3c55dc09f9c3f1a2c324f4e24c6
MD5 8bb965273ae68074caa111ffc7f4cac8
BLAKE2b-256 ef2192612f75522256adebd5ca4fea8d2a7a12a992ec0f5137fbfa58ede83baa

See more details on using hashes here.

Provenance

The following attestation bundles were made for osrm_bindings-26.8.0-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.

Release history Release notifications | RSS feed

This release

26.8.0 This release

5 files

26.7.3

5 files

26.7.2

4 files

0.3.0

4 files

0.2.0

3 files

0.1.0

2 files

Supported by

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