Skip to main content

nameparser-py — native Python binding

import nameparser gives you the Rust nameparser core's parse() directly, as a PyO3 extension module. Unlike bindings/java (which crosses the JVM/native boundary via java.lang.foreign, either JSON or a flat struct on the wire), there is no C-ABI or marshalling floor here: PyO3 wraps the core nameparser::model::ParsedName struct directly, with one getter per field mapping it straight to its idiomatic Python type — no JVM, no JSON round-trip, no separately-installed native library to locate at runtime.

Field parity with the core is validated over this repo's full ~11,302-name test corpus, cross-checked against the independent Java name-parser oracle: 0 diffs (see crates/nameparser-py/python/tests/test_parity.py).

Install

pip install gbif-name-parser   # → import nameparser

Prebuilt abi3 wheels are on PyPI for Linux (x86_64 / aarch64), macOS (Apple Silicon), and Windows (x64), covering CPython 3.9+. On other platforms (e.g. Intel macOS) pip builds from the sdist, which needs a Rust toolchain (cargo/rustc) on the machine.

(The PyPI distribution name is gbif-name-parser — matching the Rust core crate on crates.io, so it's one name across both registries — but the importable module stays nameparser either way; see pyproject.toml.)

From source (development)

python3 -m venv .venv && . .venv/bin/activate
pip install maturin
maturin develop --release -m crates/nameparser-py/Cargo.toml

maturin develop compiles the Rust cdylib and installs it into the active virtualenv as an editable nameparser package (including the nameparser.pyi type stub and a py.typed marker — this package is fully typed; see Editors / type checkers below).

Usage

import nameparser

pn = nameparser.parse("Vulpes vulpes silaceus Miller, 1907")
print(pn.rank, pn.genus, pn.specific_epithet, pn.infraspecific_epithet)   # SUBSPECIES Vulpes vulpes silaceus
print(pn.combination_authorship.authors, pn.combination_authorship.year)  # ['Miller'] 1907
print(pn.to_dict()["type"])                                               # SCIENTIFIC — full dict, wire (JSON/Java) field names

results = nameparser.parse_all(["Abies alba", "Tobacco mosaic virus"])    # batch: never raises
print(results)                                                            # [ParsedName(...), None]

try:
    nameparser.parse("Tobacco mosaic virus")
except nameparser.UnparsableNameError as e:
    print(e.name_type, e.code, e.name)   # OTHER VIRUS Tobacco mosaic virus
    print(str(e))                        # Unparsable OTHER name: Tobacco mosaic virus

Every one of ParsedName's 30 core fields is exposed as a Python property (snake_case, e.g. specific_epithet, combination_authorship, published_in_year); enum-typed fields (rank, code, type, state, and each element of notho) come across as plain SCREAMING_SNAKE_CASE strings ("SPECIES", "ZOOLOGICAL", …) — the same convention the JSON/Java wire format uses — not a Python enum.Enum. rank/code inputs to parse()/parse_all() accept those same strings (or None). to_dict() (on both ParsedName and the nested Authorship) returns the complete structure straight from the core's own serde::Serialize impl, keyed by the JSON/Java wire field names (specificEpithet, not specific_epithet) — the escape hatch for anything a typed getter doesn't surface, and the parity oracle the corpus test itself diffs against.

UnparsableNameError.name_type/.code/.name mirror Java's org.gbif.nameparser.api.UnparsableNameException's getType()/getCode()/getName(); str(e) is still exactly the core's own message, unchanged.

Editors / type checkers

nameparser.pyi (shipped inside the package, alongside a py.typed marker) gives Pyright/mypy/ your editor full attribute-level types for parse/parse_all/ParsedName/Authorship/ UnparsableNameError — no more "unknown attribute" noise on pn.specific_epithet or e.name_type. It's hand-written (the compiled extension has no Python source for a stub generator to read) and kept in sync by hand with src/lib.rs's getters; see its own module docstring.

Native, no JDK required

This binding never starts a JVM and needs no java/JAVA_HOME on the machine that runs it — unlike bindings/java (which requires JDK 22+ for java.lang.foreign) — because it compiles directly against the Rust core, in-process, with PyO3 doing the Rust↔Python marshalling at the Rust/CPython C-API level rather than crossing a JVM boundary at all. Performance-wise it inherits the native CLI's batch-throughput profile (see the root BENCHMARKS.md): there is no per-call FFM downcall or JSON re-serialization step the way the Java binding's NameParserRust has, since parse()/parse_all() call nameparser::parse directly.

Development

. .venv/bin/activate
maturin develop --release -m crates/nameparser-py/Cargo.toml
pytest crates/nameparser-py/python/tests/ -v

Three test files under python/tests/:

  • test_api.py — unit tests for the binding surface itself (getters, to_dict(), parse_all()'s none-on-unparsable contract, UnparsableNameError's structured attributes).
  • test_getter_consistency.py — checks every #[getter] agrees with to_dict() over a representative sample (a path test_parity.py alone can't exercise, since it only ever calls to_dict()).
  • test_parity.py — the corpus parity gate: diffs nameparser.parse(name).to_dict(), and UnparsableNameError's message/name_type/code, against an independent Java-oracle (or Rust-CLI-fallback) row for every one of the ~11,302 corpus names. Needs a JDK on PATH (falls back to the release nameparser-cli binary if the Java shaded jar isn't available).

