Zero-dependency QR code generator optimized for URLs
Project description
url2qr
Zero-dependency QR code generator optimized for URLs. Parallel implementations in Python and Rust, verified to produce bit-exact identical output.
Features
- Byte mode encoding (required for URLs with lowercase letters)
- EC-L error correction (7% recovery, optimized for clean screen display)
- Versions 1-6 (up to 134 characters)
- Fixed mask pattern (no scoring overhead)
- Terminal output with Unicode half-blocks
Installation
Python (pip)
pip install url2qr
Python (conda)
conda install -c mcg url2qr
Rust (cargo)
cargo install url2qr
Or add to your Cargo.toml:
[dependencies]
url2qr = "0.1"
Usage
Python
from url2qr import generate_qr, qr_to_terminal
# Display in terminal
print(qr_to_terminal("https://example.com"))
# Get raw matrix (list of lists, 1=dark, 0=light)
matrix = generate_qr("https://example.com")
Rust
use url2qr::{generate_qr, qr_to_terminal};
let matrix = generate_qr("https://example.com").unwrap();
let output = qr_to_terminal("https://example.com", 4, false).unwrap();
println!("{output}");
CLI
# Python
python url2qr.py "https://example.com"
# Rust
cargo run -- "https://example.com"
Vendoring
The Python module (url2qr.py) is designed to be vendored directly into larger projects. Simply copy the single file into your project. It is licensed under BSD 3-Clause and may be freely vendored into any other BSD 3-Clause software without credit or attribution.
Development
Prerequisites
- Python 3.9+ with pytest and qrcode (test dependency)
- Rust 1.78+ (MSRV)
Setup
# Python
pip install -e ".[test]"
pre-commit install
# Rust
cd rust && cargo build
Running Tests
# Python tests (validates against qrcode reference package)
pytest test_url2qr.py -v
# Rust tests (unit + integration with embedded reference matrices)
cd rust && cargo test
# Cross-language validation (regenerate vectors and compare)
python test-vectors/generate.py
cd rust && cargo run --bin dump_vectors > /tmp/rust_vectors.json
# Compare the two JSON files
Linting
# Python
pre-commit run --all-files
# Rust
cd rust && cargo fmt --check && cargo clippy -- -D warnings
Cross-Language Verification
Both implementations are verified to produce bit-exact identical QR matrices for all test URLs. The test-vectors/ directory contains shared test vectors generated from the Python implementation (which is itself validated against the qrcode reference package). CI runs cross-validation on every push.
Constraints
- Maximum URL length: 134 characters
- Only supports byte mode (URLs with lowercase require this)
- Fixed to EC-L and mask pattern 0
Acknowledgment
This module was developed by Michael Grant from scratch
using Claude. There are quite a few more capable QR code libraries in existence,
most notably the qrcode module used
to drive our unit tests. This module does not fork these other libraries; instead it
was constructed from first principles with significantly reduced functionality in order
to support a particular embedded use case.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file url2qr-0.1.1.tar.gz.
File metadata
- Download URL: url2qr-0.1.1.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1cb0863065548835fdc198fa10cc6aae74ddb30f6d0a8516b6ef49171a1da6aa
|
|
| MD5 |
62710cce3d40210688e62a13f7c2b2a3
|
|
| BLAKE2b-256 |
f88858263155990dd7841322636195bb7a984af8b0c41e922bf46d345b6306c1
|
Provenance
The following attestation bundles were made for url2qr-0.1.1.tar.gz:
Publisher:
release-python.yml on Anaconda-Sandbox/url2qr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
url2qr-0.1.1.tar.gz -
Subject digest:
1cb0863065548835fdc198fa10cc6aae74ddb30f6d0a8516b6ef49171a1da6aa - Sigstore transparency entry: 1191442015
- Sigstore integration time:
-
Permalink:
Anaconda-Sandbox/url2qr@202b838aa482f0332c40b2755c046d703e1d2a8e -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/Anaconda-Sandbox
-
Access:
internal
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@202b838aa482f0332c40b2755c046d703e1d2a8e -
Trigger Event:
release
-
Statement type:
File details
Details for the file url2qr-0.1.1-py3-none-any.whl.
File metadata
- Download URL: url2qr-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d90c4faacfc0af3fd573bc6bbdac7d120927f7cb28096412ab43cc3917da9eb
|
|
| MD5 |
517a96f4b3c1eeb737e1ea5535dac6ca
|
|
| BLAKE2b-256 |
6091380087f5d05faa35923bd5433fc41676e1b7e51f1155f0de68b9e9b7ed00
|
Provenance
The following attestation bundles were made for url2qr-0.1.1-py3-none-any.whl:
Publisher:
release-python.yml on Anaconda-Sandbox/url2qr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
url2qr-0.1.1-py3-none-any.whl -
Subject digest:
0d90c4faacfc0af3fd573bc6bbdac7d120927f7cb28096412ab43cc3917da9eb - Sigstore transparency entry: 1191442018
- Sigstore integration time:
-
Permalink:
Anaconda-Sandbox/url2qr@202b838aa482f0332c40b2755c046d703e1d2a8e -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/Anaconda-Sandbox
-
Access:
internal
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@202b838aa482f0332c40b2755c046d703e1d2a8e -
Trigger Event:
release
-
Statement type: