Skip to main content

pyosmptparser

Python bindings for osmptparser, a fast, parallel parser that reads public transport (PTv2) relations and areas (administrative boundaries, or any tag filter) from an OpenStreetMap .pbf extract, reconnects broken/disconnected ways with some tolerance and returns each route as an ordered geometry plus its stops, and each area as a multipolygon.

pypi package: https://pypi.org/project/pyosmptparser/

Install

pip install pyosmptparser

Prebuilt wheels are published for Linux (glibc >= 2.28 and musl, x86_64 and aarch64), macOS (Intel and Apple Silicon) and Windows, for any CPython >= 3.9 (abi3). Other platforms build from the sdist, which needs a Rust toolchain.

Usage

import pyosmptparser

p = pyosmptparser.Parser.new_ptv2('ecuador-latest.osm.pbf')   # all PTv2 route relations
pts = p.get_public_transports(150)                            # join ways with gaps up to 150 m

for pt in pts:
    pt.id            # osm relation id
    pt.tags          # dict of osm tags, e.g. pt.tags['name']
    pt.info          # dict of osm metadata: version, timestamp (epoch seconds), changeset, uid, user
    pt.geometry      # list of linestrings, each a list of (lon, lat); 1 linestring when fully joined
    pt.stops         # list of Node(id, lon, lat, tags, role) in relation member order; role is the osm member role ('stop', 'platform', ...)
    pt.status.code   # 0 ok, 101 sorted, 102 joined, 103 joined+sorted, 501 broken
    pt.status.detail

Areas (administrative boundaries, or any tag filter):

p = pyosmptparser.Parser.new_aa('portugal-latest.osm.pbf')    # name & admin_level & boundary=administrative
areas = p.get_areas(150)                                      # bridge gaps up to 150 m

for area in areas:
    area.id          # osm id
    area.id_type     # 'r' for a relation, 'w' for a standalone closed way with the tags
    area.tags        # dict of osm tags, e.g. area.tags['admin_level'], area.tags['name']
    area.info        # dict of osm metadata: version, timestamp (epoch seconds), changeset, uid, user
    area.geometry    # multipolygon: list of polygons, each a list of rings, each a closed list of (lon, lat);
                     # ring 0 of a polygon is the outer ring (osm role 'outer'), the rest are holes ('inner').
                     # [] when status is broken
    area.status      # same ParseStatus as public transports

Rings are chained by shared nodes whatever the member order, gaps up to gap meters are bridged, and an area with any ring that cannot be closed is reported broken with an empty geometry. For GeoDjango/shapely: MultiPolygon(*[Polygon(*rings) for rings in area.geometry]).

Other constructors:

pyosmptparser.Parser('file.pbf', 'route=bus,trolleybus')      # any osmptparser tag filter, see
                                                              # https://github.com/cualbondi/osmptparser#cli
pyosmptparser.Parser.new_ptv2('file.pbf', num_threads=4)      # default: all cpus

A missing or unreadable file raises FileNotFoundError / OSError. Set OSMSM_VERBOSE=1 to get the parser's progress log on stderr.

See test_pyosmptparser.py for a complete example. areas.pbf is a copy of osmptparser's tests/areas.pbf fixture.

Develop

Needs a stable Rust toolchain (https://rustup.rs) and Python >= 3.9.

git clone git@github.com:cualbondi/pyosmptparser.git
cd pyosmptparser
python3 -m venv .venv
source .venv/bin/activate
pip install maturin pytest

# build the extension into the venv and run the tests
maturin develop --release
pytest

# rust lint, same as CI
cargo fmt -- --check && cargo clippy --all-targets -- -D warnings

# build a wheel + sdist into dist/
maturin build --release --sdist --out dist

To use a local checkout of the Rust library, point the dependency at it in Cargo.toml (osmptparser = { path = "../osmptparser" }).

Release

  1. Bump version in Cargo.toml (and osmptparser there if the Rust library was released), update CHANGELOG.md, commit.
  2. Tag and push: git tag v3.0.0 && git push origin master v3.0.0.
  3. The CI workflow builds all wheels and the sdist, runs the tests, and publishes to PyPI through trusted publishing (one-time setup on PyPI: owner cualbondi, repository pyosmptparser, workflow CI.yml, environment pypi).

Manual alternative: maturin publish with a PyPI token (MATURIN_PYPI_TOKEN).

Metadata

Release files for pyosmptparser 4.2.0

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

Source distribution (sdist)

Source distribution for pyosmptparser 4.2.0
File Size Uploaded Provenance Actions
pyosmptparser-4.2.0.tar.gz 84.5 kB With provenance Details for pyosmptparser-4.2.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for pyosmptparser 4.2.0
File Actions
pyosmptparser-4.2.0-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details for pyosmptparser-4.2.0-cp39-abi3-win_amd64.whl
pyosmptparser-4.2.0-cp39-abi3-musllinux_1_2_x86_64.whl CPython 3.9 abi3 Linux musl 1.2+ x86-64 Details for pyosmptparser-4.2.0-cp39-abi3-musllinux_1_2_x86_64.whl
pyosmptparser-4.2.0-cp39-abi3-musllinux_1_2_aarch64.whl CPython 3.9 abi3 Linux musl 1.2+ ARM64 Details for pyosmptparser-4.2.0-cp39-abi3-musllinux_1_2_aarch64.whl
pyosmptparser-4.2.0-cp39-abi3-manylinux_2_28_x86_64.whl CPython 3.9 abi3 Linux glibc 2.28+ x86-64 Details for pyosmptparser-4.2.0-cp39-abi3-manylinux_2_28_x86_64.whl
pyosmptparser-4.2.0-cp39-abi3-manylinux_2_28_aarch64.whl CPython 3.9 abi3 Linux glibc 2.28+ ARM64 Details for pyosmptparser-4.2.0-cp39-abi3-manylinux_2_28_aarch64.whl
pyosmptparser-4.2.0-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details for pyosmptparser-4.2.0-cp39-abi3-macosx_11_0_arm64.whl
pyosmptparser-4.2.0-cp39-abi3-macosx_10_12_x86_64.whl CPython 3.9 abi3 macOS 10.12+ x86-64 Details for pyosmptparser-4.2.0-cp39-abi3-macosx_10_12_x86_64.whl

Total release size: 4.1 MB

Release files / pyosmptparser-4.2.0.tar.gz

Download URL pyosmptparser-4.2.0.tar.gz
Size 84.5 kB
Tags Source
SHA-256 checksum
How to use checksums
3dd99e4e8d07b36bb0f2ace41f533c2899c07a52fd0c291507475f0cd8065e7c
BLAKE2b-256 checksum
How to use checksums
d13c0bf07102e901c5f07959dced92075517f3e49adda3de5b78f23e9036792d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 6, 2026.

Transparency log

Release files / pyosmptparser-4.2.0-cp39-abi3-win_amd64.whl

Download URL pyosmptparser-4.2.0-cp39-abi3-win_amd64.whl
Size 401.5 kB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
a533fcfd40f0057a629ba42e5e2e02ef4dfc910ec75cde2ec8149716f9e37102
BLAKE2b-256 checksum
How to use checksums
cbf40447737c41a182988f8fefee94826bbc859b2ff101ede9f82422116b3677
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 6, 2026.

Transparency log

Release files / pyosmptparser-4.2.0-cp39-abi3-musllinux_1_2_x86_64.whl

Download URL pyosmptparser-4.2.0-cp39-abi3-musllinux_1_2_x86_64.whl
Size 772.5 kB
Tags CPython 3.9 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
1d1cd90db7f887f0a54659df42dcfb2c952428e945d5c1942ed51b21c198c347
BLAKE2b-256 checksum
How to use checksums
23ce5224f6e1603ff1bf9a69351a95e4d34026d4039921f5da8bf6a5bf5d6a3d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 6, 2026.

Transparency log

Release files / pyosmptparser-4.2.0-cp39-abi3-musllinux_1_2_aarch64.whl

Download URL pyosmptparser-4.2.0-cp39-abi3-musllinux_1_2_aarch64.whl
Size 733.2 kB
Tags CPython 3.9 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
8890c5f5069d68eea11dcb82243522c898130599a607ed776f730573601dc137
BLAKE2b-256 checksum
How to use checksums
d60593667bb09acbc134d9e0c78a612340134f7a2a56495c19accb1e2e29a811
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 6, 2026.

Transparency log

Release files / pyosmptparser-4.2.0-cp39-abi3-manylinux_2_28_x86_64.whl

Download URL pyosmptparser-4.2.0-cp39-abi3-manylinux_2_28_x86_64.whl
Size 569.8 kB
Tags CPython 3.9 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
674bae43d50ef8f5b9e26084b1130365e4347d52586c2de6735a761cafab95c6
BLAKE2b-256 checksum
How to use checksums
92a5e5d4f6cf19bfad5d27eff7a48bdf811ff29c569050830fdcd9ee3ca77d5a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 6, 2026.

Transparency log

Release files / pyosmptparser-4.2.0-cp39-abi3-manylinux_2_28_aarch64.whl

Download URL pyosmptparser-4.2.0-cp39-abi3-manylinux_2_28_aarch64.whl
Size 554.9 kB
Tags CPython 3.9 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
4c3896e275167e55407c250ddd33409a6dbfa4eebfea1ed30c0f00e2a18b3773
BLAKE2b-256 checksum
How to use checksums
3425d63b8b68605bc460020042a925f3466a1cadc4c97aab06ae59108de0643e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 6, 2026.

Transparency log

Release files / pyosmptparser-4.2.0-cp39-abi3-macosx_11_0_arm64.whl

Download URL pyosmptparser-4.2.0-cp39-abi3-macosx_11_0_arm64.whl
Size 483.0 kB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
0f3caaad4bf520c40a6db21d39020a5d000aa7cee8b1564e561e928e4d86dbc8
BLAKE2b-256 checksum
How to use checksums
70535511161e0c94049391e246811057e654d4174f6463780579675aad60dbaf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 6, 2026.

Transparency log

Release files / pyosmptparser-4.2.0-cp39-abi3-macosx_10_12_x86_64.whl

Download URL pyosmptparser-4.2.0-cp39-abi3-macosx_10_12_x86_64.whl
Size 499.2 kB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
bc6dbad181800e0141f769cfe17670cef56f5d04e6f727cf9c38f49d1f6e7eb5
BLAKE2b-256 checksum
How to use checksums
61da00f0da7195b62a734a171eaccec391268576e0325ec82423864a0fc5821a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 6, 2026.

Transparency log

Security for pyosmptparser 4.2.0

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.

Full provenance

All 8 files in this release have been uploaded with provenance metadata.

Select from 8 files

Attestation for pyosmptparser-4.2.0.tar.gz

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 Nov 6, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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