barcodekit
barcodekit generates barcode PNG images from Python by invoking the local
barcode-rest executable in its
one-shot CLI mode.
Despite the upstream executable's name, barcodekit's default mode does not start the REST server and does not use HTTP. Each default-mode operation runs only:
barcode-rest generate <symbology> --text <text> --output -
PNG bytes are read from standard output and returned directly to Python.
For bulk generation, BarcodeKit(server=True) can opt in to a local resident
server. This starts the bundled barcode-rest process on 127.0.0.1 for the
life of the context manager, passes a generated -exit-token, and sends
requests to that local process only.
Quick start
Install the platform-specific wheel, then:
from barcodekit import code128, datamatrix, qr
datamatrix("ABC123", size=256).save("dm.png")
qr("https://example.com", size=512, level="Q").save("qr.png")
code128("ABC-123456", label=True).save("c128.png")
An explicit engine object provides the same methods:
from barcodekit import BarcodeKit
kit = BarcodeKit(timeout=10)
image = kit.datamatrix("ABC123", size=256)
raw_png = image.to_bytes()
image.save("dm.png")
For many images, use server mode to avoid starting a new process for every barcode:
from barcodekit import barcodekit
with barcodekit(server=True) as kit:
for index in range(1000):
kit.datamatrix(f"ITEM-{index:04d}", size=256).save(f"dm-{index:04d}.png")
The class form is equivalent:
from barcodekit import BarcodeKit
with BarcodeKit(server=True) as kit:
image = kit.qr("https://example.com")
Parallel bulk generation
Resident server mode can generate independent images concurrently. Results
from generate_many() remain in the same order as the input values:
from barcodekit import barcodekit
values = [f"ITEM-{index:06d}" for index in range(10_000)]
with barcodekit(server=True) as kit:
images = kit.generate_many("datamatrix", values, workers=8, size=256)
For large or streaming inputs, imap() keeps at most twice the configured
worker count queued and yields images in input order:
with barcodekit(server=True) as kit:
for index, image in enumerate(
kit.imap("qr", values, workers=8, size=256, level="M")
):
image.save(f"qr-{index:06d}.png")
Fully consuming the iterator releases its worker pool automatically. If you
may stop early, close the iterator explicitly; contextlib.closing() does so
even when the loop exits with break or an exception:
from contextlib import closing
with barcodekit(server=True) as kit:
images = kit.imap("qr", values, workers=8, size=256, level="M")
with closing(images):
for index, image in enumerate(images):
image.save(f"qr-{index:06d}.png")
if index + 1 >= 100:
break
Parallel generation requires server=True. If workers is omitted,
barcodekit uses the detected CPU count, capped at 8. More workers are not
always faster, so benchmark the intended barcode type and host. If an item
fails, BarcodeKitBatchError.index identifies its zero-based input position
without including the input text in the error message.
For datamatrix, qr, and aztec, size and module are mutually exclusive.
Set size=None when selecting the module size directly:
datamatrix("ABC123", size=None, module=8)
Using the PNG with Pillow or OpenCV
barcodekit does not depend on Pillow, OpenCV, or NumPy. If your application
already uses those libraries, optional helpers can convert the returned PNG
bytes:
from barcodekit import qr
pil_image = qr("ABC123").to_pillow()
from barcodekit import qr
cv_image = qr("ABC123").to_cv2()
to_pillow() requires Pillow at call time. to_cv2() requires OpenCV and
NumPy at call time. These packages are not installed by barcodekit.
Executable resolution
barcodekit resolves the executable when an image is generated, in this order:
- The file path passed as
BarcodeKit(executable=...). - The file path in
BARCODEKIT_BINARY. - The executable bundled in the installed platform wheel.
An explicit development binary can be used without building a wheel:
kit = BarcodeKit(executable=r"C:\tools\barcode-rest.exe")
kit.datamatrix("ABC123").save("dm.png")
Or with an environment variable:
$env:BARCODEKIT_BINARY = "C:\tools\barcode-rest.exe"
uv run python example.py
BARCODEKIT_BINARY=/opt/barcode-rest uv run python example.py
These values must be file paths; barcodekit does not search PATH.
Bundled binary wheels
Each released wheel is intended to contain exactly one matching
barcode-rest executable. It must not contain a collection of executables for
other operating systems or CPU architectures.
Supported bundled targets:
- Windows amd64
- Linux amd64 using glibc 2.34 or newer, including Ubuntu 22.04 or newer
- Linux arm64 using glibc, including 64-bit Ubuntu and 64-bit Raspberry Pi OS
- macOS 12 or newer on Intel Macs
- macOS 12 or newer on Apple Silicon Macs
Unsupported targets:
- Windows arm64
- 32-bit Linux and 32-bit Raspberry Pi OS
- musl-based Linux distributions such as Alpine Linux
Binary-free source distributions are not intended for release. On the
supported operating systems and CPU architectures listed above, development
from a source checkout remains supported with BARCODEKIT_BINARY or
BarcodeKit(executable=...).
Release builds currently pin
barcode-rest v0.3.0.
The expected SHA-256 values are committed in checksums/v0.3.0.sha256.
Supported symbologies
Two-dimensional:
- Data Matrix (
datamatrix) - QR Code (
qr) - Aztec (
aztec) - PDF417 (
pdf417)
One-dimensional:
- Code 128 (
code128) - Code 39 (
code39) - Code 93 (
code93) - Codabar (
codabar) - Interleaved 2 of 5 (
itf) - Standard 2 of 5 (
code25) - EAN-13 / JAN (
ean13) - EAN-8 (
ean8)
barcodekit validates supported options, numeric ranges, text limits, basic
character sets, and check digits before starting the executable. Encoding
constraints that depend on the generated symbol remain the responsibility of
barcode-rest.
Security and privacy
- No executable or other data is downloaded at runtime.
- By default, no server is started and the REST API / HTTP are not used.
server=Truestarts a localbarcode-restprocess bound to127.0.0.1and uses HTTP only between Python and that local process.- In server mode, barcodekit starts
barcode-restwith a generated-exit-tokenand uses it only forPOST /exitwhen the context manager is closed. - No outbound network connection is made by the wrapper.
- Barcode text is passed only to the local
barcode-restexecutable. - The wrapper does not log barcode text.
- Commands shown by wrapper exceptions replace the value after
--textwith<redacted>. Matching text returned on stderr is also redacted.
In default CLI mode, the text is necessarily passed through the local process
command line because that is the upstream CLI interface. It may therefore be
temporarily visible to users or tools with permission to inspect local process
arguments. In server=True mode, the text is sent in HTTP query strings only to
the local 127.0.0.1 process; barcode-rest logs paths only and does not log
query values.
Development with uv
uv sync --extra dev
uv run pytest
uv run ruff check .
uv run mypy src/barcodekit
uv build
Run the dependency-free benchmark to compare one-shot CLI generation with resident server worker counts on the current machine:
uv run python scripts/benchmark.py --count 200 --workers 1 2 4 8
The benchmark reports median batch latency, p95 batch latency, and images per second. Performance values are environment-specific and are not CI pass/fail criteria.
Unit tests mock subprocess.run and do not need the Go executable. If
BARCODEKIT_BINARY is set, the optional integration test generates a real
Data Matrix image and checks its PNG output.
License
barcodekit is licensed under the Apache License 2.0. Platform wheels also
include the notices and license texts listed in
THIRD_PARTY_NOTICES.md.
Metadata
Release files for barcodekit 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| barcodekit-0.2.0-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details |
| barcodekit-0.2.0-py3-none-manylinux_2_34_x86_64.whl | Python 3 | none | Linux glibc 2.34+ x86-64 | Details |
| barcodekit-0.2.0-py3-none-manylinux_2_17_aarch64.whl | Python 3 | none | Linux glibc 2.17+ ARM64 | Details |
| barcodekit-0.2.0-py3-none-macosx_12_0_x86_64.whl | Python 3 | none | macOS 12.0+ x86-64 | Details |
| barcodekit-0.2.0-py3-none-macosx_12_0_arm64.whl | Python 3 | none | macOS 12.0+ ARM64 | Details |
Total release size: 26.7 MB
Release files / barcodekit-0.2.0-py3-none-win_amd64.whl
| Download URL | barcodekit-0.2.0-py3-none-win_amd64.whl |
|---|---|
| Size | 5.4 MB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
6914a724da5b2afd1145ca2f4da1d4457f37f27eda760c59eab0bc1df7438356
|
|
BLAKE2b-256 checksum How to use checksums |
1ba2a4042b5638be0114d57218a38b3b42c54f668633e34b18ea3ef132d0a01c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 Jul 18, 2026.
Transparency logRelease files / barcodekit-0.2.0-py3-none-manylinux_2_34_x86_64.whl
| Download URL | barcodekit-0.2.0-py3-none-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 5.5 MB |
| Tags | Linux glibc 2.34+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
63814ddd417418f361bb81e4b70974b29b40f0cd2841755394bfff54935f0194
|
|
BLAKE2b-256 checksum How to use checksums |
76467335cd33228937cf78d5ea0ed95ce89e972b74dd6065d457815db9ebce77
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 Jul 18, 2026.
Transparency logRelease files / barcodekit-0.2.0-py3-none-manylinux_2_17_aarch64.whl
| Download URL | barcodekit-0.2.0-py3-none-manylinux_2_17_aarch64.whl |
|---|---|
| Size | 5.0 MB |
| Tags | Linux glibc 2.17+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
734a79b84fd1019e9399cd4df62b7bddf45c2bcd527a71b858967f0f5a8c5f85
|
|
BLAKE2b-256 checksum How to use checksums |
857442a739246bc952b9965d2cb695f77690a37b57bd114a718a274a855774ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 Jul 18, 2026.
Transparency logRelease files / barcodekit-0.2.0-py3-none-macosx_12_0_x86_64.whl
| Download URL | barcodekit-0.2.0-py3-none-macosx_12_0_x86_64.whl |
|---|---|
| Size | 5.6 MB |
| Tags | Python 3 macOS 12.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
b667426023406a839b8c5de4a3c02578ac709c573e6b7172b032daf0151d6564
|
|
BLAKE2b-256 checksum How to use checksums |
109009df7399eb8fb3589dabbe045b83776158c8e5836b3ddcbcd5633e7e0145
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 Jul 18, 2026.
Transparency logRelease files / barcodekit-0.2.0-py3-none-macosx_12_0_arm64.whl
| Download URL | barcodekit-0.2.0-py3-none-macosx_12_0_arm64.whl |
|---|---|
| Size | 5.2 MB |
| Tags | Python 3 macOS 12.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
7cf7659e2429585d4ff70c00ae6e1c5caa8b2250a7fbb201cccaf95044e5bf13
|
|
BLAKE2b-256 checksum How to use checksums |
b204d275ed1b8cd0e527101ada6e667be2854c30cc4421cb9866da93658a45b0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 Jul 18, 2026.
Transparency log