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 (linux-x86_x64 only)

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

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.

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-manylinux_x86_64

On Linux, this might download the manylinux docker image. In the end, you'll find the wheel in ./wheelhouse.

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

Uploaded CPython 3.13Windows x86-64

pyvalhalla_weekly-3.5.1.post1.dev207-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.dev207-cp313-cp313-macosx_14_0_arm64.whl (70.4 MB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

pyvalhalla_weekly-3.5.1.post1.dev207-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.dev207-cp312-cp312-macosx_14_0_arm64.whl (70.4 MB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

pyvalhalla_weekly-3.5.1.post1.dev207-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.dev207-cp311-cp311-macosx_14_0_arm64.whl (70.4 MB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

pyvalhalla_weekly-3.5.1.post1.dev207-cp310-cp310-manylinux_2_28_x86_64.whl (87.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

pyvalhalla_weekly-3.5.1.post1.dev207-cp310-cp310-macosx_14_0_arm64.whl (70.4 MB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

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

Uploaded CPython 3.9Windows x86-64

pyvalhalla_weekly-3.5.1.post1.dev207-cp39-cp39-manylinux_2_28_x86_64.whl (87.7 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

pyvalhalla_weekly-3.5.1.post1.dev207-cp39-cp39-macosx_14_0_arm64.whl (70.4 MB view details)

Uploaded CPython 3.9macOS 14.0+ ARM64

File details

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev207-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 f177e4ff6a108347e31e3087342c9dd23492175102477657bf75df6f1383b36c
MD5 53d0d35b6aabbea19fc6fe44adae6bfe
BLAKE2b-256 18138b35fdf8b85d9adbcd8590fe5becb7fc5f559b1bd9a326e4c983cfaee401

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev207-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6ea33bf2360d7844df14f4598bc96d2b679a2e934632f27e275e9743fe6f111d
MD5 5d80157359375997af0b336e7e317738
BLAKE2b-256 e8391cb7a2e7dbf5f9b452005fbdef96f1ef7ef7146750da4bf39ebebcf942aa

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev207-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 d52f7640836512f445c17f64a9fa532a8f40515a2c021364a22df67a659f5ce2
MD5 ec3e48f0c50e4a1b75faaa0f56a13746
BLAKE2b-256 fe63d87f17ee2d94c72e226c68e5eb4e4711e7d4f0914486dfee99aba1bf856a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev207-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 d6c57bcc9cdad70e956b6e5e9d67b8f9f9de79314f9e36d7d2f7e327f25f89e6
MD5 f8d9404718642b442340dfbaa7ee75a1
BLAKE2b-256 2dd583776821d56c9ae2976b20a667e68ae63c5c7022ec39231c2787f4f674d7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev207-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b234648f4bd6356fabf6165acbbb3628b7d72acdca98d4f52bf40095a1ed21ee
MD5 a1ab2a7d584f134d03735a5a48e3837c
BLAKE2b-256 eeecef17bf1e8b39186b09bdbc403bc269b001876bfe19a9a2063602f52fbe71

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev207-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 259978f9b75022a0d79fcc14dff2a5a7d1212ed39250f7ec09323e322ba55b7b
MD5 2ad2aa22140219170d39e506d794daac
BLAKE2b-256 108879beaf17fe9e0dafae76f3f1e02e74341833e89aa308192d025ad6ebe42f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev207-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 20ed6945da9759649ea7e6972089b986d4b8850a1e2212a455025b0e6254f58c
MD5 85bd0b9071a950362b150dfa5ae4e148
BLAKE2b-256 386816d7a812dc3df2591ac1371fec8d7a0befde65e9a54094d9047af6f0d896

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev207-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 344ddfa9f87cdb36917cde68ed78c8c16371a94a373bcebe4b86f7f0973e92bc
MD5 d0814052219b11ec231d8ad89a21b87d
BLAKE2b-256 48875151dceae4876a4909223dcd79a5853a84a38dac664b611bcd2dcbb7a0d2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev207-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 0c0eabc2012e697bf5e0299796351e78144861fd90b0804024bbc8e7d4a25891
MD5 302d442f19fa0615e763e910925d1fe7
BLAKE2b-256 9801172f24bcdb5a1d48577618a1cda4a4b810f2a4a42150165c5e9348e992d7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev207-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 a43c328502e265be8c2e236b045ca54b149e7c929eee7f32326a45c6b8d1bcfd
MD5 c0aac3e1fde1f7e43cb32bd48efcb64f
BLAKE2b-256 b5cf0d420879e91967673c42a673dbe92ebc33b8345a620237a13e721f057bfa

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev207-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a6f5d58d1435e1ff65b6f98783a6ff3d0c5367bda0c8e32272d614b6700ce7cf
MD5 cba726e39784eaa8e4811fdb2b7d57c1
BLAKE2b-256 bd705c41f8d513cf8ed1d13d97c4a19a914646d31e765a80d84e5f35d8f88835

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev207-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 b18882c891265422a18158b7369866a0ce9b3e50aa900379cf5c79ed1fb1f7b2
MD5 a1b154f174af25669a833a2661eb218a
BLAKE2b-256 469b24243a3d0c50754cbd49a6109d00107cab63d90ff7584b0ab6b19f6687ae

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev207-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 fa4d2eac5c5199447155d0bc8dca507be35d4256e3730f32ac0e4ab84cf4a1c5
MD5 ed5a296702527793cc6c724e6dbec275
BLAKE2b-256 68f1678e627b236900d308fa0a1b814c92b86864213f9b74a0b910425c7020e8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev207-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1925e5d0f9165b301b9e9da416baad4b0c9362a5cc49722d25952129be684056
MD5 10b1e6bbaef36cdb0a0d1d6143294533
BLAKE2b-256 483a2e0d7c3de1b20cc2605606a850eb64faad18cad08c3b1d57e21c715cbe1d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev207-cp39-cp39-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 707a53da11465e139f0fa4f845443b19a23355677e110358148b66b1b458fba1
MD5 27530968505c8ec8e784897a43af33e3
BLAKE2b-256 97a6878a20707443b9434a6fe88a796c68833a57fb11f8d72e48a4f2543925d2

See more details on using hashes here.

Provenance

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