Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

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.

Metadata

Release files for pyvalhalla-weekly 3.5.1.post1.dev248

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for pyvalhalla-weekly 3.5.1.post1.dev248
File
pyvalhalla_weekly-3.5.1.post1.dev248-cp313-cp313-manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ x86-64 Details
pyvalhalla_weekly-3.5.1.post1.dev248-cp313-cp313-macosx_14_0_arm64.whl CPython 3.13 CPython 3.13 macOS 14.0+ ARM64 Details
pyvalhalla_weekly-3.5.1.post1.dev248-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
pyvalhalla_weekly-3.5.1.post1.dev248-cp312-cp312-manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ x86-64 Details
pyvalhalla_weekly-3.5.1.post1.dev248-cp312-cp312-macosx_14_0_arm64.whl CPython 3.12 CPython 3.12 macOS 14.0+ ARM64 Details
pyvalhalla_weekly-3.5.1.post1.dev248-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
pyvalhalla_weekly-3.5.1.post1.dev248-cp311-cp311-manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64 Details
pyvalhalla_weekly-3.5.1.post1.dev248-cp311-cp311-macosx_14_0_arm64.whl CPython 3.11 CPython 3.11 macOS 14.0+ ARM64 Details
pyvalhalla_weekly-3.5.1.post1.dev248-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
pyvalhalla_weekly-3.5.1.post1.dev248-cp310-cp310-manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ x86-64 Details
pyvalhalla_weekly-3.5.1.post1.dev248-cp310-cp310-macosx_14_0_arm64.whl CPython 3.10 CPython 3.10 macOS 14.0+ ARM64 Details

Total release size: 714.8 MB

Release files / pyvalhalla_weekly-3.5.1.post1.dev248-cp313-cp313-manylinux_2_28_x86_64.whl

Download URL pyvalhalla_weekly-3.5.1.post1.dev248-cp313-cp313-manylinux_2_28_x86_64.whl
Size 87.9 MB
Tags CPython 3.13 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
b8280dc2b83b31e9df7dfc78a065daca73732d61b6800e63e5a40ec9bb89952b
BLAKE2b-256 checksum
How to use checksums
0fdb9f46b8941c0206f84cd7e5ac9cd6ddce602c03d3505c67925cd08e4da65d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 5, 2025.

Transparency log

Release files / pyvalhalla_weekly-3.5.1.post1.dev248-cp313-cp313-macosx_14_0_arm64.whl

Download URL pyvalhalla_weekly-3.5.1.post1.dev248-cp313-cp313-macosx_14_0_arm64.whl
Size 70.6 MB
Tags CPython 3.13 macOS 14.0+ ARM64
SHA-256 checksum
How to use checksums
21ac2c873b73c2acde15bc7e57392ba69e6d3451a77b8cfd114091ae40ffe95b
BLAKE2b-256 checksum
How to use checksums
d456ee36f70e7e4da59fa0fc442ddd7b90d8b1c5c30bce0aac2825cf12c339e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 5, 2025.

Transparency log

Release files / pyvalhalla_weekly-3.5.1.post1.dev248-cp312-cp312-win_amd64.whl

Download URL pyvalhalla_weekly-3.5.1.post1.dev248-cp312-cp312-win_amd64.whl
Size 26.9 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
b6b1c61133d0136d17d10fd64f8c031a45b44781fc83b52f6f5ddc7cbdfbfd53
BLAKE2b-256 checksum
How to use checksums
f574465f55bacfe107592b6b86fe36d6072daaaa4bc257b029085440ef719141
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 5, 2025.

Transparency log

Release files / pyvalhalla_weekly-3.5.1.post1.dev248-cp312-cp312-manylinux_2_28_x86_64.whl

Download URL pyvalhalla_weekly-3.5.1.post1.dev248-cp312-cp312-manylinux_2_28_x86_64.whl
Size 87.9 MB
Tags CPython 3.12 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
4c90637cdd2a71edf75a3068c1aadab958fed3b0deaa82f122385045e83597cf
BLAKE2b-256 checksum
How to use checksums
541b05d79c49b7e7bfda0f384f6aeced115874e4c8421f79c3b18aca06635aaf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 5, 2025.

Transparency log

Release files / pyvalhalla_weekly-3.5.1.post1.dev248-cp312-cp312-macosx_14_0_arm64.whl

Download URL pyvalhalla_weekly-3.5.1.post1.dev248-cp312-cp312-macosx_14_0_arm64.whl
Size 70.6 MB
Tags CPython 3.12 macOS 14.0+ ARM64
SHA-256 checksum
How to use checksums
55dba506f8099a2429e6533be0228ad6df9e8c35fa002ff364a39636d2f4ecfd
BLAKE2b-256 checksum
How to use checksums
7dc14c207fff4e9a84845921f227b388116ad78a250eda8864620b270afeb39f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 5, 2025.

Transparency log

Release files / pyvalhalla_weekly-3.5.1.post1.dev248-cp311-cp311-win_amd64.whl

Download URL pyvalhalla_weekly-3.5.1.post1.dev248-cp311-cp311-win_amd64.whl
Size 26.9 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
c4da97ad32eac4f37ca55be28dce0304b4d20727b528289e3b8096e38e3d032a
BLAKE2b-256 checksum
How to use checksums
98d81d215631fc5de9b08da0d9b6298a06e64abf60858e5d9080d710268866b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 5, 2025.

Transparency log

Release files / pyvalhalla_weekly-3.5.1.post1.dev248-cp311-cp311-manylinux_2_28_x86_64.whl

Download URL pyvalhalla_weekly-3.5.1.post1.dev248-cp311-cp311-manylinux_2_28_x86_64.whl
Size 87.9 MB
Tags CPython 3.11 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
ac138fd26af5dd6c3f2381d4604dc2b266eca7928346595dae232a14f320c5ea
BLAKE2b-256 checksum
How to use checksums
0795791ee0524ba7d396efa9202f97c184400cc3570906e84654c02a7af91d0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 5, 2025.

Transparency log

Release files / pyvalhalla_weekly-3.5.1.post1.dev248-cp311-cp311-macosx_14_0_arm64.whl

Download URL pyvalhalla_weekly-3.5.1.post1.dev248-cp311-cp311-macosx_14_0_arm64.whl
Size 70.6 MB
Tags CPython 3.11 macOS 14.0+ ARM64
SHA-256 checksum
How to use checksums
b461f852765b1553233da733eabe04a3bc60ad1b30ffbca344c5f504ca8b4b29
BLAKE2b-256 checksum
How to use checksums
1ecc2fd094f64242a010bd7499ecb8636bc361511724ffb739c4fc6d72c6b90c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 5, 2025.

Transparency log

Release files / pyvalhalla_weekly-3.5.1.post1.dev248-cp310-cp310-win_amd64.whl

Download URL pyvalhalla_weekly-3.5.1.post1.dev248-cp310-cp310-win_amd64.whl
Size 26.9 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
43ddd41a5fa78301ac7fa2d0f8091d97fece8c592b00c560ad3b74f0a47c82ba
BLAKE2b-256 checksum
How to use checksums
219ce4172a8b647ca9e79357cdf1b9b84c759376bd6f1f07c52f82ed17b0cce3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 5, 2025.

Transparency log

Release files / pyvalhalla_weekly-3.5.1.post1.dev248-cp310-cp310-manylinux_2_28_x86_64.whl

Download URL pyvalhalla_weekly-3.5.1.post1.dev248-cp310-cp310-manylinux_2_28_x86_64.whl
Size 87.9 MB
Tags CPython 3.10 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
08699d932ba8c6c6047263549af76b1384d1cdf9ff4ff627596aa73fc07009fb
BLAKE2b-256 checksum
How to use checksums
ad162b4072c8cbbc51e3385976887d65c855b9fd359dc86a7046f577e299ba76
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 5, 2025.

Transparency log

Release files / pyvalhalla_weekly-3.5.1.post1.dev248-cp310-cp310-macosx_14_0_arm64.whl

Download URL pyvalhalla_weekly-3.5.1.post1.dev248-cp310-cp310-macosx_14_0_arm64.whl
Size 70.6 MB
Tags CPython 3.10 macOS 14.0+ ARM64
SHA-256 checksum
How to use checksums
1e6a45865431bce81ac3b60c39f01a11fef5ab263cf2ebcce65d6f5e4e8ea9d9
BLAKE2b-256 checksum
How to use checksums
dafa4bbcf76edb48da99416e41cf9cb5f19e3b6e3878ce545ffc275ef9224a8d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 5, 2025.

Transparency log
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page