Skip to main content

Python bindings for the osrm-backend project

Project description

osrm-bindings

Push Master osrm-bindings version

osrm-bindings is a Python package that binds to osrm-backend using nanobind.

[!WARNING] osrm-bindings on Windows might not support map matching. See this issue on progress.


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 x86_64
Windows x86_64

From Source

osrm-bindings is (likely, didn't check) supported from CPython 3.10+ on, and can be installed from source via running the following command in the source folder:

pip install .

OSRM Version

When building from source, the OSRM upstream version is controlled by OSRM_GIT_REPO & OSRM_GIT_TAG in pyproject.toml:

[tool.scikit-build.cmake.define]
OSRM_GIT_REPO = "https://github.com/nilsnolde/osrm-backend"
OSRM_GIT_TAG = "de8a9da93aa09a4943d3964f0fb378a01a66af49"

This accepts any git commit hash, branch name, or tag. To override it without editing the file, pass it as a config setting at install time:

pip install . --config-settings cmake.define.OSRM_GIT_TAG=<commit/tag/branch>

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("./tests/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/osrm/osrm_ext.pyi contains auto-generated type stubs for the C++ extension module. These are used by IDEs for autocompletion and by mkdocstrings to build documentation without compiling the extension.

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

pip install -e .

Then commit the updated .pyi file. CI will verify that committed stubs are up to date.

Documentation

Documentation Page

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

osrm_bindings-0.2.0-cp312-abi3-win_amd64.whl (4.7 MB view details)

Uploaded CPython 3.12+Windows x86-64

osrm_bindings-0.2.0-cp312-abi3-manylinux_2_28_x86_64.whl (6.3 MB view details)

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

osrm_bindings-0.2.0-cp312-abi3-macosx_15_0_arm64.whl (19.7 MB view details)

Uploaded CPython 3.12+macOS 15.0+ ARM64

File details

Details for the file osrm_bindings-0.2.0-cp312-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for osrm_bindings-0.2.0-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 ae32aa90497a18ce935056ca0079f0744b497dae7ffa5e85ad7ab74ea31a9c2d
MD5 148744547bb6f50763bc326e4a4bf128
BLAKE2b-256 a97d91ed165a976bece99d2d18117009c219e0313cbd51d58883349435b4c55e

See more details on using hashes here.

Provenance

The following attestation bundles were made for osrm_bindings-0.2.0-cp312-abi3-win_amd64.whl:

Publisher: publish_wheels.yml on nilsnolde/osrm-bindings

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-0.2.0-cp312-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for osrm_bindings-0.2.0-cp312-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d1fb5085411d90a2ed622fe43868ee622c6baa76f2db93af039c1f9d7943f73a
MD5 0c4d1512f6276b813cc13224ca6a6240
BLAKE2b-256 dd55704f27548b181ad347ad91b978ab0e3bbe62cdebbff696e88ed0ca79ca1a

See more details on using hashes here.

Provenance

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

Publisher: publish_wheels.yml on nilsnolde/osrm-bindings

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-0.2.0-cp312-abi3-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for osrm_bindings-0.2.0-cp312-abi3-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 191eddca3da279aa5ab216b44dfb3f40afb15020ae9dd3da159fee7d2f118c36
MD5 580823829e6f915996f65dfa9a62a301
BLAKE2b-256 823c5890c0db69bf26d1e7e5a501e405ccc6d5fd983f563f08848278839f0cd0

See more details on using hashes here.

Provenance

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

Publisher: publish_wheels.yml on nilsnolde/osrm-bindings

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