Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dist/tools/bmp: in-line dependencies using PEP 723 #21131

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

basilfx
Copy link
Member

@basilfx basilfx commented Jan 12, 2025

Contribution description

PEP 723 is an accepted proposal to in-line script metadata. One such use cases is to list script dependencies inside the script, which makes the requirements.txt redundant.

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 and can be easily installed when pip is available. It is maintained by the PyPA, just like pip.

I chose this file to start with, but there are at least five more scripts with requirements.txt that could benefit from the same change. Because pip install still requires a requirements.txt file, which is generally accepted during development, I kept both for now. Aan open issue exists to add support for reading dependencies from PEP 723, which might make it superfluous in the future.

Testing procedure

Ensure that pipx is installed.

Alternatively, execute it from the dist/tools/bmp folder.

This script is part of the Black Magic Debugger. Execute it from the dist/tools/bmp folder, or compile any application and use PROGRAMMER=bmp to execute it from the build process.

Issues/PRs references

None

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
@github-actions github-actions bot added Area: doc Area: Documentation Area: tools Area: Supplementary tools labels Jan 12, 2025
@mguetschow
Copy link
Contributor

While I like the idea of getting rid of separate requirements.txt files and legacy pip, it's a bit unfortunate that the dependency information is now doubled in both files. I think you should add least add a comment on both sites that they need to be kept in sync.

@benpicco benpicco requested review from miri64 and maribu January 13, 2025 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: doc Area: Documentation Area: tools Area: Supplementary tools
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants