The `rfc3987` Python library provides regular expressions and utilities for parsing and validating Uniform Resource Identifiers (URIs) as per RFC 3986 and Internationalized Resource Identifiers (IRIs) according to RFC 3987. The current version is 1.3.8. Development on the original GitHub repository has ceased, and the project is now archived, with development reportedly moved to Codeberg, implying a largely unmaintained or very slow release cadence on PyPI.
pip install rfc3987Verified import paths — ran on the pinned version, not inferred.
Demonstrates parsing an IRI, matching a component against a rule, and resolving a relative URI reference. The `parse` function extracts components into a dictionary, `match` checks if a string conforms to a specific ABNF rule, and `resolve` combines a base URI with a relative reference.
Be aware that active development has shifted. For new projects, evaluate if the current 1.3.8 version meets your needs, or consider forks/alternative libraries if active maintenance is critical. The Codeberg repository (https://codeberg.org/atufi/rfc3987/) might contain more up-to-date information or development.
If you need to validate or parse strings against arbitrary or less common RFC 3986/3987 rules, ensure you install the `regex` package: `pip install rfc3987 regex`. Otherwise, restrict rule usage to those explicitly supported by the `re` module fallback.
Test thoroughly on your target Python 3.x version. While the core regex patterns are stable, be mindful of potential unexpected behavior or lack of optimizations on newer Python runtimes.
Ensure you are using a modern Python 3.x version (preferably 3.7+) which typically supports a 'wide' Unicode build, resolving this limitation. This warning is less relevant for contemporary Python environments.
Install the package using pip: `pip install rfc3987`
Either ensure the input string is a valid IRI/URI, or use `rfc3987.is_valid(iri_string)` if you only need a boolean result and prefer not to handle exceptions for invalid inputs.
Ensure that the input provided to `rfc3987` functions is a string or bytes-like object representing the URI/IRI.
Add `import rfc3987` at the beginning of your Python script or interactive session before using the module.