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

Uploaded CPython 3.13Windows x86-64

pyvalhalla_weekly-3.5.1.post1.dev202-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.dev202-cp313-cp313-macosx_14_0_arm64.whl (70.3 MB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

pyvalhalla_weekly-3.5.1.post1.dev202-cp312-cp312-win_amd64.whl (26.8 MB view details)

Uploaded CPython 3.12Windows x86-64

pyvalhalla_weekly-3.5.1.post1.dev202-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.dev202-cp312-cp312-macosx_14_0_arm64.whl (70.3 MB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

pyvalhalla_weekly-3.5.1.post1.dev202-cp311-cp311-win_amd64.whl (26.8 MB view details)

Uploaded CPython 3.11Windows x86-64

pyvalhalla_weekly-3.5.1.post1.dev202-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.dev202-cp311-cp311-macosx_14_0_arm64.whl (70.3 MB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

pyvalhalla_weekly-3.5.1.post1.dev202-cp310-cp310-win_amd64.whl (26.8 MB view details)

Uploaded CPython 3.10Windows x86-64

pyvalhalla_weekly-3.5.1.post1.dev202-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.dev202-cp310-cp310-macosx_14_0_arm64.whl (70.3 MB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

pyvalhalla_weekly-3.5.1.post1.dev202-cp39-cp39-win_amd64.whl (26.9 MB view details)

Uploaded CPython 3.9Windows x86-64

pyvalhalla_weekly-3.5.1.post1.dev202-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.dev202-cp39-cp39-macosx_14_0_arm64.whl (70.3 MB view details)

Uploaded CPython 3.9macOS 14.0+ ARM64

File details

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev202-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 c5bcc6e4ca466e928577f6db09badcfd127c16004e72acd3d084fe8882d90852
MD5 618e9c09227bc3edc3ac4342bd52f0a1
BLAKE2b-256 8a3c9e2d18820906ec96512e48956ddde9ce9327a527c7bc6337a1d89e40f7b3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev202-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 05d18db530f96f85fa9773b5ad95148f79caabdab46f15c5cc990c22931cd0d0
MD5 52c301e482a24363025eee13d4521c47
BLAKE2b-256 a2fc9305b71a36bf73696804fd745c8a702fb1ff788a44811de58af5292d151c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev202-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 2936aaf06b496ca6deb3892e3752d77bc0287683259f146c984cc5d3442e42cf
MD5 8bc49d4a71afa25ece0060e6ea2e0d1e
BLAKE2b-256 a19194fadc04f3322892ce0c1631ce07d98bd51058fdde37f83af4e07fbe5439

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev202-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 2c1110c19fdd20e7d4ecc38afe98bf6492df96ffb184f023ffd6ef6542a42619
MD5 26e348eb7a2aeb0871c31c174767b944
BLAKE2b-256 76109589317d9fdb60d35cf8a1ebd5fcb2f0f64a6d2dadd66be1d21efe5649ad

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev202-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c17bc4a220c14978fa0efd4b4414557cb82e4e98496903b1cd36a80a04843496
MD5 a54f4c77445ecc9557007c0978c2b7f4
BLAKE2b-256 bd3282e1fa30d3c9258e8b354a839031652e88079f89b611db4d08c28fceec39

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev202-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 68b9631c0f866f9ab28b3711f2d9d7eee4a2689d48cf7e2abc59fee9d6754ccb
MD5 645acc9f5e0b181bb9343b80ad939272
BLAKE2b-256 28191ae5d58f36399a14ffcb3e398411f51c1ec2ecd3fbeba0e7da15a5f1f367

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev202-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 4bfac53c16ca8c9350b2f4834bd2fd63ff5649dc66c848bc0b135cc45603aba9
MD5 524d4414425d41019127f641379649c4
BLAKE2b-256 7d2ca882ae591834ff1b5cd15455fddf7448b626a318578499d041c1bbf441ce

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev202-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e42991a25095ca4934c0c4220308c021b45728ad9cd9215fe505853a6c2d29e1
MD5 487b9a9edd3d96b1d0ea9d609a6123d4
BLAKE2b-256 3725703337d8e177c8f4248a2fadbd8fa014739047fc888ac462bbefee83d83f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev202-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 4a542ab4d26ef86424484fc5453bec0a99f5a78124aad89e8f34e59bc14d2d25
MD5 e45c50c979b7c65efaae1c84ccfc690d
BLAKE2b-256 d3da9bf40615db3d90225cb0b7b9e227ecf90e6b8f109009dcc5c70aef4e90ea

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev202-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 98f2b4119c77273b8cbc15b64aee69326b0b10abf219656a36481ed21067f4f0
MD5 9d295752e53a548045529a7d84d95613
BLAKE2b-256 3dcd2bb378a4dba81911ca832dca59410136ca8c2f15d6e4e976848fef671f9c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev202-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 cb78925ebef9cfb6a8ec935c0c9d7528d49524d383562eb4766ee5ce74f35683
MD5 9c95dba3a4e5e5d30007b227392da857
BLAKE2b-256 ee4bac02155332f69d1a8a8801f49c81acb9e38dd1db905d7321f28370ce17fe

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev202-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 4d608229505b0a7105e4ded5dc7119b95ff925c4739d28329dfe34bcb1a58a40
MD5 8180f77156e86be9a8c7a545c709c433
BLAKE2b-256 86044d77586f0e51a32203612de407a7438ee071cd1da9464c935d399c1327c2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev202-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 cff650b7616fc27d357767d77adb8b7e153a9175ee3c8bb083004b829e4052af
MD5 5460c61f27b2fb579772f37046a17e0b
BLAKE2b-256 463a5f0de13ef55d8daab0749a98c4450f28604b48047fa3409c743385a2a391

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev202-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 56a208405793d6c54974a38991419ca7557740c070ecb7640ba522751dabd32a
MD5 3efa56462042bfe23be63808fed57cf5
BLAKE2b-256 0e0809d4be9bedd1fc50b13b5a915da15d2d6de7434869dbd475b712c8f1f13b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyvalhalla_weekly-3.5.1.post1.dev202-cp39-cp39-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 15c7d2bd188b6931282a9bbeef7a4be8fd6ea80dfc316aaf1eebadf5ac9892e5
MD5 83dfb8ba3111b0e4997838e663796ba0
BLAKE2b-256 b011809da0af9de1845a4a709c1ff85bdc5a364cbfb568ad5f0db8e2aceb8f27

See more details on using hashes here.

Provenance

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