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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.9Windows x86-64

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev205-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 c913718b82bf5972e64b587fb5923371e97ee6c5f76f2fe9771321481b038465
MD5 535ff31736166c7337521ea14d1fc67e
BLAKE2b-256 defc91002d8b83b186d931ce105aea0ca7fef2bce19bc300f29cfa4846d0af6d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev205-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 683cbc1f50b0be88fb278fe486f8e136cca2adc80dd8904f17671bc26e2619fa
MD5 1e33f9333bc4bb9f7a922952c4e97573
BLAKE2b-256 6189b996bf9440a6a303d5c29b0cdba8c43b41a735ac31f4528dfe91aaec082f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev205-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 c9b6a4ad75f7e8e414ee53cdffb26af91ff42b39c2cfcd49599969215885ade7
MD5 6f9810658e993a8d3c4c6723eb675308
BLAKE2b-256 0dd54361948a1a24cd39f7a954311ab5dedf295c22cf2903b0ff10fa16990c98

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev205-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 6cac4f23019393173511fdc8db3d6cac9a2cf01da7a8b21835ea0ce741fe0a11
MD5 85f5d60d833ce55cee520de8d164a8a2
BLAKE2b-256 bcbf5142349b2cd26bb656da58ea2936880f4f1be9d1bd32c09383e5e1d61aad

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev205-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6a866284b6b53b7bb9369fc1f0c853587329f7fba8f0082c604d50439c64f0b0
MD5 8e59be5f635eeab4ad9324e16711bb0f
BLAKE2b-256 0498db708d209e2c6dcc1f97aaf48341b0ce9f10af30fe020209edf33f257d23

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev205-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 003d072ac20f0d5ad1734e77d67a638d4e3ce96ea6e2cd92ea7d734de419c87d
MD5 cf14c83d163d95ff7d7ba1bf2a2fe5c7
BLAKE2b-256 5dbf49b1aba9bb9ce39273a3899eb6e5c933098a07b65926069c3364876aca9b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev205-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 09c0cdc5b32d7018b394aca7243d96c4efdb4b3806dd1809923e86edff331d2b
MD5 0b2faa285704bb838157a35199ad9d18
BLAKE2b-256 49ab25f899dfd9bd8824ed330ee0fa5ef6b18a9673831707ff07b78612451fd6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev205-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 43d9763230409123bd46bae34d18527d5d5410f5c4cdd9c646c2f310dfc69548
MD5 b5fff1cd45edcce8ea2376f0e56fd31d
BLAKE2b-256 a1404852cd9a2aad7e2249c5438d4e71771e9b8e806d6dab7d2af5220c614016

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev205-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 4a9183ba930d9ad3f053d1f50f5d387f191b3ddf8afd480853af3433facb923f
MD5 3571acacb00b3c942751300224a67d3d
BLAKE2b-256 bfcecf3e7414fc74be343690c0e37d6d0332c8ff16d8e1d002ef1ed529d66b19

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev205-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 aa63dcd5a940335f9fe1bf6d09133486633163f021fb341156526774a8e5f6c8
MD5 c77e466e23a20b87929eb349105a19ec
BLAKE2b-256 cec1cf6ee3d448fa8a3b007a86b40fd4d87ea5e8069945390cfc6a2281427aab

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev205-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ff6b80f6f7914f04465df7e5b52a6c520bf01142d9c898a262747751101c9986
MD5 6cba60104ee77aef535b8ff34530fb13
BLAKE2b-256 b9c333ada705c6bfee40de5605f1cb24ceb100419d67541ca2df2d5c172ee6c7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev205-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 a05d2d8f08dd39a19c108a6df80db8740d6b981a6de13cad4cee21b6c3395745
MD5 3fcf542c4acd06988d609d94e2278c85
BLAKE2b-256 bd6ebcfd034ee0fb3d46dd51b92718000b2100825193bc3c67179fc0dcbead1c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev205-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 e84ba56bb91c72029aaba852da27c9a021f0d69fb6c6266baa89fd32994e1eee
MD5 8e51c7d97109ab75b63c9f6eb205d69b
BLAKE2b-256 cc52ae24bd0c08e50416fccfef1cbca1ea662966e1fb141ae826a145cd1c3473

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev205-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 85d660c522d73016115d814b6386134d41836d9868664287032fe169921cb6f3
MD5 56df997ece9aadd689f6e86034cf00e8
BLAKE2b-256 84b1ae72066436fea02856cfc0ba9f7b7067e7f91f08580f09db6e08b1dfa6de

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev205-cp39-cp39-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 00142fa80cee4a2353f67cb3a665b01f96c80e9cab643abf1cdeb9890c8bb91d
MD5 2b4b84174beae1577e5a286ce85deafe
BLAKE2b-256 50e3be47be13acef4fc2898af6a3264f45e917c5c39d17e1ccada42c0248088d

See more details on using hashes here.

Provenance

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