-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathpyproject.toml
More file actions
206 lines (180 loc) · 7.1 KB
/
Copy pathpyproject.toml
File metadata and controls
206 lines (180 loc) · 7.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# The MIT License (MIT)
# Copyright (c) 2021-2026 Krux contributors
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
[project]
name = "krux"
version = "26.08.0"
description = "Open-source signing device firmware for Bitcoin"
authors = [{ name = "Jeff S", email = "jeffreesun@protonmail.com" }]
readme = "README.md"
license = { text = "MIT" }
requires-python = ">=3.11.5, <3.13"
dependencies = [
"embit",
"uUR",
]
[project.optional-dependencies]
docs = [
"mkdocs>=1.6.1,<2",
"mkdocs-material>=9.7.5,<10",
"mkdocs-static-i18n>=1.3.1,<2",
"pymdown-extensions>=10.21,<11",
"mkdocs-macros-plugin>=1.5.0,<2",
]
simulator = [
"numpy>=2.4.3,<3",
"opencv-python>=4.13.0.92,<5",
"Pillow>=12.2.0,<13",
"pygame>=2.6.1,<3",
"pyzbar>=0.1.9,<1",
]
flash = [
"pyserial>=3.5,<4",
]
sign = [
"qrcode>=8.2,<9",
]
[dependency-groups]
dev = [
"black>=26.3.1,<27",
"pylint>=4.0.5,<5",
"pytest>=9.0.2,<10",
"pytest-cov>=7.0.0,<8",
"pytest-mock>=3.15.1,<4",
"PyQRCode>=1.2.1,<2",
"pycryptodome>=3.23.0,<4",
"poethepoet>=0.42.1,<1",
"vulture>=2.15,<3",
"urllib3>=2.6.3",
]
# krux is firmware, not a distributable Python package
[tool.uv]
package = false
[tool.uv.sources]
embit = { path = "vendor/embit", editable = true }
# Native BC-UR module, the same cUR sources the devices run. Not editable: it is
# a C extension, so it has to be rebuilt (uv sync --reinstall-package uUR) after
# changing the submodule anyway.
uUR = { path = "firmware/MaixPy/components/micropython/port/src/bc-ur" }
[tool.pytest.ini_options]
pythonpath = ["src"]
[tool.poe.env]
PYTHONPATH = "${POE_ROOT}/src${PYTHONPATH:+:${PYTHONPATH}}"
[tool.poe.tasks]
# format tasks
format-src = "black src"
format-tests = "black tests"
format-scripts = "black firmware/font firmware/scripts i18n/*.py"
format = ["format-src", "format-tests", "format-scripts"]
# aliases
black.ref = "format"
format-test.ref = "format-tests"
# pylint tasks
lint-src = "pylint src"
lint-scripts = "pylint firmware/font/*.py firmware/scripts/*.py i18n/*.py"
lint = ["lint-src", "lint-scripts"]
# aliases
pylint.ref = "lint"
# vulture tasks
vulture-src = "vulture src"
vulture.ref = "vulture-src vulture_whitelist.py"
vulture-make = { shell = "vulture src --make-whitelist > vulture_whitelist.py" }
vulture-whitelist.ref = "vulture-make"
# secp256k1 tasks
# Builds the libsecp256k1-zkp pinned by the embit submodule and drops it where
# embit's ctypes backend looks for it. Without it embit falls back to its pure
# Python EC implementation, which is slower and does not always behave like the
# C library the firmware runs.
secp256k1-build = { shell = """
make -C vendor/embit/secp256k1
mkdir -p vendor/embit/src/embit/util/prebuilt
cp vendor/embit/secp256k1/build/libsecp256k1_* vendor/embit/src/embit/util/prebuilt/
""" }
secp256k1-check = { shell = '''python -c "
import sys
from embit.util import secp256k1
using_c = hasattr(secp256k1, '_secp')
print('embit secp256k1 backend:', 'C library' if using_c else 'pure Python')
sys.exit(0 if using_c else 1)
"''' }
# test tasks
test-clean = """python -c 'import shutil, os; os.path.exists("htmlcov") and shutil.rmtree("htmlcov")'"""
test-cov = "pytest --cache-clear --cov src/krux --cov-report html ./tests --cov-context=test --cov-report term-missing"
test-verbose = "pytest --cache-clear --cov src/krux --cov-report html --show-capture all --capture tee-sys -r A ./tests"
test-simple = "pytest --cache-clear ./tests"
# aliases
tests = ["test-clean", "test-cov"]
test.ref = "tests"
pytest.ref = "tests"
# pre commit task (do formatting, linting and tests)
pre-commit = ["format", "lint", "i18n validate", "vulture", "test-simple"]
pre-release = ["format", "lint", "i18n validate", "i18n-build", "update-glyphs", "vulture", "test-simple"]
# run docs locally
docs = "mkdocs serve --livereload"
# translations tasks
i18n = "python i18n/i18n.py"
i18n-bake = "python i18n/i18n.py clean prettify bake"
format-translations = "black src/krux/translations/*.py"
i18n-build = ["i18n-bake", "format-translations", "i18n validate"]
# aliases
translations.ref = "i18n-build"
# simulator tasks
# tasks below accept additional arguments
simulator-amigo = "python simulator/simulator.py --device maixpy_amigo"
simulator-m5stickv = "python simulator/simulator.py --device maixpy_m5stickv"
simulator-dock = "python simulator/simulator.py --device maixpy_dock"
simulator-yahboom = "python simulator/simulator.py --device maixpy_yahboom"
simulator-cube = "python simulator/simulator.py --device maixpy_cube"
simulator-wonder-mv = "python simulator/simulator.py --device maixpy_wonder_mv"
simulator-tzt = "python simulator/simulator.py --device maixpy_tzt"
simulator-wonder-k = "python simulator/simulator.py --device maixpy_wonder_k"
simulator-embed-fire = "python simulator/simulator.py --device maixpy_embed_fire"
# aliases
simulator.ref = "simulator-amigo"
simulator-m5.ref = "simulator-m5stickv"
simulator-mv.ref = "simulator-wonder-mv"
simulator-wonder.ref = "simulator-wonder-mv"
simulator-wondermv.ref = "simulator-wonder-mv"
simulator-wonderk.ref = "simulator-wonder-k"
simulator-k.ref = "simulator-wonder-k"
simulator-embed.ref = "simulator-embed-fire"
simulator-embedfire.ref = "simulator-embed-fire"
# git tasks
git-update = "git submodule update --init --recursive"
git-pull = "git pull git@github.com:selfcustody/krux.git"
git-pull-https = "git pull https://github.com/selfcustody/krux.git"
# ktool tasks
ktool-cmd = "python firmware/Kboot/build/ktool.py -b 2000000"
flash-cmd.ref = "ktool-cmd build/kboot.kfpkg"
flash.ref = "flash-cmd -B goE"
flash-dock.ref = "flash-cmd -B dan"
boot-cmd.ref = "ktool-cmd -s build/firmware.bin"
boot.ref = "boot-cmd -B goE"
boot-dock.ref = "boot-cmd -B dan"
terminal.ref = "ktool-cmd -T" # for yahboom add param: --reset
erase.ref = "ktool-cmd -B goE -E"
erase-dock.ref = "ktool-cmd -B dan -E"
# task for bdftokff font glyphs update
update-glyphs = "python ./firmware/font/bdftokff.py True"
glyphs.ref = "update-glyphs"
fonts.ref = "update-glyphs"
# task for sign_release?
# python sign_release.py
# task for missing glyphs
missing-glyphs = "python ./firmware/font/missing_glyphs.py"
fonts-missing.ref = "missing-glyphs"
missing.ref = "missing-glyphs"