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

This folder contains the Python bindings to Valhalla routing engine.

[!NOTE] pyvalhalla(-git) 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.

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 most recent 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_gis-ops -p 8002:8002 -v $PWD/custom_files:/custom_files -e tile_urls=https://download.geofabrik.de/europe/andorra-latest.osm.pbf gisops/valhalla: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/build_linux.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.dev151-cp313-cp313-win_amd64.whl (15.7 MB view details)

Uploaded CPython 3.13Windows x86-64

pyvalhalla_weekly-3.5.1.post1.dev151-cp313-cp313-manylinux_2_28_x86_64.whl (85.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

pyvalhalla_weekly-3.5.1.post1.dev151-cp313-cp313-macosx_14_0_arm64.whl (59.5 MB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

pyvalhalla_weekly-3.5.1.post1.dev151-cp312-cp312-win_amd64.whl (15.7 MB view details)

Uploaded CPython 3.12Windows x86-64

pyvalhalla_weekly-3.5.1.post1.dev151-cp312-cp312-manylinux_2_28_x86_64.whl (85.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

pyvalhalla_weekly-3.5.1.post1.dev151-cp312-cp312-macosx_14_0_arm64.whl (59.5 MB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

pyvalhalla_weekly-3.5.1.post1.dev151-cp311-cp311-win_amd64.whl (15.7 MB view details)

Uploaded CPython 3.11Windows x86-64

pyvalhalla_weekly-3.5.1.post1.dev151-cp311-cp311-manylinux_2_28_x86_64.whl (85.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

pyvalhalla_weekly-3.5.1.post1.dev151-cp311-cp311-macosx_14_0_arm64.whl (59.5 MB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

pyvalhalla_weekly-3.5.1.post1.dev151-cp310-cp310-win_amd64.whl (15.7 MB view details)

Uploaded CPython 3.10Windows x86-64

pyvalhalla_weekly-3.5.1.post1.dev151-cp310-cp310-manylinux_2_28_x86_64.whl (85.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

pyvalhalla_weekly-3.5.1.post1.dev151-cp310-cp310-macosx_14_0_arm64.whl (59.5 MB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

pyvalhalla_weekly-3.5.1.post1.dev151-cp39-cp39-win_amd64.whl (15.7 MB view details)

Uploaded CPython 3.9Windows x86-64

pyvalhalla_weekly-3.5.1.post1.dev151-cp39-cp39-manylinux_2_28_x86_64.whl (85.1 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

pyvalhalla_weekly-3.5.1.post1.dev151-cp39-cp39-macosx_14_0_arm64.whl (59.5 MB view details)

Uploaded CPython 3.9macOS 14.0+ ARM64

File details

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev151-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 5b7961e56a906e2e24995fc12c83a81576ee9d71b210e2495ef66d92050483ca
MD5 fd871c3b6ba24a85e009d4d727ab1259
BLAKE2b-256 d302dc5a77420a22ef46590db90f980545ffe2830f2568ae0581ac2bf7324da3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev151-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 deb49373cbdb776f24cc45b133021428ebebd6746b459e39c016c5ecc9c18302
MD5 a8d96391182eca2f3524b2f8af81c564
BLAKE2b-256 7b875581a94330d861b6690f7e1b467261e23e0383fe724351e806ac05a9ac13

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev151-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 d95367bec9173246e38fb6680be84e2a88bca74be4ff272b4ee995e27903ffad
MD5 316b9e9e6e7bf79f69db73961cc9c31d
BLAKE2b-256 e137e1f55e8f8da7d35032804eef1ac0acf451255b946d67af0d925bd444a76e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev151-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 b6984ed151b52c07613730b3abb4074223b156e036189d40ede59a20594ff1bc
MD5 fa4200f84672cb14da29b661ffc7ee58
BLAKE2b-256 83af00d15516127dfc80e8e4a8d2cdc07eea78d34a5a8552310a795a0abe0c77

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev151-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f26a1c1facb112f34fe16b3040ea279b70c2fe145fa70743903ed44837861121
MD5 0a012328248a6802fe8bbbe0a8c295cb
BLAKE2b-256 e4f44a4712a3d0e92b25fb1d6586033b5572b91e2da1337050ae46fd9afd7fda

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev151-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 57496633fd587b3917eb7c327f5ac2131b3ad3809bdb067d1afe1f3e97cd386f
MD5 807051a5d47c6d9f79cf298fd362a805
BLAKE2b-256 601ea0098a0e86f35e738c679063c3dc3feda59439e74e7fc24a6cf7f8e08d56

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev151-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 36f15a1a112adb7706e1744f4ed332a241500cb11a2c70122150450a79aad5b9
MD5 40392a7548813625e178bfe97797e1d5
BLAKE2b-256 2f7d6179e03cd366908a8d3bae0a2fb44ec25fa5fd8c0d4b1dfad5a9fce4b115

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev151-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5efccfd21e402a8f0804e04d47fc5a8b9f5ff40f658dc00e27b18f16a4310965
MD5 38c388e900dfb3b514a15cdb99edf848
BLAKE2b-256 a8f27cd331dbbf911405bb10b7d948400910025b843d59e66fe8ce42b397f55f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev151-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 f1c6419023ed9c41ed3b1f3bf595072aa3dfe9e8691be9b7732be3c22276ddd2
MD5 4b40aaa05a34ff871b39e475ef959e9e
BLAKE2b-256 85a41d56d79876f43453eabf4bb42941af74caab238a83bac0159deb33359c1f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev151-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 4ee1bf0ee12e6de304012dc0161b7f8b2a5e1e012552fb79efe712198df2e9d8
MD5 bb4301488039848f6d7491c06f86e782
BLAKE2b-256 d1c1493ccdfd532d99266316dbd787534cdc056e9713012b8a4db221085ab9df

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev151-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6c40e3368027fdf4db17fcdb68db8ba2800e368603551a270199049e52bbf550
MD5 3d7172fab085637df6e578bd7fb7caef
BLAKE2b-256 e533bf6e16b78b40e825a0c18e616a511ddefe1553b95057d70fde4fdc6d9c73

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev151-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 5f20bf2e009acd1447ed637103c8a1dcd9d0249450c6b6f9ec7c12bc799bfe61
MD5 b0696ecdb26304ea0f3fec47baeff3ee
BLAKE2b-256 131e2a8118f3e1fe6eb2215f6aff95c2b836d500685b567d8118dc9fd71d7ea6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev151-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 f989c07d3cf6ba2c10fd09dffc1f88dce941a293925b724a9d9e81099a9d0e37
MD5 7fbb15c7c83ecaccf89f4e840dcaa61b
BLAKE2b-256 781b5b71014090f734c37ad0db2af175bd7f9a7bf59d4b65dc7be41b290c7229

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev151-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e9b760a2e8b3ff761ea652e895cf95420350e9c653c112b86563ab4e9d218101
MD5 acf521262b782ad3dd71d36f3436f8f8
BLAKE2b-256 7861f257c0cff428de2fa2876704354d2d90a47ffed35f0c67b76a18a138f0c5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev151-cp39-cp39-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 ebad3037c960c03c6d386679bbc2219830f34fd47da8b9565f5c85a98c084892
MD5 1e1932d4476c8daaca84f2f52de147a6
BLAKE2b-256 8f3eac7ede6b6089b31cd57ce3f8157e8132cf9c765c9e857bf2981374898307

See more details on using hashes here.

Provenance

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