Skip to content

dist/tools/usb-serial: use pipx for as runner#22223

Open
maribu wants to merge 1 commit intoRIOT-OS:masterfrom
maribu:dist/tools/usb-serial/pipx
Open

dist/tools/usb-serial: use pipx for as runner#22223
maribu wants to merge 1 commit intoRIOT-OS:masterfrom
maribu:dist/tools/usb-serial/pipx

Conversation

@maribu
Copy link
Copy Markdown
Member

@maribu maribu commented Apr 28, 2026

Contribution description

This allows users to not having to care about python dependencies.

In addition SPDX annotations have been added.

Testing procedure

Run make -C examples/basic/hello-world list-ttys or dist/tools/usb-serial/ttys.py. It should now work, even if the python3-pyudev / pyudev/ py3-udev / ... package is not locally installed.

Issues/PRs references

None

Declaration of AI-Tools / LLMs usage:

AI-Tools / LLMs that were used are:

  • none

This allows users to not having to care about python dependencies.

In addition SPDX annotations have been added.
@github-actions github-actions Bot added the Area: tools Area: Supplementary tools label Apr 28, 2026
@maribu maribu added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation Impact: minor The PR is small in size and might only require a quick look of a knowledgeable reviewer CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Apr 28, 2026
@maribu maribu enabled auto-merge April 28, 2026 14:11
@crasbe
Copy link
Copy Markdown
Contributor

crasbe commented Apr 28, 2026

Am I special? 🤣

cbuec@W11nMate:~/RIOTstuff/riot-vanilla/RIOT$ make -C examples/basic/hello-world/ list-ttys
make: Entering directory '/home/cbuec/RIOTstuff/riot-vanilla/RIOT/examples/basic/hello-world'
using BOARD="native64" as "native" on a 64-bit system
/usr/bin/env: ‘pipx’: No such file or directory
make: *** [/home/cbuec/RIOTstuff/riot-vanilla/RIOT/examples/basic/hello-world/../../../Makefile.include:880: list-ttys] Error 127
make: Leaving directory '/home/cbuec/RIOTstuff/riot-vanilla/RIOT/examples/basic/hello-world'

After installing pipx, I get an infinite wall of this:

cbuec@W11nMate:~/RIOTstuff/riot-vanilla/RIOT$ make -C examples/basic/hello-world/ list-ttys
make: Entering directory '/home/cbuec/RIOTstuff/riot-vanilla/RIOT/examples/basic/hello-world'
using BOARD="native64" as "native" on a 64-bit system
⚠️  /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py is already on your PATH and installed at /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py. Downloading and running anyway.
⚠️  /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py is already on your PATH and installed at /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py. Downloading and running anyway.
⚠️  /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py is already on your PATH and installed at /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py. Downloading and running anyway.
⚠️  /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py is already on your PATH and installed at /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py. Downloading and running anyway.
⚠️  /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py is already on your PATH and installed at /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py. Downloading and running anyway.
⚠️  /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py is already on your PATH and installed at /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py. Downloading and running anyway.
⚠️  /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py is already on your PATH and installed at /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py. Downloading and running anyway.
⚠️  /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py is already on your PATH and installed at /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py. Downloading and running anyway.
⚠️  /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py is already on your PATH and installed at /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py. Downloading and running anyway.
⚠️  /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py is already on your PATH and installed at /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py. Downloading and running anyway.
⚠️  /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py is already on your PATH and installed at /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py. Downloading and running anyway.
⚠️  /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py is already on your PATH and installed at /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py. Downloading and running anyway.
⚠️  /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py is already on your PATH and installed at /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py. Downloading and running anyway.
⚠️  /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py is already on your PATH and installed at /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py. Downloading and running anyway.
⚠️  /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py is already on your PATH and installed at /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py. Downloading and running anyway.
⚠️  /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py is already on your PATH and installed at /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py. Downloading and running anyway.
...
⚠️  /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py is already on your PATH and installed at /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py. Downloading and running anyway.
⚠️  /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py is already on your PATH and installed at /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py. Downloading and running anyway.
⚠️  /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py is already on your PATH and installed at /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py. Downloading and running anyway.
⚠️  /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py is already on your PATH and installed at /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py. Downloading and running anyway.
⚠️  /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py is already on your PATH and installed at /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py. Downloading and running anyway.
⚠️  /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py is already on your PATH and installed at /home/cbuec/RIOTstuff/riot-vanilla/RIOT/dist/tools/usb-serial/ttys.py. Downloading and running anyway.
^CTraceback (most recent call last):
  File "/usr/bin/pipx", line 5, in <module>
    from pipx.main import cli
  File "/usr/lib/python3/dist-packages/pipx/main.py", line 19, in <module>
    from packaging.requirements import InvalidRequirement, Requirement
  File "/home/cbuec/.local/lib/python3.10/site-packages/packaging/requirements.py", line 8, in <module>
    from ._parser import parse_requirement as _parse_requirement
  File "/home/cbuec/.local/lib/python3.10/site-packages/packaging/_parser.py", line 12, in <module>
    from ._tokenizer import DEFAULT_RULES, Tokenizer
  File "/home/cbuec/.local/lib/python3.10/site-packages/packaging/_tokenizer.py", line 60, in <module>
    "VARIABLE": re.compile(
  File "/usr/lib/python3.10/re.py", line 251, in compile
    return _compile(pattern, flags)
  File "/usr/lib/python3.10/re.py", line 303, in _compile
    p = sre_compile.compile(pattern, flags)
  File "/usr/lib/python3.10/sre_compile.py", line 788, in compile
    p = sre_parse.parse(p, flags)
  File "/usr/lib/python3.10/sre_parse.py", line 955, in parse
    p = _parse_sub(source, state, flags & SRE_FLAG_VERBOSE, 0)
  File "/usr/lib/python3.10/sre_parse.py", line 444, in _parse_sub
    itemsappend(_parse(source, state, verbose, nested + 1,
  File "/usr/lib/python3.10/sre_parse.py", line 841, in _parse
    p = _parse_sub(source, state, sub_verbose, nested + 1)
  File "/usr/lib/python3.10/sre_parse.py", line 444, in _parse_sub
    itemsappend(_parse(source, state, verbose, nested + 1,
  File "/usr/lib/python3.10/sre_parse.py", line 525, in _parse
    if this[0] == "\\":
KeyboardInterrupt
make: *** [/home/cbuec/RIOTstuff/riot-vanilla/RIOT/examples/basic/hello-world/../../../Makefile.include:880: list-ttys] Interrupt

@crasbe
Copy link
Copy Markdown
Contributor

crasbe commented Apr 28, 2026

Perhaps it would be a good idea to add pipx to make print-versions if it's now a dependency that's regularly used?

@crasbe
Copy link
Copy Markdown
Contributor

crasbe commented Apr 28, 2026

This is Ubuntu 22.04.5 LTS on WSL btw:

cbuec@W11nMate:~/RIOTstuff/riot-vanilla/RIOT$ python3 --version
Python 3.10.12
cbuec@W11nMate:~/RIOTstuff/riot-vanilla/RIOT$ pipx --version
1.0.0

@maribu
Copy link
Copy Markdown
Member Author

maribu commented Apr 28, 2026

You could run it with pipx run pipx run dist/tools/usb-serial/ttys.py 😜

@maribu
Copy link
Copy Markdown
Member Author

maribu commented Apr 28, 2026

Maybe we should go for uv run instead, if there are still pipx versions with https://peps.python.org/pep-0723/ not implemented yet out there?

I think uv is installed using cargo install uv mostly, which will give you a recent tool.

@crasbe
Copy link
Copy Markdown
Contributor

crasbe commented Apr 28, 2026

pipx version 1.0.0 is from January 2022, so a good 1.5 years older than the PEP 👀

I installed pipx fresh with apt install pipx.

@AnnsAnns
Copy link
Copy Markdown
Member

AnnsAnns commented Apr 28, 2026

Maybe we should go for uv run instead, if there are still pipx versions with https://peps.python.org/pep-0723/ not implemented yet out there?

I think uv is installed using cargo install uv mostly, which will give you a recent tool.

I +1 a transition to uv, esp. since there is also a uv plugin for tox and I find our python tox stuff to be quite flaky since it doesn't have to benefits that uv brings to python envs like very exact version pinning. I also heard from @LasseRosenow that uv has become the quasi universal standard for modern python environments (Back in my days ppl used poetry 😔)

@riot-ci
Copy link
Copy Markdown

riot-ci commented Apr 28, 2026

Murdock results

✔️ PASSED

2ee9ec4 dist/tools/usb-serial: use pipx for as runner

Success Failures Total Runtime
1 0 1 01m:25s

Artifacts

@kfessel
Copy link
Copy Markdown
Contributor

kfessel commented Apr 29, 2026

How about adding a shell script in front that tries to identify which ever python venv management is installed

#!/bin/sh
if which pipx; then exec pipx run tty.py $*; fi
if which poetry; then exec poetry run tty.py $*; fi
if which uv; then exec uv run tty.py $*; fi
if which upy ; then exec upy tty.py $*; fi
if which python3; then exec python3 tty.py $*; fi
exec python tty.py $*

and than runs the python script through that and as a last resort just calls the script on its own to check whether the user just does not want a venv manger but had installed the dependency trough their package manger (no one would use pip).

-- instead of adding a new dependency on a specific python venv manger
there probaly already is someone that develops the new python runner finaly i get dependancy handling good somewhere

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: tools Area: Supplementary tools CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Impact: minor The PR is small in size and might only require a quick look of a knowledgeable reviewer Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants