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.0.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.0.0
File Size Uploaded Provenance Actions
pyosmptparser-4.0.0.tar.gz 83.3 kB With provenance Details for pyosmptparser-4.0.0.tar.gz

Built distributions (wheels)

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

Total release size: 4.0 MB

Release files / pyosmptparser-4.0.0.tar.gz

Download URL pyosmptparser-4.0.0.tar.gz
Size 83.3 kB
Tags Source
SHA-256 checksum
How to use checksums
8d244cab5ab1a2e8907a55850919d66a0cefd70ad6d46d7bc086d0395402f56e
BLAKE2b-256 checksum
How to use checksums
c5ba200fa843d164134c102353b259ce7b2b99a9c37382e889f113d977d267cf
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.0.0-cp39-abi3-win_amd64.whl

Download URL pyosmptparser-4.0.0-cp39-abi3-win_amd64.whl
Size 386.6 kB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
5554a7b7dee196b3eab97f14be71358525781e479ba9b2f6bcbdcd3e820e12f2
BLAKE2b-256 checksum
How to use checksums
3fe1a26eb2f216be2c3144c9d68eb5ec2b002b5f49ad0782f6a416d2ef164814
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.0.0-cp39-abi3-musllinux_1_2_x86_64.whl

Download URL pyosmptparser-4.0.0-cp39-abi3-musllinux_1_2_x86_64.whl
Size 761.8 kB
Tags CPython 3.9 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
56ce721e885ba7d7bd0ec8c947a0d377cd959262b82edf0d043ed1fa214bab34
BLAKE2b-256 checksum
How to use checksums
2a027446d9c0dac633d6cf5ca2695de5c930efe16f27a04555a60b3f45213aa3
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.0.0-cp39-abi3-musllinux_1_2_aarch64.whl

Download URL pyosmptparser-4.0.0-cp39-abi3-musllinux_1_2_aarch64.whl
Size 722.4 kB
Tags CPython 3.9 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
1917f812e1692616be8b99e6ab1bc31d52d629dc51c7a055cd82fc2744fba67d
BLAKE2b-256 checksum
How to use checksums
25e7b1742b2d6cb07f3d79547f52a8e60e9bd42ea52d35494cdb8796c9dce706
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.0.0-cp39-abi3-manylinux_2_28_x86_64.whl

Download URL pyosmptparser-4.0.0-cp39-abi3-manylinux_2_28_x86_64.whl
Size 555.7 kB
Tags CPython 3.9 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
bdecafc645dc0d47152c72c286a4c91759e6e83099a0bc8647ad2e850716c06e
BLAKE2b-256 checksum
How to use checksums
06ccad715cd7c9d5cf3ad6d236b1ef9f4dde141697f5dc345254d0e780e47784
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.0.0-cp39-abi3-manylinux_2_28_aarch64.whl

Download URL pyosmptparser-4.0.0-cp39-abi3-manylinux_2_28_aarch64.whl
Size 545.0 kB
Tags CPython 3.9 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
74872184e1c27021748d15df996946fc9270715ffca609dc8fdb3836089d2447
BLAKE2b-256 checksum
How to use checksums
12647c3fd715957be43ee126ac4de805eaf2a10df208a0b6324c70531268c31d
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.0.0-cp39-abi3-macosx_11_0_arm64.whl

Download URL pyosmptparser-4.0.0-cp39-abi3-macosx_11_0_arm64.whl
Size 472.7 kB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
2af75e4521a0ce8ece04ceb84c3e2b41453a091a2c783a525e2b13ef889b58f4
BLAKE2b-256 checksum
How to use checksums
12e4d16fca4303f01bf51f65d4ad44ca5441306426b91ef79d4340677c525af8
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.0.0-cp39-abi3-macosx_10_12_x86_64.whl

Download URL pyosmptparser-4.0.0-cp39-abi3-macosx_10_12_x86_64.whl
Size 486.1 kB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
e02de120a6e9eb8da8d4dbc2d9132d663d1874051b3ce8f2a38de6a1e8781f10
BLAKE2b-256 checksum
How to use checksums
6b300b3d1a85f36f205a7f137031a93f088e079d553434d5957e24efddd1400e
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.0.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.0.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