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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.9Windows x86-64

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev179-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 656de8b5665b6cc154284afe4aef410c03fbffcd6baddc42a413b4fbf1daec2d
MD5 6a9c9fcbb99b965d1b648d4ce54e7326
BLAKE2b-256 fe459e8d3edf84b22f629ad25a9f0e28b1b1fb63021bcd38c041c6ec9f9a5bff

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev179-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 12be3872bb6244e404dff2628f4e01a37eb16c92f491ac8832b7c84b199b8f17
MD5 3826a987977971c770793a594ec9c4bc
BLAKE2b-256 0d9284f97a650ba0e6102f3cd8aef1488f3faf97b9037ed259f29934ae77b1fd

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev179-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 47396e59ca43c160d5a15070e0efd52df82376226f28605305065e65d5740074
MD5 7c6dac15c5af85a6ba32d1ca8a690490
BLAKE2b-256 a52c4eb2c4f503df627f4664c04a5d20a91d1038ddf17e9ced5605de5ae23417

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev179-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 0da46e4467aa33454baa6039e3ecee7f3f3725c44b03a9da30c4b03b0967de33
MD5 9671fc72d161024f4487c5471a4a7a55
BLAKE2b-256 163c54183e34e220d32181f860e7f7ba2478a0d009ed09de9e993ff4af0073c5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev179-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a164a1544b2b61ef30b1b4f0079812e28cad813ba0929bf90abeb0ffddc5fda8
MD5 8e251dab5feaf72c57cfbd59d0452035
BLAKE2b-256 17ed6c3e2aba1466572cf8c8173767186f5dd250245d697a69da41b2e5b32480

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev179-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 625f4a8714e9c42e69a0a10634206a62f2121e6548d939d9eed195f1e7bd413b
MD5 5e0ba6162c07294829f6f35c920bd907
BLAKE2b-256 b0a30530b9e2e794b61f7ccfbb986db96e9b95c8afccca33504a3acf7a3636a3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev179-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 7ad3bc4d611e4624de486b5beb314732247ce6b6e8bd5d6745ee7c1516d64088
MD5 51466f2a9851509282dafcdf931feb88
BLAKE2b-256 8e1f8176323dc0c23bb51714cd19688d1375bbacdec7983e3737beb61aa58708

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev179-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9c95ba117b3bfcaa11cf7c46d407dc7f6725c4b3a6d10bfa29a2054fbadf39a8
MD5 b0b6ea9d738e5c35130d76bbdd0f9913
BLAKE2b-256 22c8379a0b87a5ca8f51a5e386b6588c3e3ead39b16033ab399aed4f602c40cd

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev179-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 2c0161b5ea9e98558a5895482e4532ecd2fb421bde9914c3560f105c5aca55ed
MD5 c825587a86459afb4d8469f8146fddd9
BLAKE2b-256 b70226f72dccde403010507f1fddf666019ff62da4fcea6c9597cb467cdd18f4

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev179-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 aa13323078d43baa25006120da31e5bc33e59cea652d5ee081d725fcdc1a6b87
MD5 db598e8c62356110c0ec1d7ceae37fb4
BLAKE2b-256 aa3ed22225c9f31f4d70616877077732bcca97ce5e7e0887916f55618f140624

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev179-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 856f624b67a4b7442bafd572954a9a1d3c20816f2fe34f5614248145c706c3e9
MD5 2bd9867bc74c45c57cd19792204f2c57
BLAKE2b-256 0b5eecf18638398e396fa3cb07a066347f8822807d8c47c16e7fe56d06662747

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev179-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 1225f3e6cb4a43363b8a44f8b819c6cdc5ad14f235c232db281bd91a3111ec0b
MD5 386348e815192bb4b83def8e701aec56
BLAKE2b-256 c37683a6fb1b0c7eb458670f6164043934be4019d4bd4a11706ce570f5287314

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev179-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 4bd7a48591ff523e6dc21109b85456a6b270f5b748f1c785110bb6cd9c63995e
MD5 92cb20ebca4948a8c24b00733addba32
BLAKE2b-256 54d02efbabe2b5ea4456541e750aae7fb108b5088a58fb86ab1445aa1ee48100

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev179-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 57e0684f0fe34362d3d5aed8e1c075b1653c7efc9beed4e21b7b2f5291b42a36
MD5 3a050c44a962f30a96170d8ac2356a09
BLAKE2b-256 2626119c32aa66da816b7b564b1788967fffae7b968f99ac5b55f9591971b028

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev179-cp39-cp39-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 f08899b0c310edceeee007d3176755e4f769812c19bc39655cba6376cc017298
MD5 36072a2998b2be660ed63fa5f7097287
BLAKE2b-256 827878c8728e84e8370dd91b463dd72cb973e3652c88ae3a5f5e5a3e28e7c8ea

See more details on using hashes here.

Provenance

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