Skip to content

Commit fe3e724

Browse files
committed
dist/tools/bmp: in-line dependencies using PEP 723
PEP 723 is an accepted proposal to in-line script metadata. One such use cases is to put script dependencies inside the script, which makes the requirements.txt redundant [1]. With the correct shebang, it becomes even possible to run the script directly, without creating a virtual environment and installing dependencies in advance. Combining both makes the execution of single-file scripts within RIOT much easier and friendlier. PEP 723 metadata can be used by `pipx` [2] and can be easily installed when `pip` is available. [1] `pip install` still requires a requirements.txt, which is generally accepted during development. An open issue exists to add support for reading dependencies from PEP 723 as well. See pypa/pip#12891 [2] https://github.com/pypa/pipx
1 parent c81a103 commit fe3e724

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

dist/tools/bmp/bmp.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python3
1+
#!/usr/bin/env -S pipx run
22

33
# Copyright (C) 2019 Otto-von-Guericke-Universität Magdeburg
44
#
@@ -9,6 +9,17 @@
99
# @author Maximilian Deubel <[email protected]>
1010
# @author Bas Stottelaar <[email protected]>
1111

12+
# /// script
13+
# requires-python = ">=3.10"
14+
# dependencies = [
15+
# "humanize",
16+
# "packaging",
17+
# "progressbar",
18+
# "pygdbmi",
19+
# "pyserial"
20+
# ]
21+
# ///
22+
1223
# Black Magic Probe helper script
1324
# This script can detect connected Black Magic Probes and can be used as a flashloader and much more
1425

dist/tools/bmp/requirements.txt

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
# Dependencies are listed as PEP 723 metadata in `bmp.py`. This file exists
2+
# for compatibility reasons.
13
humanize
24
packaging
5+
progressbar
36
pygdbmi
4-
pyserial
5-
progressbar
7+
pyserial

0 commit comments

Comments
 (0)