pip: fix editable imports for pip >= 25
What changed, and why it matters
This commit fixes a Python development workflow issue. Newer versions of pip (25+) changed how editable installs work, causing import statements inside the project's Python library to point to the wrong place. The fix re-exports symbols from the correct nested module so imports resolve correctly. It only affects local development setup and does not change the firmware or device behavior.
No security action required. This is a build/development workflow fix. Developers should ensure pip >= 25 when using editable installs as documented.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch adds re-exports to py/bitbox02/bitbox02/init.py so that ‘from .bitbox02 import common’ and similar imports resolve to the nested bitbox02 subpackage under pip >= 25 editable installs (PEP 660), rather than resolving back to the outer init.py. Documentation in BUILD.md and py/README.md is updated to state pip >= 25 is required. No firmware, cryptographic, or device-facing code is modified.
Changed components
py/bitbox02/bitbox02/__init__.pypy/README.mdBUILD.mdInspect captured patch +48 / −3
diff --git a/BUILD.md b/BUILD.md
index f8fffb6..d958d1d 100644
--- a/BUILD.md
+++ b/BUILD.md
@@ -385,6 +385,10 @@ docker exec -u 0 -it bitbox02-firmware-dev bash -c 'apt update && apt install -y
There is a Python api library in `py/bitbox02`.
+> [!IMPORTANT]
+> The Python scripts and editable installs require **pip ≥ 25**. Older pip versions will fail.
+> For setup and usage instructions, see [`py/README.md`](py/README.md).
+
### BitBox02 CLI client
Run `pip install -r py/requirements.txt` to install the deps (virtualenv recommended).
diff --git a/py/README.md b/py/README.md
index 6f096fe..49130ba 100644
--- a/py/README.md
+++ b/py/README.md
@@ -1,9 +1,18 @@
# Python scripts
-To use the scripts (`send_message.py`, `load_firmware.py` for example) go into the `bitbox02`
-directory and run `pip3 install .`.
+**Important: pip >= 25 is required.**
+Editable installs (`pip install -e …`) are only supported with pip 25 or newer.
+Older pip versions will fail due to changes in how editable installs are handled (PEP 660).
-If you plan to work on the scripts run `pip3 install -e .` instead.
+To use the scripts (e.g. `send_message.py`, `load_firmware.py`):
+```bash
+pip3 install py/bitbox02
+```
+
+To work on the library/scripts and install in editable mode:
+```bash
+pip install -e py/bitbox02
+```
It is highly recommended that you use the dockerized setup while developing, guide for setting it up
can be found in [BUILD.md](../BUILD.md).
\ No newline at end of file
diff --git a/py/bitbox02/bitbox02/__init__.py b/py/bitbox02/bitbox02/__init__.py
index e69de29..fd035dc 100644
--- a/py/bitbox02/bitbox02/__init__.py
+++ b/py/bitbox02/bitbox02/__init__.py
@@ -0,0 +1,32 @@
+"""
+This file re-exports all symbols from the nested bitbox02 subpackage.
+
+This is needed for compatibility with pip >= 25, which changed how editable installs
+resolve imports. With pip 25, "from .bitbox02 import common" inside util.py resolves
+to this outer __init__.py instead of the inner bitbox02 subpackage.
+"""
+
+# Re-export all symbols from the nested package
+from .bitbox02 import * # noqa: F401, F403
+
+# Explicitly list all public exports for type checkers and documentation
+from .bitbox02 import (
+ __version__,
+ btc_sign_needs_prevtxs,
+ Backup,
+ BitBox02,
+ BTCInputType,
+ BTCOutputExternal,
+ BTCOutputInternal,
+ BTCOutputType,
+ BTCPrevTxInputType,
+ BTCPrevTxOutputType,
+ DuplicateEntryException,
+ hww,
+ btc,
+ cardano,
+ common,
+ eth,
+ system,
+ Bootloader,
+)
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.