Skip to main content

Python bindings for the osrm-backend project

Project description

osrm-bindings

PUSH_CI

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


PyPI Supported Platforms

Platform Arch
Linux x86_64
MacOS x86_64
Windows x86_64

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.

Installation

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

File metadata

File hashes

Hashes for osrm_bindings-0.1.0-cp312-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4949dce7da7ec04d14cfc31a74f460812f152ca51d054017345a78c04dcbb84d
MD5 ab41d52eeaf7906c3fe30c458d4e1298
BLAKE2b-256 8783c63869704f41715114108658ea5f400a9f9ace2c9d21de9894127d3d6203

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for osrm_bindings-0.1.0-cp312-abi3-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 5cdba4e2656324c8655507f8db0f2661cc1280ed4cdbd5811fcbed335c67c7e6
MD5 c66fb44ca46a64262f4a88559d39f2c1
BLAKE2b-256 c7cffab06b9c2c32a4246e9ce660e54515c2fc06e127b6574f5b7cf29fad8696

See more details on using hashes here.

Provenance

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