From fe3e7243068c005a1f88889770302248de8034dc Mon Sep 17 00:00:00 2001 From: Bas Stottelaar Date: Sun, 12 Jan 2025 23:59:33 +0100 Subject: [PATCH] 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 https://github.com/pypa/pip/issues/12891 [2] https://github.com/pypa/pipx --- dist/tools/bmp/bmp.py | 13 ++++++++++++- dist/tools/bmp/requirements.txt | 6 ++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/dist/tools/bmp/bmp.py b/dist/tools/bmp/bmp.py index 1c8ec3acf900..b9b6454b865b 100755 --- a/dist/tools/bmp/bmp.py +++ b/dist/tools/bmp/bmp.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env -S pipx run # Copyright (C) 2019 Otto-von-Guericke-Universität Magdeburg # @@ -9,6 +9,17 @@ # @author Maximilian Deubel # @author Bas Stottelaar +# /// script +# requires-python = ">=3.10" +# dependencies = [ +# "humanize", +# "packaging", +# "progressbar", +# "pygdbmi", +# "pyserial" +# ] +# /// + # Black Magic Probe helper script # This script can detect connected Black Magic Probes and can be used as a flashloader and much more diff --git a/dist/tools/bmp/requirements.txt b/dist/tools/bmp/requirements.txt index 01ba93f6d686..ba0a7e7d0c70 100644 --- a/dist/tools/bmp/requirements.txt +++ b/dist/tools/bmp/requirements.txt @@ -1,5 +1,7 @@ +# Dependencies are listed as PEP 723 metadata in `bmp.py`. This file exists +# for compatibility reasons. humanize packaging +progressbar pygdbmi -pyserial -progressbar \ No newline at end of file +pyserial \ No newline at end of file