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.1.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.1.0
File Size Uploaded Provenance Actions
pyosmptparser-4.1.0.tar.gz 83.5 kB With provenance Details for pyosmptparser-4.1.0.tar.gz

Built distributions (wheels)

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

Total release size: 4.1 MB

Release files / pyosmptparser-4.1.0.tar.gz

Download URL pyosmptparser-4.1.0.tar.gz
Size 83.5 kB
Tags Source
SHA-256 checksum
How to use checksums
31baa8e81bd255ab1b7352fa7999ae1622c3fa703e717217c032eb710c790fb0
BLAKE2b-256 checksum
How to use checksums
31559add51701dcca4f8a20d5dd6126b50141e52a507ae864d8a2835f5e3915a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 15, 2026.

Transparency log

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

Download URL pyosmptparser-4.1.0-cp39-abi3-win_amd64.whl
Size 400.6 kB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
ff220ea325bf73c74fa6a3f35387e1f6b9ce6f732f4b6ac5e847e2632a656839
BLAKE2b-256 checksum
How to use checksums
726231477d096b31a8a760aea9ffbc9fb15a92ccce0189174014134c39a19d87
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 15, 2026.

Transparency log

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

Download URL pyosmptparser-4.1.0-cp39-abi3-musllinux_1_2_x86_64.whl
Size 771.8 kB
Tags CPython 3.9 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
90788e6d5f1e5f1e34bc804832f4cee68bf37f30b79be3bdc65f16bed824fdf3
BLAKE2b-256 checksum
How to use checksums
38ac47fa5fa8264abede066acbb9ad28d1b1e093a5c047a7f6ee883f82b412b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 15, 2026.

Transparency log

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

Download URL pyosmptparser-4.1.0-cp39-abi3-musllinux_1_2_aarch64.whl
Size 732.2 kB
Tags CPython 3.9 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
29de88e850b2bee1380de58242f4927f6a25acf1f9d4359afc89db890f58c495
BLAKE2b-256 checksum
How to use checksums
1c70b6ec6041aaad8de389f5d5ab53bf71ea07d6f130cc76efb0f06272db234c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 15, 2026.

Transparency log

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

Download URL pyosmptparser-4.1.0-cp39-abi3-manylinux_2_28_x86_64.whl
Size 567.3 kB
Tags CPython 3.9 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
c889c03faaf662bc8a36bd0edf39b4fd70c39123084746e71479d88ae203baa3
BLAKE2b-256 checksum
How to use checksums
1fdb5065f1b7e560d9d3e4ea2204726c63d5f58a077c213e262d83793d592aa6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 15, 2026.

Transparency log

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

Download URL pyosmptparser-4.1.0-cp39-abi3-manylinux_2_28_aarch64.whl
Size 553.7 kB
Tags CPython 3.9 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
f45beee569c174c2e51c0427148344ae17abe485a5acaf5468fb3ff78c196077
BLAKE2b-256 checksum
How to use checksums
3c9b830bd4151be559a33e8f1de0405d115fcb81d99b09e41199a440548dacfc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 15, 2026.

Transparency log

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

Download URL pyosmptparser-4.1.0-cp39-abi3-macosx_11_0_arm64.whl
Size 482.6 kB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
df6ec4fd355af067eca6bd73628e7ade17ca5a6dd6a1da86b663334ab30ef725
BLAKE2b-256 checksum
How to use checksums
5955013b48187a1351ce4e714b86c04d36407a5c6693f29ba5873998c0e866eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 15, 2026.

Transparency log

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

Download URL pyosmptparser-4.1.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
e6fd130c618dc800c5230b2df71304d853e3f2cc24995b1b98a41c6d6a2085b9
BLAKE2b-256 checksum
How to use checksums
67c5dadb88838b7b1ddbc695ad998c67eb88c296ff90056d8a398f52ea635cf3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 15, 2026.

Transparency log

Security for pyosmptparser 4.1.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.1.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 Oct 15, 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