aztec-py 0.11.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- aztec_py-0.11.0/CONTRIBUTORS.md +28 -0
- aztec_py-0.11.0/LICENSE +21 -0
- aztec_py-0.11.0/LICENSE.upstream +21 -0
- aztec_py-0.11.0/MANIFEST.in +6 -0
- aztec_py-0.11.0/PKG-INFO +275 -0
- aztec_py-0.11.0/README.md +231 -0
- aztec_py-0.11.0/aztec_code_generator.py +12 -0
- aztec_py-0.11.0/aztec_py/__init__.py +39 -0
- aztec_py-0.11.0/aztec_py/__main__.py +70 -0
- aztec_py-0.11.0/aztec_py/compat.py +152 -0
- aztec_py-0.11.0/aztec_py/core.py +922 -0
- aztec_py-0.11.0/aztec_py/decode.py +34 -0
- aztec_py-0.11.0/aztec_py/error_correction.py +5 -0
- aztec_py-0.11.0/aztec_py/gs1.py +65 -0
- aztec_py-0.11.0/aztec_py/matrix.py +5 -0
- aztec_py-0.11.0/aztec_py/renderers/__init__.py +6 -0
- aztec_py-0.11.0/aztec_py/renderers/image.py +41 -0
- aztec_py-0.11.0/aztec_py/renderers/svg.py +82 -0
- aztec_py-0.11.0/aztec_py/rune.py +113 -0
- aztec_py-0.11.0/aztec_py.egg-info/PKG-INFO +275 -0
- aztec_py-0.11.0/aztec_py.egg-info/SOURCES.txt +39 -0
- aztec_py-0.11.0/aztec_py.egg-info/dependency_links.txt +1 -0
- aztec_py-0.11.0/aztec_py.egg-info/entry_points.txt +2 -0
- aztec_py-0.11.0/aztec_py.egg-info/requires.txt +22 -0
- aztec_py-0.11.0/aztec_py.egg-info/top_level.txt +2 -0
- aztec_py-0.11.0/docs/ISO_IEC_24778_TRACEABILITY.md +41 -0
- aztec_py-0.11.0/pyproject.toml +92 -0
- aztec_py-0.11.0/requirements.txt +0 -0
- aztec_py-0.11.0/setup.cfg +4 -0
- aztec_py-0.11.0/tests/test_api_behaviour.py +49 -0
- aztec_py-0.11.0/tests/test_cli.py +43 -0
- aztec_py-0.11.0/tests/test_compat_matrix.py +60 -0
- aztec_py-0.11.0/tests/test_conformance_report.py +41 -0
- aztec_py-0.11.0/tests/test_core.py +218 -0
- aztec_py-0.11.0/tests/test_decode.py +43 -0
- aztec_py-0.11.0/tests/test_gs1.py +45 -0
- aztec_py-0.11.0/tests/test_modules.py +15 -0
- aztec_py-0.11.0/tests/test_property.py +21 -0
- aztec_py-0.11.0/tests/test_renderers.py +42 -0
- aztec_py-0.11.0/tests/test_rune.py +53 -0
- aztec_py-0.11.0/tests/test_validation.py +25 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Contributors & Lineage
|
|
2
|
+
|
|
3
|
+
## Authors
|
|
4
|
+
- Originally written by Dmitry Alimov (delimitry).
|
|
5
|
+
- Updates, bug fixes, and active maintenance in this fork by greyllmmoder.
|
|
6
|
+
|
|
7
|
+
## Current maintainer
|
|
8
|
+
- greyllmmoder - https://github.com/greyllmmoder
|
|
9
|
+
|
|
10
|
+
## Upstream lineage (MIT license chain)
|
|
11
|
+
This project is a fork of **dlenski/aztec_code_generator**
|
|
12
|
+
(https://github.com/dlenski/aztec_code_generator), which is itself
|
|
13
|
+
a fork of **delimitry/aztec_code_generator**
|
|
14
|
+
(https://github.com/delimitry/aztec_code_generator).
|
|
15
|
+
|
|
16
|
+
Both upstream projects are MIT licensed. The original upstream license
|
|
17
|
+
text is preserved in `LICENSE.upstream`.
|
|
18
|
+
|
|
19
|
+
## What changed from upstream
|
|
20
|
+
- Fixed: CRLF encoding crash (upstream issue #5)
|
|
21
|
+
- Fixed: Error correction capacity calculation (upstream issue #7)
|
|
22
|
+
- Added: SVG renderer (based on upstream PR #6)
|
|
23
|
+
- Added: Type hints, docstrings, CLI, PDF output, Rune mode
|
|
24
|
+
- Restructured: Single-file module split into package
|
|
25
|
+
|
|
26
|
+
## Third-party contributions incorporated
|
|
27
|
+
- SVG support: originally authored by Zazzik1
|
|
28
|
+
(https://github.com/dlenski/aztec_code_generator/pull/6), MIT license
|
aztec_py-0.11.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 greyllmmoder
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 Dmitry Alimov
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
aztec_py-0.11.0/PKG-INFO
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: aztec-py
|
|
3
|
+
Version: 0.11.0
|
|
4
|
+
Summary: Pure-Python Aztec Code 2D barcode generator - production-grade fork
|
|
5
|
+
Author: greyllmmoder
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/greyllmmoder/python-aztec
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/greyllmmoder/python-aztec/issues
|
|
9
|
+
Project-URL: Source, https://github.com/greyllmmoder/python-aztec
|
|
10
|
+
Project-URL: Upstream, https://github.com/dlenski/aztec_code_generator
|
|
11
|
+
Keywords: aztec,barcode,2d-barcode,qr,iso-24778
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Multimedia :: Graphics
|
|
22
|
+
Requires-Python: >=3.9
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
License-File: LICENSE.upstream
|
|
26
|
+
Provides-Extra: image
|
|
27
|
+
Requires-Dist: pillow>=8.0; extra == "image"
|
|
28
|
+
Provides-Extra: svg
|
|
29
|
+
Requires-Dist: lxml>=4.9; extra == "svg"
|
|
30
|
+
Provides-Extra: pdf
|
|
31
|
+
Requires-Dist: fpdf2>=2.7; extra == "pdf"
|
|
32
|
+
Requires-Dist: pillow>=8.0; extra == "pdf"
|
|
33
|
+
Provides-Extra: decode
|
|
34
|
+
Requires-Dist: zxing>=1.0.4; extra == "decode"
|
|
35
|
+
Provides-Extra: dev
|
|
36
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
37
|
+
Requires-Dist: pytest-cov>=5.0; extra == "dev"
|
|
38
|
+
Requires-Dist: hypothesis>=6.0; extra == "dev"
|
|
39
|
+
Requires-Dist: mypy>=1.0; extra == "dev"
|
|
40
|
+
Requires-Dist: ruff>=0.5; extra == "dev"
|
|
41
|
+
Requires-Dist: pillow>=8.0; extra == "dev"
|
|
42
|
+
Requires-Dist: fpdf2>=2.7; extra == "dev"
|
|
43
|
+
Dynamic: license-file
|
|
44
|
+
|
|
45
|
+
# aztec-py
|
|
46
|
+
|
|
47
|
+
[](https://github.com/greyllmmoder/python-aztec/actions/workflows/ci.yml)
|
|
48
|
+
[](https://pypi.org/project/aztec-py/)
|
|
49
|
+
[](https://github.com/greyllmmoder/python-aztec)
|
|
50
|
+
[](https://mypy-lang.org/)
|
|
51
|
+
|
|
52
|
+
Pure-Python Aztec Code 2D barcode generator.
|
|
53
|
+
|
|
54
|
+
Forked from [`dlenski/aztec_code_generator`](https://github.com/dlenski/aztec_code_generator)
|
|
55
|
+
with production fixes, package modernization, SVG/PDF output, CLI tooling, and active maintenance.
|
|
56
|
+
|
|
57
|
+
## What Is Aztec Code?
|
|
58
|
+
|
|
59
|
+
Aztec Code is a compact 2D barcode format standardized in ISO/IEC 24778. It can encode text or
|
|
60
|
+
binary payloads with configurable error correction, and it does not require a quiet zone.
|
|
61
|
+
|
|
62
|
+
## Install
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
pip install aztec-py
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Optional extras:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
pip install "aztec-py[pdf]" # PDF output
|
|
72
|
+
pip install "aztec-py[decode]" # Decode utility via python-zxing + Java
|
|
73
|
+
pip install "aztec-py[svg]" # lxml-backed SVG workflows (optional)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Use In Your Project
|
|
77
|
+
|
|
78
|
+
Recommended dependency pins for production:
|
|
79
|
+
|
|
80
|
+
`requirements.txt`
|
|
81
|
+
```text
|
|
82
|
+
aztec-py>=0.11,<1.0
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
`pyproject.toml` (PEP 621)
|
|
86
|
+
```toml
|
|
87
|
+
[project]
|
|
88
|
+
dependencies = [
|
|
89
|
+
"aztec-py>=0.11,<1.0",
|
|
90
|
+
]
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Install directly from GitHub when you need an unreleased fix:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
pip install "aztec-py @ git+https://github.com/greyllmmoder/python-aztec.git@<tag-or-commit>"
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
For production, pin to a tag or commit SHA, not `main`.
|
|
100
|
+
|
|
101
|
+
## Quick Start
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
from aztec_py import AztecCode
|
|
105
|
+
|
|
106
|
+
code = AztecCode("Hello World")
|
|
107
|
+
code.save("hello.png", module_size=4)
|
|
108
|
+
print(code.svg())
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Production Validation
|
|
112
|
+
|
|
113
|
+
Run compatibility fixtures and generate a markdown report:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
python scripts/decoder_matrix.py --report compat_matrix_report.md
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
The script is skip-safe when decode runtime requirements (`zxing` + Java) are unavailable.
|
|
120
|
+
Use strict mode when decode checks are mandatory in CI:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
python scripts/decoder_matrix.py --strict-decode
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Generate full conformance evidence (markdown + JSON + compatibility matrix):
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
python scripts/conformance_report.py \
|
|
130
|
+
--report conformance_report.md \
|
|
131
|
+
--json conformance_report.json \
|
|
132
|
+
--matrix-report compat_matrix_report.md
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Fixture source: `tests/compat/fixtures.json`
|
|
136
|
+
Traceability matrix: `docs/ISO_IEC_24778_TRACEABILITY.md`
|
|
137
|
+
Release checklist: `PRODUCTION_CHECKLIST.md`
|
|
138
|
+
|
|
139
|
+
## CLI
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
aztec "Hello World" --format terminal
|
|
143
|
+
aztec "Hello World" --format svg > code.svg
|
|
144
|
+
aztec "Hello World" --format png --module-size 4 --output code.png
|
|
145
|
+
aztec --ec 33 --charset ISO-8859-1 "Héllo" --format svg --output code.svg
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Supported flags:
|
|
149
|
+
|
|
150
|
+
- `--format/-f`: `svg`, `png`, `terminal` (default: `terminal`)
|
|
151
|
+
- `--module-size/-m`: module size in pixels (default: `1`)
|
|
152
|
+
- `--ec`: error correction percent (default: `23`)
|
|
153
|
+
- `--charset`: text charset/ECI hint (default: `UTF-8`)
|
|
154
|
+
- `--output/-o`: output file path (required for `png`)
|
|
155
|
+
|
|
156
|
+
## API Reference
|
|
157
|
+
|
|
158
|
+
### `AztecCode`
|
|
159
|
+
|
|
160
|
+
- `AztecCode(data, ec_percent=23, encoding=None, charset=None, size=None, compact=None)`
|
|
161
|
+
- `image(module_size=2, border=0)`
|
|
162
|
+
- `svg(module_size=1, border=1) -> str`
|
|
163
|
+
- `pdf(module_size=3, border=1) -> bytes`
|
|
164
|
+
- `save(path, module_size=2, border=0, format=None)`
|
|
165
|
+
- `print_out(border=0)`
|
|
166
|
+
- `print_fancy(border=0)`
|
|
167
|
+
|
|
168
|
+
### `AztecRune`
|
|
169
|
+
|
|
170
|
+
- `AztecRune(value)` where `value` is in `0..255`
|
|
171
|
+
- `image()`, `svg()`, `save(...)`
|
|
172
|
+
|
|
173
|
+
### GS1 Payload Helper
|
|
174
|
+
|
|
175
|
+
- `GS1Element(ai, data, variable_length=False)`
|
|
176
|
+
- `build_gs1_payload([...]) -> str`
|
|
177
|
+
- `GROUP_SEPARATOR` (`\x1d`)
|
|
178
|
+
|
|
179
|
+
Example:
|
|
180
|
+
|
|
181
|
+
```python
|
|
182
|
+
from aztec_py import AztecCode, GS1Element, build_gs1_payload
|
|
183
|
+
|
|
184
|
+
payload = build_gs1_payload(
|
|
185
|
+
[
|
|
186
|
+
GS1Element("01", "03453120000011"),
|
|
187
|
+
GS1Element("17", "120508"),
|
|
188
|
+
GS1Element("10", "ABCD1234", variable_length=True),
|
|
189
|
+
GS1Element("410", "9501101020917"),
|
|
190
|
+
]
|
|
191
|
+
)
|
|
192
|
+
AztecCode(payload).save("gs1.png", module_size=4)
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Decode Utility
|
|
196
|
+
|
|
197
|
+
```python
|
|
198
|
+
from aztec_py import AztecCode, decode
|
|
199
|
+
|
|
200
|
+
code = AztecCode("test data")
|
|
201
|
+
decoded = decode(code.image())
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
Requires `pip install "aztec-py[decode]"` and a Java runtime.
|
|
205
|
+
|
|
206
|
+
## GS1 Recipes
|
|
207
|
+
|
|
208
|
+
```python
|
|
209
|
+
from aztec_py import GS1Element, build_gs1_payload
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
1. GTIN + Expiry (fixed-length only)
|
|
213
|
+
```python
|
|
214
|
+
build_gs1_payload([
|
|
215
|
+
GS1Element("01", "03453120000011"),
|
|
216
|
+
GS1Element("17", "120508"),
|
|
217
|
+
])
|
|
218
|
+
```
|
|
219
|
+
2. GTIN + Batch/Lot + Ship To (variable field adds separator)
|
|
220
|
+
```python
|
|
221
|
+
build_gs1_payload([
|
|
222
|
+
GS1Element("01", "03453120000011"),
|
|
223
|
+
GS1Element("10", "ABCD1234", variable_length=True),
|
|
224
|
+
GS1Element("410", "9501101020917"),
|
|
225
|
+
])
|
|
226
|
+
```
|
|
227
|
+
3. GTIN + Serial
|
|
228
|
+
```python
|
|
229
|
+
build_gs1_payload([
|
|
230
|
+
GS1Element("01", "03453120000011"),
|
|
231
|
+
GS1Element("21", "SERIAL0001", variable_length=True),
|
|
232
|
+
])
|
|
233
|
+
```
|
|
234
|
+
4. GTIN + Weight (kg)
|
|
235
|
+
```python
|
|
236
|
+
build_gs1_payload([
|
|
237
|
+
GS1Element("01", "03453120000011"),
|
|
238
|
+
GS1Element("3103", "000750"),
|
|
239
|
+
])
|
|
240
|
+
```
|
|
241
|
+
5. GTIN + Expiry + Serial + Destination
|
|
242
|
+
```python
|
|
243
|
+
build_gs1_payload([
|
|
244
|
+
GS1Element("01", "03453120000011"),
|
|
245
|
+
GS1Element("17", "120508"),
|
|
246
|
+
GS1Element("21", "XYZ12345", variable_length=True),
|
|
247
|
+
GS1Element("410", "9501101020917"),
|
|
248
|
+
])
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
## Comparison
|
|
252
|
+
|
|
253
|
+
| Library | Pure Python encode | SVG | CLI | Rune | PDF | Notes |
|
|
254
|
+
|---|---:|---:|---:|---:|---:|---|
|
|
255
|
+
| `aztec-py` | Yes | Yes | Yes | Yes | Yes | Active fork with bugfixes |
|
|
256
|
+
| `dlenski/aztec_code_generator` | Yes | PR pending | No | No | No | Upstream fork |
|
|
257
|
+
| `delimitry/aztec_code_generator` | Yes | No | No | No | No | Original lineage |
|
|
258
|
+
| `treepoem` | No (BWIPP/Ghostscript backend) | Via backend | No | Backend-dependent | Via backend | Wrapper-based |
|
|
259
|
+
| Aspose Barcode | No (proprietary) | Yes | N/A | Yes | Yes | Commercial SDK |
|
|
260
|
+
|
|
261
|
+
## Lineage and Attribution
|
|
262
|
+
|
|
263
|
+
- Originally written by Dmitry Alimov (delimitry); this fork's updates and bug fixes are maintained by greyllmmoder.
|
|
264
|
+
- Upstream fork source: https://github.com/dlenski/aztec_code_generator
|
|
265
|
+
- Original project: https://github.com/delimitry/aztec_code_generator
|
|
266
|
+
- License chain: MIT (`LICENSE` and `LICENSE.upstream`)
|
|
267
|
+
- SVG support based on upstream PR #6 by Zazzik1:
|
|
268
|
+
https://github.com/dlenski/aztec_code_generator/pull/6
|
|
269
|
+
|
|
270
|
+
## Contributing
|
|
271
|
+
|
|
272
|
+
- Read contribution guidelines: `CONTRIBUTING.md`
|
|
273
|
+
- Security reporting process: `SECURITY.md`
|
|
274
|
+
- Production release checks: `PRODUCTION_CHECKLIST.md`
|
|
275
|
+
- To sync standard labels (after `gh auth login`): `./scripts/sync_labels.sh`
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
# aztec-py
|
|
2
|
+
|
|
3
|
+
[](https://github.com/greyllmmoder/python-aztec/actions/workflows/ci.yml)
|
|
4
|
+
[](https://pypi.org/project/aztec-py/)
|
|
5
|
+
[](https://github.com/greyllmmoder/python-aztec)
|
|
6
|
+
[](https://mypy-lang.org/)
|
|
7
|
+
|
|
8
|
+
Pure-Python Aztec Code 2D barcode generator.
|
|
9
|
+
|
|
10
|
+
Forked from [`dlenski/aztec_code_generator`](https://github.com/dlenski/aztec_code_generator)
|
|
11
|
+
with production fixes, package modernization, SVG/PDF output, CLI tooling, and active maintenance.
|
|
12
|
+
|
|
13
|
+
## What Is Aztec Code?
|
|
14
|
+
|
|
15
|
+
Aztec Code is a compact 2D barcode format standardized in ISO/IEC 24778. It can encode text or
|
|
16
|
+
binary payloads with configurable error correction, and it does not require a quiet zone.
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install aztec-py
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Optional extras:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pip install "aztec-py[pdf]" # PDF output
|
|
28
|
+
pip install "aztec-py[decode]" # Decode utility via python-zxing + Java
|
|
29
|
+
pip install "aztec-py[svg]" # lxml-backed SVG workflows (optional)
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Use In Your Project
|
|
33
|
+
|
|
34
|
+
Recommended dependency pins for production:
|
|
35
|
+
|
|
36
|
+
`requirements.txt`
|
|
37
|
+
```text
|
|
38
|
+
aztec-py>=0.11,<1.0
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
`pyproject.toml` (PEP 621)
|
|
42
|
+
```toml
|
|
43
|
+
[project]
|
|
44
|
+
dependencies = [
|
|
45
|
+
"aztec-py>=0.11,<1.0",
|
|
46
|
+
]
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Install directly from GitHub when you need an unreleased fix:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
pip install "aztec-py @ git+https://github.com/greyllmmoder/python-aztec.git@<tag-or-commit>"
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
For production, pin to a tag or commit SHA, not `main`.
|
|
56
|
+
|
|
57
|
+
## Quick Start
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
from aztec_py import AztecCode
|
|
61
|
+
|
|
62
|
+
code = AztecCode("Hello World")
|
|
63
|
+
code.save("hello.png", module_size=4)
|
|
64
|
+
print(code.svg())
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Production Validation
|
|
68
|
+
|
|
69
|
+
Run compatibility fixtures and generate a markdown report:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
python scripts/decoder_matrix.py --report compat_matrix_report.md
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
The script is skip-safe when decode runtime requirements (`zxing` + Java) are unavailable.
|
|
76
|
+
Use strict mode when decode checks are mandatory in CI:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
python scripts/decoder_matrix.py --strict-decode
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Generate full conformance evidence (markdown + JSON + compatibility matrix):
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
python scripts/conformance_report.py \
|
|
86
|
+
--report conformance_report.md \
|
|
87
|
+
--json conformance_report.json \
|
|
88
|
+
--matrix-report compat_matrix_report.md
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Fixture source: `tests/compat/fixtures.json`
|
|
92
|
+
Traceability matrix: `docs/ISO_IEC_24778_TRACEABILITY.md`
|
|
93
|
+
Release checklist: `PRODUCTION_CHECKLIST.md`
|
|
94
|
+
|
|
95
|
+
## CLI
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
aztec "Hello World" --format terminal
|
|
99
|
+
aztec "Hello World" --format svg > code.svg
|
|
100
|
+
aztec "Hello World" --format png --module-size 4 --output code.png
|
|
101
|
+
aztec --ec 33 --charset ISO-8859-1 "Héllo" --format svg --output code.svg
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Supported flags:
|
|
105
|
+
|
|
106
|
+
- `--format/-f`: `svg`, `png`, `terminal` (default: `terminal`)
|
|
107
|
+
- `--module-size/-m`: module size in pixels (default: `1`)
|
|
108
|
+
- `--ec`: error correction percent (default: `23`)
|
|
109
|
+
- `--charset`: text charset/ECI hint (default: `UTF-8`)
|
|
110
|
+
- `--output/-o`: output file path (required for `png`)
|
|
111
|
+
|
|
112
|
+
## API Reference
|
|
113
|
+
|
|
114
|
+
### `AztecCode`
|
|
115
|
+
|
|
116
|
+
- `AztecCode(data, ec_percent=23, encoding=None, charset=None, size=None, compact=None)`
|
|
117
|
+
- `image(module_size=2, border=0)`
|
|
118
|
+
- `svg(module_size=1, border=1) -> str`
|
|
119
|
+
- `pdf(module_size=3, border=1) -> bytes`
|
|
120
|
+
- `save(path, module_size=2, border=0, format=None)`
|
|
121
|
+
- `print_out(border=0)`
|
|
122
|
+
- `print_fancy(border=0)`
|
|
123
|
+
|
|
124
|
+
### `AztecRune`
|
|
125
|
+
|
|
126
|
+
- `AztecRune(value)` where `value` is in `0..255`
|
|
127
|
+
- `image()`, `svg()`, `save(...)`
|
|
128
|
+
|
|
129
|
+
### GS1 Payload Helper
|
|
130
|
+
|
|
131
|
+
- `GS1Element(ai, data, variable_length=False)`
|
|
132
|
+
- `build_gs1_payload([...]) -> str`
|
|
133
|
+
- `GROUP_SEPARATOR` (`\x1d`)
|
|
134
|
+
|
|
135
|
+
Example:
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
from aztec_py import AztecCode, GS1Element, build_gs1_payload
|
|
139
|
+
|
|
140
|
+
payload = build_gs1_payload(
|
|
141
|
+
[
|
|
142
|
+
GS1Element("01", "03453120000011"),
|
|
143
|
+
GS1Element("17", "120508"),
|
|
144
|
+
GS1Element("10", "ABCD1234", variable_length=True),
|
|
145
|
+
GS1Element("410", "9501101020917"),
|
|
146
|
+
]
|
|
147
|
+
)
|
|
148
|
+
AztecCode(payload).save("gs1.png", module_size=4)
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Decode Utility
|
|
152
|
+
|
|
153
|
+
```python
|
|
154
|
+
from aztec_py import AztecCode, decode
|
|
155
|
+
|
|
156
|
+
code = AztecCode("test data")
|
|
157
|
+
decoded = decode(code.image())
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Requires `pip install "aztec-py[decode]"` and a Java runtime.
|
|
161
|
+
|
|
162
|
+
## GS1 Recipes
|
|
163
|
+
|
|
164
|
+
```python
|
|
165
|
+
from aztec_py import GS1Element, build_gs1_payload
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
1. GTIN + Expiry (fixed-length only)
|
|
169
|
+
```python
|
|
170
|
+
build_gs1_payload([
|
|
171
|
+
GS1Element("01", "03453120000011"),
|
|
172
|
+
GS1Element("17", "120508"),
|
|
173
|
+
])
|
|
174
|
+
```
|
|
175
|
+
2. GTIN + Batch/Lot + Ship To (variable field adds separator)
|
|
176
|
+
```python
|
|
177
|
+
build_gs1_payload([
|
|
178
|
+
GS1Element("01", "03453120000011"),
|
|
179
|
+
GS1Element("10", "ABCD1234", variable_length=True),
|
|
180
|
+
GS1Element("410", "9501101020917"),
|
|
181
|
+
])
|
|
182
|
+
```
|
|
183
|
+
3. GTIN + Serial
|
|
184
|
+
```python
|
|
185
|
+
build_gs1_payload([
|
|
186
|
+
GS1Element("01", "03453120000011"),
|
|
187
|
+
GS1Element("21", "SERIAL0001", variable_length=True),
|
|
188
|
+
])
|
|
189
|
+
```
|
|
190
|
+
4. GTIN + Weight (kg)
|
|
191
|
+
```python
|
|
192
|
+
build_gs1_payload([
|
|
193
|
+
GS1Element("01", "03453120000011"),
|
|
194
|
+
GS1Element("3103", "000750"),
|
|
195
|
+
])
|
|
196
|
+
```
|
|
197
|
+
5. GTIN + Expiry + Serial + Destination
|
|
198
|
+
```python
|
|
199
|
+
build_gs1_payload([
|
|
200
|
+
GS1Element("01", "03453120000011"),
|
|
201
|
+
GS1Element("17", "120508"),
|
|
202
|
+
GS1Element("21", "XYZ12345", variable_length=True),
|
|
203
|
+
GS1Element("410", "9501101020917"),
|
|
204
|
+
])
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Comparison
|
|
208
|
+
|
|
209
|
+
| Library | Pure Python encode | SVG | CLI | Rune | PDF | Notes |
|
|
210
|
+
|---|---:|---:|---:|---:|---:|---|
|
|
211
|
+
| `aztec-py` | Yes | Yes | Yes | Yes | Yes | Active fork with bugfixes |
|
|
212
|
+
| `dlenski/aztec_code_generator` | Yes | PR pending | No | No | No | Upstream fork |
|
|
213
|
+
| `delimitry/aztec_code_generator` | Yes | No | No | No | No | Original lineage |
|
|
214
|
+
| `treepoem` | No (BWIPP/Ghostscript backend) | Via backend | No | Backend-dependent | Via backend | Wrapper-based |
|
|
215
|
+
| Aspose Barcode | No (proprietary) | Yes | N/A | Yes | Yes | Commercial SDK |
|
|
216
|
+
|
|
217
|
+
## Lineage and Attribution
|
|
218
|
+
|
|
219
|
+
- Originally written by Dmitry Alimov (delimitry); this fork's updates and bug fixes are maintained by greyllmmoder.
|
|
220
|
+
- Upstream fork source: https://github.com/dlenski/aztec_code_generator
|
|
221
|
+
- Original project: https://github.com/delimitry/aztec_code_generator
|
|
222
|
+
- License chain: MIT (`LICENSE` and `LICENSE.upstream`)
|
|
223
|
+
- SVG support based on upstream PR #6 by Zazzik1:
|
|
224
|
+
https://github.com/dlenski/aztec_code_generator/pull/6
|
|
225
|
+
|
|
226
|
+
## Contributing
|
|
227
|
+
|
|
228
|
+
- Read contribution guidelines: `CONTRIBUTING.md`
|
|
229
|
+
- Security reporting process: `SECURITY.md`
|
|
230
|
+
- Production release checks: `PRODUCTION_CHECKLIST.md`
|
|
231
|
+
- To sync standard labels (after `gh auth login`): `./scripts/sync_labels.sh`
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
"""Backward-compatible import shim for the legacy module path."""
|
|
4
|
+
|
|
5
|
+
from aztec_py.core import * # noqa: F401,F403
|
|
6
|
+
from aztec_py.core import main
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
if __name__ == '__main__':
|
|
10
|
+
import sys
|
|
11
|
+
|
|
12
|
+
main(sys.argv)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"""Public package API for aztec-py."""
|
|
2
|
+
|
|
3
|
+
from .core import (
|
|
4
|
+
AztecCode,
|
|
5
|
+
Latch,
|
|
6
|
+
Misc,
|
|
7
|
+
Mode,
|
|
8
|
+
Shift,
|
|
9
|
+
encoding_to_eci,
|
|
10
|
+
find_optimal_sequence,
|
|
11
|
+
find_suitable_matrix_size,
|
|
12
|
+
get_data_codewords,
|
|
13
|
+
get_config_from_table,
|
|
14
|
+
optimal_sequence_to_bits,
|
|
15
|
+
reed_solomon,
|
|
16
|
+
)
|
|
17
|
+
from .decode import decode
|
|
18
|
+
from .gs1 import GROUP_SEPARATOR, GS1Element, build_gs1_payload
|
|
19
|
+
from .rune import AztecRune
|
|
20
|
+
|
|
21
|
+
__all__ = [
|
|
22
|
+
'AztecCode',
|
|
23
|
+
'Latch',
|
|
24
|
+
'Misc',
|
|
25
|
+
'Mode',
|
|
26
|
+
'Shift',
|
|
27
|
+
'encoding_to_eci',
|
|
28
|
+
'find_optimal_sequence',
|
|
29
|
+
'find_suitable_matrix_size',
|
|
30
|
+
'get_data_codewords',
|
|
31
|
+
'get_config_from_table',
|
|
32
|
+
'optimal_sequence_to_bits',
|
|
33
|
+
'reed_solomon',
|
|
34
|
+
'AztecRune',
|
|
35
|
+
'decode',
|
|
36
|
+
'GROUP_SEPARATOR',
|
|
37
|
+
'GS1Element',
|
|
38
|
+
'build_gs1_payload',
|
|
39
|
+
]
|