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

Uploaded CPython 3.13Windows x86-64

pyvalhalla_weekly-3.5.1.post1.dev180-cp313-cp313-manylinux_2_28_x86_64.whl (85.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

pyvalhalla_weekly-3.5.1.post1.dev180-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.dev180-cp312-cp312-win_amd64.whl (27.4 MB view details)

Uploaded CPython 3.12Windows x86-64

pyvalhalla_weekly-3.5.1.post1.dev180-cp312-cp312-manylinux_2_28_x86_64.whl (85.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

pyvalhalla_weekly-3.5.1.post1.dev180-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.dev180-cp311-cp311-win_amd64.whl (27.4 MB view details)

Uploaded CPython 3.11Windows x86-64

pyvalhalla_weekly-3.5.1.post1.dev180-cp311-cp311-manylinux_2_28_x86_64.whl (85.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

pyvalhalla_weekly-3.5.1.post1.dev180-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.dev180-cp310-cp310-win_amd64.whl (27.4 MB view details)

Uploaded CPython 3.10Windows x86-64

pyvalhalla_weekly-3.5.1.post1.dev180-cp310-cp310-manylinux_2_28_x86_64.whl (85.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

pyvalhalla_weekly-3.5.1.post1.dev180-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.dev180-cp39-cp39-win_amd64.whl (27.4 MB view details)

Uploaded CPython 3.9Windows x86-64

pyvalhalla_weekly-3.5.1.post1.dev180-cp39-cp39-manylinux_2_28_x86_64.whl (85.5 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

pyvalhalla_weekly-3.5.1.post1.dev180-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.dev180-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev180-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 d091c54b12a546a0be345d3110f19d3ea61065248c20e5a0762825d70d6b8b2e
MD5 9c291e2fbb59ad04bf344e48520ebc10
BLAKE2b-256 8b4eb19a537860641dbe523bf6aa2b03323b193f5f51fc460010552d08745175

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev180-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1491cba5535effd8781aac812345f1f966820cdc71af3b2fe12fb6edcfbc97da
MD5 68f1da00ce6552069560c0a8679a684f
BLAKE2b-256 d094f830f59b63c43b7f5e1d206d39560a3db0880584ff45380eea6a00ffbc79

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev180-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 82aa011ffce9df9e36ced0655384ca1b3185bcc53f96cc1395d324448457d669
MD5 e924b3c7cd781767a26889266fb1d54e
BLAKE2b-256 190a253c4c82af3637cb18e9b7d19b64fcc6297b51bb343b0fe04a3293c3cb8f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev180-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 d2bbc9343dc7565ec7272185bb8ad65ad48cad088d6a1fca675910b1998a4979
MD5 0c4edf286b041ea007c745ba2b599046
BLAKE2b-256 d5943cd0771297fed7f21a2bbef3d033855e99745f4da1bad5d63df44aacbaf3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev180-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f65909eac4d05eed61ad87d8f5c839df71c948fa71bc5707297798c3ec472000
MD5 181d178577d88b2dd0c4debc1e1d1aea
BLAKE2b-256 dcf23a57c9f1e9316cbdc0a77a6068c3acbf5ea23b503bf5280448cd90d734d8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev180-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 659274a6088d3f448541de4b7035fab55ee299ef21b89c719bb9154277ec7b68
MD5 f8a90f9f81662b2927f15dbb6c8ef2da
BLAKE2b-256 fa626c98db3b2c7201a6af0af3d8c3334a073823873cb91b760c3c1ed5147917

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev180-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 1008f450901633c5ebaabca88e966d77e6356f133f0c050b7ab5dd1b11290aae
MD5 5970cb3ce756dfdea59691a63257ec05
BLAKE2b-256 00a1c2c0c5e1a9bb75504b84db1d9edf1c02a37ac11f8d3d014eae40acc453fd

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev180-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 cad9901e17fdc65f8a09ec45337ff8f578c64cd2b9813de02ea1b9b150c0e178
MD5 09504f3c02cb19aabcb2782269ecb974
BLAKE2b-256 a315a0b9b00089455e696cfe1606c986af2da53dbf124039feed2f6a1a6b3c20

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev180-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 9c6857206151ec3ece34c26192e86f0db9a2bfd5f534d4d76173c69436180c0f
MD5 8aab2da5c75649003e5556dc92e3b6a1
BLAKE2b-256 92743b5f7340d49fb0adc09afd073dc7ff2080d7c5fa1cb65fcea9377f1e86eb

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev180-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 3a9d83b86c80a13fbf5e769ef3bb8e46afb05655c61ab0ac58ef64d5e2b9b18d
MD5 e67f7cedda6dee818265b0e48f9ca71a
BLAKE2b-256 027b56484c0a5dab42dc5b08c10b83706814247a171babf293891f36a1f76e2f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev180-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a6e1be462f694095a53b8a16c65afb5c2626c6df54f86f81aa6e332d80c50915
MD5 d86e0ba409ac596c544256f1a6212e34
BLAKE2b-256 47722b9769ffc1bbb7caf529ca8bf25bbbe8470920e3db3762c0496f4cff379a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev180-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 954bda701f0f55fa3de5310ecd1aaee1b06e51dc5be8f82b88c8fa75319a4016
MD5 39ed6f87b4d7337fe406498bcd9a8f45
BLAKE2b-256 1af3a191783963170bce3ba87552c52f72fa63b166c459c4fab30cab2c939e90

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev180-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 55d94f67e5cf24134add48796e3c8cfb03af64de4ba5c17c434bcdad03f1e1ee
MD5 3910815b680ca1c2ff3bdac4d9b332a4
BLAKE2b-256 64f76dc365c8e9d82806d43e38622d38ed40c439b0627a3f6dbe426037a182ef

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev180-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fc5bd11a0eb5fab127771463595e3e85a75cdb0c0b23c629465f31163c0fd218
MD5 a452924b46f51e4a5961bd24e8ca8a77
BLAKE2b-256 a3ac741ce98dba90aa2d6526b412be6e6ca085a65ac30c74f20b4cfe680ec233

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev180-cp39-cp39-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 81a6365c5b04e222f1f39af62c4155f61b0b6af6f550afe41c4d9d76935ec87b
MD5 71f47750fe6cf2e1fe02021a1c7441a3
BLAKE2b-256 627cc153187254d550f19e474dafac1c909e1d2d6b6849d4433c3f8798586de5

See more details on using hashes here.

Provenance

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