Build a wheel (not published) with:

maturin build --release -m crates/nameparser-py/Cargo.toml   # → target/wheels/*.whl (git-ignored)

The wheel is abi3 (built against the stable Python C ABI, py39 floor) — one wheel per platform, working across Python 3.9+, not one per Python minor version.

Metadata

Release files for gbif-name-parser 0.5.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 gbif-name-parser 0.5.0
File Size Uploaded Provenance Actions
gbif_name_parser-0.5.0.tar.gz 717.6 kB With provenance Details for gbif_name_parser-0.5.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for gbif-name-parser 0.5.0
File Actions
gbif_name_parser-0.5.0-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details for gbif_name_parser-0.5.0-cp39-abi3-win_amd64.whl
gbif_name_parser-0.5.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details for gbif_name_parser-0.5.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
gbif_name_parser-0.5.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.9 abi3 Linux glibc 2.17+ ARM64 Details for gbif_name_parser-0.5.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
gbif_name_parser-0.5.0-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details for gbif_name_parser-0.5.0-cp39-abi3-macosx_11_0_arm64.whl

Total release size: 7.6 MB

Release files / gbif_name_parser-0.5.0.tar.gz

Download URL gbif_name_parser-0.5.0.tar.gz
Size 717.6 kB
Tags Source
SHA-256 checksum
How to use checksums
138722eec29b02ac986bd5e5ce31d27492cc4f78e77b6003d857d9fabc05a9b8
BLAKE2b-256 checksum
How to use checksums
0b7cec2fde2f27e21bab35b3d63b8d8b8af258d1d155f0d26abde39b2b037ef9
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 11, 2026.

Transparency log

Release files / gbif_name_parser-0.5.0-cp39-abi3-win_amd64.whl

Download URL gbif_name_parser-0.5.0-cp39-abi3-win_amd64.whl
Size 1.6 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
62a5efc35f62d73179bd1945fc56383582e4260f739853bf381b924962f7fef9
BLAKE2b-256 checksum
How to use checksums
d01b456cd5ace030db6491f4716dc7a3870daaf0cc56a4dcdf7d2dbcd2bbbebb
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 11, 2026.

Transparency log

Release files / gbif_name_parser-0.5.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL gbif_name_parser-0.5.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 1.9 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
00f2a9c8dc2caad6004286eac7dcdd2f8578d8c5ee02f987b8541fff7117a286
BLAKE2b-256 checksum
How to use checksums
a36e2ce529c85df178de7395b4e22ccb6f23da5d3bf6e69c1400d7edbca7ebb8
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 11, 2026.

Transparency log

Release files / gbif_name_parser-0.5.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL gbif_name_parser-0.5.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 1.8 MB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
07411192f5443aebc40648766fc3f1a20a29e89c9f07ebb1615e09c0bfb3ef24
BLAKE2b-256 checksum
How to use checksums
513e944807a846796d9eeee54ba3c8da44a318609fe2129d670b5752fb2f01a6
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 11, 2026.

Transparency log

Release files / gbif_name_parser-0.5.0-cp39-abi3-macosx_11_0_arm64.whl

Download URL gbif_name_parser-0.5.0-cp39-abi3-macosx_11_0_arm64.whl
Size 1.7 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
7b8e1cada4299cd79f415644980373d9f4190ff836e7a4d60056ea726b63b841
BLAKE2b-256 checksum
How to use checksums
d64ed9be7aa1772fd7852ae1940ffe9a2648277252b10bf2abdd854e838e7776
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 11, 2026.

Transparency log

Security for gbif-name-parser 0.5.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 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for gbif_name_parser-0.5.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 11, 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