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.1

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

Built distributions (wheels)

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

Total release size: 4.1 MB

Release files / pyosmptparser-4.1.1.tar.gz

Download URL pyosmptparser-4.1.1.tar.gz
Size 83.7 kB
Tags Source
SHA-256 checksum
How to use checksums
34df4aa7e5bc964d8c04714175c3477c46d9949af81be23d559467eefaed5149
BLAKE2b-256 checksum
How to use checksums
feaed9773f11f22d9153bf04557dfd30d77416a3345e87dfa08179bd05dcc647
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 17, 2026.

Transparency log

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

Download URL pyosmptparser-4.1.1-cp39-abi3-win_amd64.whl
Size 400.6 kB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
304ee7a69378a05261736a1449936ad2737b72dbbae7e4c16e8f903266e76aaa
BLAKE2b-256 checksum
How to use checksums
7183dc795329086bb67af790f4341139b3729c2b21b31499a8d3d64ab575d907
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 17, 2026.

Transparency log

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

Download URL pyosmptparser-4.1.1-cp39-abi3-musllinux_1_2_x86_64.whl
Size 771.6 kB
Tags CPython 3.9 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
e3ef9a62c6fa0f783c52e08236f91e3d793fd896c70d9e47860974b34961ab4f
BLAKE2b-256 checksum
How to use checksums
5e34a973f257021e0e06b34cb8d7f4b6c49aa36155b6efa63472e84cebe0636e
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 17, 2026.

Transparency log

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

Download URL pyosmptparser-4.1.1-cp39-abi3-musllinux_1_2_aarch64.whl
Size 732.4 kB
Tags CPython 3.9 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
ce6a7ed8348c71c6925418b0c72e2beb7f8d6a6078313b259cdacc62e886763b
BLAKE2b-256 checksum
How to use checksums
657bdfec6ca19dc4572cbafe05022f8e70cea2f6fc7b9e30e379faabad118776
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 17, 2026.

Transparency log

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

Download URL pyosmptparser-4.1.1-cp39-abi3-manylinux_2_28_x86_64.whl
Size 567.1 kB
Tags CPython 3.9 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
73fa1a0464379b39cfd9815739fa2435f08579d607862ffc8a182610652d205e
BLAKE2b-256 checksum
How to use checksums
6fecc2ba16e946975fd270264dba6ddfdc421c4f5d3fcb981bc521eea8391fcc
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 17, 2026.

Transparency log

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

Download URL pyosmptparser-4.1.1-cp39-abi3-manylinux_2_28_aarch64.whl
Size 553.9 kB
Tags CPython 3.9 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
99671417c04d1bf3091be5757a65cba3b9b366aafa78f01788511dce49e6e4bb
BLAKE2b-256 checksum
How to use checksums
c966741adcfed4f88731f7d95c9c3e0e59142e111a6e7014a6be6d0d2326e3c3
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 17, 2026.

Transparency log

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

Download URL pyosmptparser-4.1.1-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
428c20a22cf2677edd250a8007575f4626bb493de52420c38b93dfe858ce6740
BLAKE2b-256 checksum
How to use checksums
ea729528d49b93683128520f15692d0eb79e73cb6506136840afdb5cfcf91c5e
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 17, 2026.

Transparency log

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

Download URL pyosmptparser-4.1.1-cp39-abi3-macosx_10_12_x86_64.whl
Size 499.3 kB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
e597dbc1971b4ceb00eb0a1b1b32d96a65c78f2d4627346d2da2c0f6dc7ddb5f
BLAKE2b-256 checksum
How to use checksums
b2d0a7c71291c8911fc8994967b9c1d6aace85cc1c609048f443b3a43b01dfdd
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 17, 2026.

Transparency log

Security for pyosmptparser 4.1.1

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.1.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 17, 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