Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Petazzoni via buildroot <buildroot@buildroot.org>
To: Federico Pellegrin <fede@evolware.org>
Cc: buildroot <buildroot@buildroot.org>
Subject: Re: [Buildroot] Python pyc only and problem with scripts
Date: Mon, 8 Aug 2022 12:20:20 +0200	[thread overview]
Message-ID: <20220808122020.0c1ec66a@windsurf> (raw)
In-Reply-To: <CAM6O0Zgc_jfn+m1ZhRByLQ4QDDAYpAOQv-9aDRgruSYKWV5wUA@mail.gmail.com>

Hello Federico,

On Mon, 8 Aug 2022 09:40:02 +0200
Federico Pellegrin <fede@evolware.org> wrote:

> I've found a minor problem related to the rt-tests package, but that maybe
> is slightly more generic and wanted to report and in case understand which
> approach would be best to fix it (and contribute a patch then if possible).
> 
> The specific problem: rt-tests, besides a few compiled executables,
> installs also two tools which are written in Python, namely hwlatdetect and
> get_cyclictest_snapshot. These are Python scripts which get installed in
> the PYLIB and then a symbolic link is done from /usr/bin to them, so ie we
> have: /usr/bin/hwlatdetect ->
> /usr/lib/python3.10/site-packages//hwlatdetect.py
> 
> Needless to say that once the pycompile.py script is run and original .py
> files are removed, of course in the "PYC only" setup (which is the
> default), then the link is broken and it will not work.
> Additionally that pyc files will not work for scripts like that, so just
> somehow fixing the link mentioned above would anyhow not work, as you need
> to execute them eventually by explicitly naming the interpreter.
> 
> I could imagine that we could have some similar other cases when we are
> installing Python scripts directly executed in PYLIB and not modules. But
> I'm not sure that installing the scripts there is a good idea as well,
> comparing with other distros that doesn't seem to be the case.
> So maybe the problem is really in rt-tests after all and the location those
> scripts get installed and I may just fix it that way (and contact upstream)?
> Otherwise should it be more generic maybe could make sense to have a
> facility to list some files that should not be converted to PYC?

Thanks for your bug report.

My initial gut feeling would indeed be that it is strange to install
scripts in /usr/lib/python, and they should be installed in /usr/bin
instead, so that /usr/lib/python is only for Python modules that can be
byte-compiled. However, I am not an expert at all in terms of Python
best practices and latest standards.

But from a Buildroot perspective, it really makes a lot of sense to be
able to do the byte-compilation at build-time (to save on startup time)
and drop the .py files (to save on filesystem footprint).

For the rt-tests case, I would therefore suggest to move those scripts
to /usr/bin.

Of course, if that problem shows up in more packages, then yes we could
think of a mechanism for packages to declare a number of py files that
should not be byte-compiled, and that should be preserved on the target.

Best regards,

Thomas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

  parent reply	other threads:[~2022-08-08 10:20 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-08  7:40 [Buildroot] Python pyc only and problem with scripts Federico Pellegrin
2022-08-08 10:05 ` Marcus Hoffmann
2022-08-08 10:17   ` Thomas Petazzoni via buildroot
2022-08-08 10:30     ` Marcus Hoffmann
2022-08-08 10:47       ` Thomas Petazzoni via buildroot
2022-08-08 17:55         ` Marcus Hoffmann
2022-08-26  9:09       ` Marcus Hoffmann
2022-08-08 10:20 ` Thomas Petazzoni via buildroot [this message]
2022-08-08 13:19   ` Federico Pellegrin
2022-08-08 20:48     ` Arnout Vandecappelle
2022-08-09  4:49       ` Federico Pellegrin
2022-08-09 12:54         ` [Buildroot] [External] - " Vincent Fazio
2022-08-09 16:35           ` Yann E. MORIN
2022-08-26 16:31       ` [Buildroot] " James Hilliard
2022-08-26 16:22 ` James Hilliard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220808122020.0c1ec66a@windsurf \
    --to=buildroot@buildroot.org \
    --cc=fede@evolware.org \
    --cc=thomas.petazzoni@bootlin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox