Skip to main content

Generate barcode PNGs with the local barcode-rest command-line tool.

Project description

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 does not start the REST server and does not use HTTP. Each operation runs only:

barcode-rest generate <symbology> --text <text> --output -

PNG bytes are read from standard output and returned directly to Python.

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 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)

Executable resolution

barcodekit resolves the executable when an image is generated, in this order:

  1. The file path passed as BarcodeKit(executable=...).
  2. The file path in BARCODEKIT_BINARY.
  3. 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

Unsupported targets:

  • macOS
  • 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.2.0. The expected SHA-256 values are committed in checksums/v0.2.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.
  • No server is started.
  • The REST API and HTTP are not used.
  • No outbound network connection is made by the wrapper.
  • Barcode text is passed only to the local barcode-rest executable.
  • The wrapper does not log barcode text.
  • Commands shown by wrapper exceptions replace the value after --text with <redacted>. Matching text returned on stderr is also redacted.

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.

Development with uv

uv sync --extra dev
uv run pytest
uv run ruff check .
uv run mypy src/barcodekit
uv build

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 MIT licensed. Platform wheels also include the notices and license texts listed in THIRD_PARTY_NOTICES.md.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

barcodekit-0.1.2-py3-none-win_amd64.whl (5.4 MB view details)

Uploaded Python 3Windows x86-64

barcodekit-0.1.2-py3-none-manylinux_2_34_x86_64.whl (5.5 MB view details)

Uploaded Python 3manylinux: glibc 2.34+ x86-64

barcodekit-0.1.2-py3-none-manylinux_2_17_aarch64.whl (4.9 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

File details

Details for the file barcodekit-0.1.2-py3-none-win_amd64.whl.

File metadata

  • Download URL: barcodekit-0.1.2-py3-none-win_amd64.whl
  • Upload date:
  • Size: 5.4 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for barcodekit-0.1.2-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 7d443965e969d538882e729acd7e12a23a9edca5c6e3c2e5f3ebf7340cb5b7f3
MD5 dbb4598dc91a3fcf1599f31fb790c93d
BLAKE2b-256 a7530652bae6ff3c54cd6bd5b97a2c611fd054c64b1726fe6d0959af2c637879

See more details on using hashes here.

Provenance

The following attestation bundles were made for barcodekit-0.1.2-py3-none-win_amd64.whl:

Publisher: release.yml on Moge800/barcodekit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file barcodekit-0.1.2-py3-none-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for barcodekit-0.1.2-py3-none-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 319b1e35fa1de82c1dc32771bf264874ae81dcf98f51f6a8a5f07175012e412a
MD5 c4801629ee91fee9dcecfe56da827a25
BLAKE2b-256 dcde228d2c9d71797cfab8ade1e4fc939696a143efb14743eb9a733dab02ef3a

See more details on using hashes here.

Provenance

The following attestation bundles were made for barcodekit-0.1.2-py3-none-manylinux_2_34_x86_64.whl:

Publisher: release.yml on Moge800/barcodekit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file barcodekit-0.1.2-py3-none-manylinux_2_17_aarch64.whl.

File metadata

File hashes

Hashes for barcodekit-0.1.2-py3-none-manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 3c61c4d5834b2e75c3b8020e8b0ab6415a9da7143a8a6eefca7d3acc284adf54
MD5 2095fac602c0f8d22f243c3d67ccf697
BLAKE2b-256 2558f32df975822a93e3e7913d27bb7c1b75a2198b77344c2629483a968cf5c5

See more details on using hashes here.

Provenance

The following attestation bundles were made for barcodekit-0.1.2-py3-none-manylinux_2_17_aarch64.whl:

Publisher: release.yml on Moge800/barcodekit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page