Skip to main content

High-level bindings to the Valhalla C++ library

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

Valhalla Python bindings

pyvalhalla version pyvalhalla-weekly version

This folder contains the Python bindings to Valhalla routing engine.

[!NOTE] pyvalhalla(-weekly) packages are currently only published for:

  • linux-x86_x64
  • win-amd64
  • macos-arm64

On top of the (very) high-level Python bindings, we package some data-building Valhalla executables to ease the process of graph creation or run Valhalla as a service, see below.

Installation

We distribute all currently maintained CPython versions as binary wheels for Win64, MacOS (arm64) and Linux (x86_64) distributions with glibc>=2.28. We do not offer a source distribution on PyPI.

pip install pyvalhalla to install the most recent Valhalla release.
pip install pyvalhalla-weekly to install the weekly published Valhalla master commit.

Usage

Bindings

Find a more extended notebook in ./examples, e.g. how to use the actor.

Before using the Python bindings you need to have access to a routable Valhalla graph. Either install Valhalla from source and built the graph from OSM compatible data or use our Valhalla docker image for a painless experience, e.g. this will build the routing graph for Andorra in ./custom_files:

docker run --rm --name valhalla -p 8002:8002 -v $PWD/custom_files:/custom_files -e tile_urls=https://download.geofabrik.de/europe/andorra-latest.osm.pbf ghcr.io/valhalla/valhalla-scripted:latest

Once you have created a graph locally, you can use it like this:

from valhalla import Actor, get_config, get_help

# generate configuration
config = get_config(tile_extract='./custom_files/valhalla_tiles.tar', verbose=True)

# print the help for specific config items (has the same structure as the output of get_config()
print(get_help()["service_limits"]["auto"]["max_distance"])

# instantiate Actor to load graph and call actions
actor = Actor(config)
route = actor.route({"locations": [...]})

Valhalla executables

To access the C++ (native) executables, there are 2 options:

  • (recommended) execute the module, e.g. python -m valhalla valhalla_build_tiles -h
  • execute the Python wrapper scripts directly, e.g. valhalla_build_tiles -h

[!NOTE] For the latter option to work, the Python environment's bin/ folder has to be in the $PATH. Inside virtual environments, that's always the case.

Executing the scripts directly might also not work properly if there's a system-wide Valhalla installation, unless the Python environment's bin/ folder has higher priority than system folders in $PATH. The module execution uses an explicit Python executable which should be preferred.

There are also some additional commands we added:

  • --help: print the help for python -m valhalla explicitly
  • --quiet: redirect stdout of the C++ executables to /dev/null; can be added once anywhere in the command, will not be forwarded to a C++ executable
  • print_bin_path: simply prints the absolute path to the package-internal bin/ directory where the C++ executables are; useful if the executables should be accessed directly in some script

To find out which Valhalla executables are currently included, run python -m valhalla --help. We limit the number of executables to control the wheel size. However, we're open to include any other executable if there's a good reason.

Building from source

Note, building the bindings from source is usually best done by building Valhalla with cmake -B build -DENABLE_PYTHON_BINDING=ON .... However, if you want to package your own pyvalhalla bindings for some reason (e.g. fork in a bigger team), you can follow the below instructions, which are also executed by our CI.

cibuildwheel

On our CI, this orchestrates the packaging of all pyvalhalla wheels for every supported, minor Python version and every platform. It can also be run locally (obviously only being able to build wheels for your platform), e.g.

python -m pip install cibuildwheel
cibuildwheel --print-build-identifiers
cibuildwheel --only cp313-manylinux_x86_64

# for windows you'll have to set an env var to the vcpkg win root
VCPKG_ARCH_ROOT="build/vcpkg_installed/custom-x64-windows" cibuildwheel --only cp313-win_amd64

[!NOTE] On Windows & OSX we expect Valhalla to be built before running cibuildwheel. On Linux we use a manylinux image to orchestrate the build of both Valhalla and the bindings, see below.

The build looks at a few environment variables, some optional, some mandatory:

  • VALHALLA_BUILD_BIN_DIR (optional): Specify the relative/absolute path to the build artifacts of Valhalla, e.g. ./build, if you want to package the C++ executables
  • VALHALLA_VERSION_MODIFIER (optional): Will append a string to the actual Valhalla version string, e.g. $(git rev-parse --short HEAD) will append the current branch's commit hash.
  • VALHALLA_RELEASE_PKG: To determine the package name, mostly useful for packaging, expects one of pyvalhalla or pyvalhalla-weekly.
  • VCPKG_ARCH_ROOT (required for Win): The relative/absolute directory of the vcpkg root.

In the end, you'll find the wheel in ./wheelhouse.

Linux

To package arch-dependent Linux bindings we use a manylinux fork, where we install all dependencies into the manylinux_2_28 image, based on AlmaLinux 8. This is necessary to have a broad glibc compatibility with many semi-recent Linux distros.

Either pull the manylinux image, or build it locally for testing:

docker pull ghcr.io/valhalla/manylinux:2_28_valhalla_python

# or pull the image from ghcr.io
git clone https://github.com/valhalla/manylinux
cd manylinux
POLICY=manylinux_2_28 PLATFORM=x86_64 COMMIT_SHA=$(git rev-parse --verify HEAD) BUILDX_BUILDER=builder-docker-container ./build.sh
docker tag quay.io/pypa/manylinux_2_28_x86_64:$(git rev-parse --verify HEAD) ghcr.io/valhalla/manylinux:2_28_valhalla_python

Once built, start a container to actually build Valhalla using AlmaLinux 8:

cd valhalla
docker run -dt -v $PWD:/valhalla-py --name valhalla-py --workdir /valhalla-py ghcr.io/valhalla/manylinux:2_28_valhalla_python
docker exec -t valhalla-py /valhalla-py/src/bindings/python/scripts/build_manylinux.sh build_manylinux 3.13

This will also build & install libvalhalla before building the bindings. At this point there should be a wheelhouse folder with the fixed python wheel, ready to be installed or distributed to arbitrary python 3.12 installations.

Testing (linux-x86_x64 only)

We have a small test script which makes sure that all the executables are working properly. If run locally for some reason, install a pyvalhalla wheel first. We run this in CI in a fresh Docker container with no dependencies installed, mostly to verify dynamic linking of the vendored dependencies.

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.

pyvalhalla_weekly-3.5.1.post1.dev244-cp313-cp313-win_amd64.whl (26.9 MB view details)

Uploaded CPython 3.13Windows x86-64

pyvalhalla_weekly-3.5.1.post1.dev244-cp313-cp313-manylinux_2_28_x86_64.whl (87.9 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

pyvalhalla_weekly-3.5.1.post1.dev244-cp313-cp313-macosx_14_0_arm64.whl (70.6 MB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

pyvalhalla_weekly-3.5.1.post1.dev244-cp312-cp312-win_amd64.whl (26.9 MB view details)

Uploaded CPython 3.12Windows x86-64

pyvalhalla_weekly-3.5.1.post1.dev244-cp312-cp312-manylinux_2_28_x86_64.whl (87.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

pyvalhalla_weekly-3.5.1.post1.dev244-cp312-cp312-macosx_14_0_arm64.whl (70.6 MB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

pyvalhalla_weekly-3.5.1.post1.dev244-cp311-cp311-win_amd64.whl (26.9 MB view details)

Uploaded CPython 3.11Windows x86-64

pyvalhalla_weekly-3.5.1.post1.dev244-cp311-cp311-manylinux_2_28_x86_64.whl (87.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

pyvalhalla_weekly-3.5.1.post1.dev244-cp311-cp311-macosx_14_0_arm64.whl (70.6 MB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

pyvalhalla_weekly-3.5.1.post1.dev244-cp310-cp310-win_amd64.whl (26.9 MB view details)

Uploaded CPython 3.10Windows x86-64

pyvalhalla_weekly-3.5.1.post1.dev244-cp310-cp310-manylinux_2_28_x86_64.whl (87.9 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

pyvalhalla_weekly-3.5.1.post1.dev244-cp310-cp310-macosx_14_0_arm64.whl (70.6 MB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

pyvalhalla_weekly-3.5.1.post1.dev244-cp39-cp39-win_amd64.whl (26.9 MB view details)

Uploaded CPython 3.9Windows x86-64

pyvalhalla_weekly-3.5.1.post1.dev244-cp39-cp39-manylinux_2_28_x86_64.whl (87.9 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

pyvalhalla_weekly-3.5.1.post1.dev244-cp39-cp39-macosx_14_0_arm64.whl (70.6 MB view details)

Uploaded CPython 3.9macOS 14.0+ ARM64

File details

Details for the file pyvalhalla_weekly-3.5.1.post1.dev244-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev244-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 59265ebd9e24d0c4f7dbc850876ebbb9fb4e7c76fe3341fe4f70e6b1a8c2c7e4
MD5 4f34baf290d469b9cb91a4f56a843dae
BLAKE2b-256 a47cc196fe51e3c62d7b1fe6060e9e5d9124f418b987af680d6b41868585df36

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvalhalla_weekly-3.5.1.post1.dev244-cp313-cp313-win_amd64.whl:

Publisher: osx_win_python_builds.yml on valhalla/valhalla

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

File details

Details for the file pyvalhalla_weekly-3.5.1.post1.dev244-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev244-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9a9f06b09b76f69d3e942aed9c7b2b865d103c0bb8e1cf5a0d78bd86c6f8cda2
MD5 68dee4f97bb83d3264c03ff554f9da22
BLAKE2b-256 0355aeacf85ee3e7587d38584a260c6524eee7a73e5d7e19d81bd316c33dbcb8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvalhalla_weekly-3.5.1.post1.dev244-cp313-cp313-manylinux_2_28_x86_64.whl:

Publisher: osx_win_python_builds.yml on valhalla/valhalla

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

File details

Details for the file pyvalhalla_weekly-3.5.1.post1.dev244-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev244-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 1dd315a56121cd32ede02a51cec642c280972606c74560f0446b09c941085e4c
MD5 592cbabf5a42d0fdc031facd1b9681c8
BLAKE2b-256 88ffa6296f47d70d0081e27c800ae418f47f1647328fde201b9164786e11331c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvalhalla_weekly-3.5.1.post1.dev244-cp313-cp313-macosx_14_0_arm64.whl:

Publisher: osx_win_python_builds.yml on valhalla/valhalla

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

File details

Details for the file pyvalhalla_weekly-3.5.1.post1.dev244-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev244-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 bf1625d5eba363f3d9e55f8a7487c9ad0c450096c42121c0de497e6a06aa231d
MD5 80b1f80ecf6dbc6c138df6209ef464bc
BLAKE2b-256 78704aec44efdcc21749ed80bb9349d28adfb1647e1705c29b4531e8141e43b8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvalhalla_weekly-3.5.1.post1.dev244-cp312-cp312-win_amd64.whl:

Publisher: osx_win_python_builds.yml on valhalla/valhalla

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

File details

Details for the file pyvalhalla_weekly-3.5.1.post1.dev244-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev244-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ecfb1c4092bdc69aa9bb489c066f2baff1279d358fa75386123ae86f56d8e2bf
MD5 29091bff53221c51568f20d178c361c7
BLAKE2b-256 9b7b39e0fe229b6c8a56125b13bd17cebd91bc8f19ab57742c2c883388a4e804

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvalhalla_weekly-3.5.1.post1.dev244-cp312-cp312-manylinux_2_28_x86_64.whl:

Publisher: osx_win_python_builds.yml on valhalla/valhalla

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

File details

Details for the file pyvalhalla_weekly-3.5.1.post1.dev244-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev244-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 190bc5eca0c37002c47566c82d281b573175195b4debc36c70338a5283f6a2a6
MD5 d09ac221afd19d64646eba4944aa6c54
BLAKE2b-256 cddad012d24753eae69c75e3c8e901d102716d008d16d8525116ff3c7b1a250d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvalhalla_weekly-3.5.1.post1.dev244-cp312-cp312-macosx_14_0_arm64.whl:

Publisher: osx_win_python_builds.yml on valhalla/valhalla

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

File details

Details for the file pyvalhalla_weekly-3.5.1.post1.dev244-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev244-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 95a55340a75aa326317bc771236338bcc632b068750d7f80c2468dd3a3fa2257
MD5 ed1ad6df9cb04a99966baeb9e2951e8a
BLAKE2b-256 618a7b16235491fd9b14d79a97b5e8b65ccadfeded37d57d016c4ceae4c99870

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvalhalla_weekly-3.5.1.post1.dev244-cp311-cp311-win_amd64.whl:

Publisher: osx_win_python_builds.yml on valhalla/valhalla

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

File details

Details for the file pyvalhalla_weekly-3.5.1.post1.dev244-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev244-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c5010fcc3ee7666cd5d2dc8cc8c8d97a9aaf12333d8292e1683fb145eca46c66
MD5 c0b5b9268daa12c029fe8a957314663d
BLAKE2b-256 f997529812950e4ad720e4cfad3c00f8c2ff176af46ad81b9d63f6a72aaee32d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvalhalla_weekly-3.5.1.post1.dev244-cp311-cp311-manylinux_2_28_x86_64.whl:

Publisher: osx_win_python_builds.yml on valhalla/valhalla

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

File details

Details for the file pyvalhalla_weekly-3.5.1.post1.dev244-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev244-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 9ae574e3a3e8f7f4adf74ce22e57c096e7e586b3f5bafd3cb28dc0ae2bf05b7d
MD5 a6dfb42ecbbb2121aca5e3597c6653a1
BLAKE2b-256 7dd65d6c55cef2e0c3defee7a6378ebc3b4bdefffb0b1635d9e4f0973df5e849

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvalhalla_weekly-3.5.1.post1.dev244-cp311-cp311-macosx_14_0_arm64.whl:

Publisher: osx_win_python_builds.yml on valhalla/valhalla

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

File details

Details for the file pyvalhalla_weekly-3.5.1.post1.dev244-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev244-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 7b40d61531890426d2e34e916dd1eb2a5eba2802366c022f03d3dc7398227e9a
MD5 85011bfec456b5e0ef8c18252d0e173d
BLAKE2b-256 d65fc82113a5b73311dfb202711681da1dc56012b4d630dd6822a21fe603a284

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvalhalla_weekly-3.5.1.post1.dev244-cp310-cp310-win_amd64.whl:

Publisher: osx_win_python_builds.yml on valhalla/valhalla

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

File details

Details for the file pyvalhalla_weekly-3.5.1.post1.dev244-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev244-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3f2f20497c961f3bae7553eccffed0b8135e76856c392a95bcbb7f7d48540d3c
MD5 67cade75a1e416dd8935a9150a36c2bb
BLAKE2b-256 5949f62901225e51c94879a3803ee134ff5b8b0bdad91186215f625c92299f56

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvalhalla_weekly-3.5.1.post1.dev244-cp310-cp310-manylinux_2_28_x86_64.whl:

Publisher: osx_win_python_builds.yml on valhalla/valhalla

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

File details

Details for the file pyvalhalla_weekly-3.5.1.post1.dev244-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev244-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 c31ef97d71bbde38ab8a1d21996bfc309993658b3db629e950c63e41a419ebb9
MD5 cca7fcf7eacb578ab26b07a59b2700c6
BLAKE2b-256 55cfc4626c65d1c0ea8e337726aa5f7b5c6050bee91e32106af48eff76c2d300

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvalhalla_weekly-3.5.1.post1.dev244-cp310-cp310-macosx_14_0_arm64.whl:

Publisher: osx_win_python_builds.yml on valhalla/valhalla

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

File details

Details for the file pyvalhalla_weekly-3.5.1.post1.dev244-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev244-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 a35aad24d8e98656b4c184b69736e3575eb42140890ef4a5732179bcad1bfa6d
MD5 f67f5d2aa751e88592407c557d2ede73
BLAKE2b-256 4c7cbad4342746ab794500b7f2563dc1769a42f0e7242ea9b3d986ceff70926a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvalhalla_weekly-3.5.1.post1.dev244-cp39-cp39-win_amd64.whl:

Publisher: osx_win_python_builds.yml on valhalla/valhalla

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

File details

Details for the file pyvalhalla_weekly-3.5.1.post1.dev244-cp39-cp39-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev244-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7fe65452bff6bf3f5312b773c4cb6ccce79be76f9d1bfcaf93451559f86c07c3
MD5 295ed717437c607ce2499a2034cdf036
BLAKE2b-256 4854830937c4f76bef84af6768502af068e3634dbf3805b9f6d680df7f7f2052

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvalhalla_weekly-3.5.1.post1.dev244-cp39-cp39-manylinux_2_28_x86_64.whl:

Publisher: osx_win_python_builds.yml on valhalla/valhalla

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

File details

Details for the file pyvalhalla_weekly-3.5.1.post1.dev244-cp39-cp39-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev244-cp39-cp39-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 fa5086001347aff61adee9023a5e6069f84dd9b2cb62a27c1372fdab059f7e14
MD5 328d400262ff8b3c19385fbcf6ec6b06
BLAKE2b-256 15ad9d1b1642ce3787fe4de1c64009393a836603b8d0214a67ba252b716f8253

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvalhalla_weekly-3.5.1.post1.dev244-cp39-cp39-macosx_14_0_arm64.whl:

Publisher: osx_win_python_builds.yml on valhalla/valhalla

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