-
Notifications
You must be signed in to change notification settings - Fork 278
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
Add python-as-wrapper package and use it in asciidoc build. #36891
base: main
Are you sure you want to change the base?
Conversation
I feel like this can actually replace a lot of the shell that I've written in pipelines/py/, but even without that, it allows more build systems to "just work" by providing a |
70ac7d0
to
471cf64
Compare
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as resolved.
This comment was marked as resolved.
471cf64
to
26d4d62
Compare
26d4d62
to
29edfd5
Compare
silly question, why shell and not python https://docs.python.org/3/library/os.html#os.execv ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The concept makes sense to me, nice! Should we add some bumpers to try and avoid this getting shipped in packages/images? Maybe emit a warning when used?
It is probably difficult to tell exactly what python-as-wrapper does by reading python-as-wrapper.yaml. I encourange you to pull this branch, What you'll see is:
The
#!/bin/sh
fail() { echo "FATAL:" "$0" "$@"; exit 9; }
[ -n "${PYTHON3_AS}" ] || fail "invoked without PYTHON3_AS set"
[ "$PYTHON3_AS" -ef "$0" ] && fail "invoked with PYTHON3_AS = $0"
[ "${PYTHON3_AS}" != "${0##*/}" ] || fail "invoked with PYTHON3_AS = basename($0)"
command -v "$PYTHON3_AS" >/dev/null ||
fail "invoked with PYTHON3_AS=$PYTHON3_AS, but $PYTHON3_AS not found in PATH"
exec "${PYTHON3_AS}" "$@" The overhead of both the nums=$(seq 1 1000);
PPATH=/usr/bin/python3
time sh -c 'p=$1; shift; for n in "$@"; do $p -c pass; done' PPATH $nums
The numbers aren't scientific. Prices and participation my vary, but they do |
It would be longer text-wise and slower. It would drop a shell depends, but ... we're not really going to get rid of /bin/sh in our build environments. Here is a 'time' run of 1000 invocations of the noops `python3.13 -c pass' and 'sh -c :'. Basically, it shows the overhead of bringup of those interpreters.
|
ok, rust binary? c binary? go binary? i do understand those are harder to write over shell script. i guess future improvements. Really need to write shell -> rust transpiler. |
ideas on how? Also, thanks for the push to split out the HERE docs, this is more readable now. |
Hopefully the use here in asciidoc shows the usefulness of this wrapper. Many programs or build systems really want to use 'python3', but we really want them to use 'python3.X'. This wrapper package provides a compromise that gets rid of the "sticky" results of calling 'python3'. The big change is that now a program that uses 'python3' to write its scripts will write a shbang as '#!/usr/bin/python3.XX'
c36eb05
to
55a6335
Compare
Hopefully the use here in asciidoc shows the usefulness of this wrapper. Many programs or build systems really want to use 'python3', but we really want them to use 'python3.X'.
asciidoc's build system is hard coded to call 'python3'. I had submitted a patch upstream to allow us to use 'python3.13' here. But doing that is costly in time. Not doing it means the programs it installs in /usr/bin have shbang of 'python3', which we do not want. The python3-as-3.13 package makes that "just work" without modification.
This wrapper package provides a compromise that gets rid of the "sticky" results of calling 'python3'. The big change is that now a program that uses 'python3' to write its scripts will write a shbang as '#!/usr/bin/python3.XX'