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.dev232-cp313-cp313-win_amd64.whl (26.8 MB view details)

Uploaded CPython 3.13Windows x86-64

pyvalhalla_weekly-3.5.1.post1.dev232-cp313-cp313-manylinux_2_28_x86_64.whl (87.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

pyvalhalla_weekly-3.5.1.post1.dev232-cp313-cp313-macosx_14_0_arm64.whl (70.5 MB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

pyvalhalla_weekly-3.5.1.post1.dev232-cp312-cp312-win_amd64.whl (26.8 MB view details)

Uploaded CPython 3.12Windows x86-64

pyvalhalla_weekly-3.5.1.post1.dev232-cp312-cp312-manylinux_2_28_x86_64.whl (87.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

pyvalhalla_weekly-3.5.1.post1.dev232-cp312-cp312-macosx_14_0_arm64.whl (70.5 MB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

pyvalhalla_weekly-3.5.1.post1.dev232-cp311-cp311-win_amd64.whl (26.8 MB view details)

Uploaded CPython 3.11Windows x86-64

pyvalhalla_weekly-3.5.1.post1.dev232-cp311-cp311-manylinux_2_28_x86_64.whl (87.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

pyvalhalla_weekly-3.5.1.post1.dev232-cp311-cp311-macosx_14_0_arm64.whl (70.5 MB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

pyvalhalla_weekly-3.5.1.post1.dev232-cp310-cp310-win_amd64.whl (26.8 MB view details)

Uploaded CPython 3.10Windows x86-64

pyvalhalla_weekly-3.5.1.post1.dev232-cp310-cp310-manylinux_2_28_x86_64.whl (87.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

pyvalhalla_weekly-3.5.1.post1.dev232-cp310-cp310-macosx_14_0_arm64.whl (70.5 MB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

pyvalhalla_weekly-3.5.1.post1.dev232-cp39-cp39-win_amd64.whl (26.8 MB view details)

Uploaded CPython 3.9Windows x86-64

pyvalhalla_weekly-3.5.1.post1.dev232-cp39-cp39-manylinux_2_28_x86_64.whl (87.8 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

pyvalhalla_weekly-3.5.1.post1.dev232-cp39-cp39-macosx_14_0_arm64.whl (70.5 MB view details)

Uploaded CPython 3.9macOS 14.0+ ARM64

File details

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev232-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 2f697a8f3ae751c7742dbe2e0d59b04422c8da1c0149278fca9be39fcfa2bc8d
MD5 6c8611b5d67f732503196eb0dea788b0
BLAKE2b-256 dd3e380580cb06af8063751f381465a29c7c9e3aa8a5ca359c8a7684b302d3b2

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvalhalla_weekly-3.5.1.post1.dev232-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.dev232-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev232-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 903c741105a62bda3e35819a0f1c2c72c08f5bdf97822493cd637d1b6237b63d
MD5 ffdc09ceca6cd5b82360c63ae8244da8
BLAKE2b-256 1f79b8ede046c84bf23ac0df37d1e11e75d2b161f342df4e4bcc6c37078db223

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvalhalla_weekly-3.5.1.post1.dev232-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.dev232-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev232-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 867a69be39936e37b08f9305c69d33715304de2b700b2a91eb018677fdf4fc34
MD5 c4547bc1ab38f535d7671db8c990b283
BLAKE2b-256 847ce5a84b7b7aa54058c64986247e6ae1dff59e779f9cdb0128703df23788ad

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvalhalla_weekly-3.5.1.post1.dev232-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.dev232-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev232-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 54a12818a4e46cece8918d8d12d29222c4c18b738a04ca3e80634bd59dad1214
MD5 7eb0a7741994a3c59dea2550126507df
BLAKE2b-256 bb340dc742005c5d9514f0b18f40e863493bbc98ee776433a1edb2b9d8a7da48

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvalhalla_weekly-3.5.1.post1.dev232-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.dev232-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev232-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ac328288e27af9d7c17cdebd5fe0cfd4c28130a61479bba4a62df2f65624022f
MD5 e21378fa59c1c421d40490b736331a34
BLAKE2b-256 75a8c9215be9a4b1ec41dc81a84594a005839ac86ec9d12b5e7a4eff236b5a43

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvalhalla_weekly-3.5.1.post1.dev232-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.dev232-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev232-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 5282af8c77be0ab143d32e9c815bb375c00c8e4688ee5429580ae9c50f5ac9b8
MD5 27c17755e76e5e1f536856a25b2690a2
BLAKE2b-256 4bf163c242a6d4cc865df9859e7b6a5c276cd7ce8183ff1ec603a6f5aea953a7

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvalhalla_weekly-3.5.1.post1.dev232-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.dev232-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev232-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 a7f510421c68f88abfb609d511860b37a83571e6ddafd2b643061ed74d7e6a98
MD5 a8db43ffa25cc3744cf32300bbbedb97
BLAKE2b-256 8985caa785c4d0eadc8e34818cfe9dac73249676446cf25369c2e5966b264b6d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvalhalla_weekly-3.5.1.post1.dev232-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.dev232-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev232-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ea598d961b2ca02626308e1f8b64954a333a17230b111658bc1acc9531a2bfbb
MD5 d7f7cc6c0b456d7526cb7ba23400d6ce
BLAKE2b-256 8ffab8aff1d12a94a083fc48ba3d72839a2dac657a199a536b05e15b32216324

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvalhalla_weekly-3.5.1.post1.dev232-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.dev232-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev232-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 8fdb399344fd125558e0e22b8874205c47f5c8d276e1ceba0c086694cf75c345
MD5 c8015a7457e475857b1705ed08a126e2
BLAKE2b-256 69c95a3181bfa2230655a433db8c7e820356898ea77b438a7dcd3891adea42a6

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvalhalla_weekly-3.5.1.post1.dev232-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.dev232-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev232-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 af8a5a01a94ef208ea60e9eca73ccf40b0d4c985c9f2d7d2607d31c219ba4b8a
MD5 8f1382adfa25c16c6b30dff69c37ed6a
BLAKE2b-256 9388f1dac86f94b31d5695f7a63c3b68ffa434497deef48b9e17d9ad8957f95a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvalhalla_weekly-3.5.1.post1.dev232-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.dev232-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev232-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 aa01a2b3bb9e708debb03b125f37bb4a4c59859d91c5bdea184d38959c08899e
MD5 af4280db4f580eaa1af82b62760606ec
BLAKE2b-256 0db8a58614d81127e42fce42a4ff584d26373708c39f84b2369f2c50142a0763

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvalhalla_weekly-3.5.1.post1.dev232-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.dev232-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev232-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 e66197b7c445957c293547319a5672e72d1a178c0a627752bed19d7d5b4e6d1c
MD5 5df7cc97fcd824a1fdb5d1bc1496b7c1
BLAKE2b-256 fca0724eed75cdb3d8b4e0b665cadb7e86c60e0e542866bb80a6d88ff74f5102

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvalhalla_weekly-3.5.1.post1.dev232-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.dev232-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev232-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 6a6dce1cb7dcfa8f45e6c01d5fb1b7087583a85f16149445e64bad82a3c4e3c9
MD5 b0cb3f511a30c8850d2e82f3d712e56b
BLAKE2b-256 b761b4b8d3d770e20816779c0735ebbe6421aebfc0685270889a5014c5c38d75

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvalhalla_weekly-3.5.1.post1.dev232-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.dev232-cp39-cp39-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev232-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0024f8869b5787a8a06b884df26df8db9c188cb9ab50d6ea2bde6f34a76365d4
MD5 cf39191b8487792558059a14ab78e829
BLAKE2b-256 df4f36b2d81a0eaefffdf8c38a292ab04624bb3006bb94f492d591a43658f52f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvalhalla_weekly-3.5.1.post1.dev232-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.dev232-cp39-cp39-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev232-cp39-cp39-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 fd979cef57acde47f01bb50fe8eeb68e594f56d1edf1225521cab3f9d2d87b5d
MD5 c7be50403384fe8af171cd5c77832aa6
BLAKE2b-256 28f60207e6b3b703bee85364172c435e59fb23c7f266fd30a4b533896115368d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyvalhalla_weekly-3.5.1.post1.dev232-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