Skip to contentSkip to conversation

size-stats: count compiled python (.pyc) files

PATCH In review Michael Klein via buildroot 3 participants 3 messages Sep 1, 2022 – Sep 30, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 size-stats: count compiled python (.pyc) files

Any .pyc files generated by the pycompile script during target finalization are currently counted in the "Unknown" package, because packages-file-list.txt only contains the source .py file.

If a .py file is added to filesdict, add the corresponding .pyc file as well.

---
 support/scripts/size-stats | 3 +++
 1 file changed, 3 insertions(+)
support/scripts/size-stats +3 -0
index e4389e99b5..79c0dc571e 100755
@@ -54,6 +54,9 @@ class Config:
 # pkg: package to which the file belongs
 #
 def add_file(filesdict, relpath, abspath, pkg):
+    if relpath.endswith(".py"):
+        # also check for compiled .pyc file
+        add_file(filesdict, relpath + "c", abspath + "c", pkg)
     if not os.path.exists(abspath):
         return
     if os.path.islink(abspath):
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw
Quoted 11 lines · On Thu, 1 Sep 2022 13:40:07 +0200 Michael Klein via buildroot…

Any .pyc files generated by the pycompile script during target finalization are currently counted in the "Unknown" package, because packages-file-list.txt only contains the source .py file.

If a .py file is added to filesdict, add the corresponding .pyc file as well.

---
 support/scripts/size-stats | 3 +++
 1 file changed, 3 insertions(+)

We indeed don't have a very good mechanism to "connect" files generated during the target-finalize step with their original package in a generic way, so for now what you did is I believe good enough to solve this very common case of .pyc files, and therefore I've applied to master. Thanks!

Thomas

Signature · 7 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw
In reply to Michael Klein via buildroot
Quoted 10 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Michael" == Michael Klein via buildroot <[email protected]> writes:

Any .pyc files generated by the pycompile script during target finalization are currently counted in the "Unknown" package, because packages-file-list.txt only contains the source .py file.

If a .py file is added to filesdict, add the corresponding .pyc file as well.

Committed to 2022.02.x, 2022.05.x and 2022.08.x, thanks.

Signature · 5 lines
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot