diff options
| author | Christian Breunig <christian@breunig.cc> | 2026-08-29 09:29:51 +0000 |
|---|---|---|
| committer | Christian Breunig <christian@breunig.cc> | 2026-08-30 13:40:44 +0200 |
| commit | 0e8c5e02f8b17b7b7a7905ec2b3057359edd02d6 (patch) | |
| tree | 5b91f73281af0d261ee3d9f6e86043bef378805a /scripts/cli | |
| parent | 662ad8e5a93298f8d4fe813bd615cf00d74cf4c4 (diff) | |
| download | vyos-1x-0e8c5e02f8b17b7b7a7905ec2b3057359edd02d6.tar.gz vyos-1x-0e8c5e02f8b17b7b7a7905ec2b3057359edd02d6.zip | |
debian: T9261: byte-compile the Python library on install
The package ships 188 .py files and zero .pyc. dh_python3 runs and its py3clean
counterpart is present in the generated prerm, but the postinst half is silently
dropped: debhelper only injects autoscripts where its substitution token
appears, and debian/vyos-1x.postinst does not carry one. The package therefore
cleans up bytecode that nothing ever creates.
Call py3compile directly rather than adding the token, which would also inject
the dh_installsystemd enable/start snippets for vyos-router.service and
vyos.target and change service enablement at install time.
vyos/xml_ref/cache.py needs a second pass. It is generated by update_cache.py
from the postinst itself, so it does not exist yet when py3compile walks the
package. It is a multi-megabyte dict literal and by far the most expensive
single file in the tree to parse.
Measured on a fast build host, per interpreter start:
vyos/xml_ref/cache.py 216.1 -> 32.1 ms (-85%)
import vyos.ifconfig 66.8 -> 29.0 ms (-57%)
import vyos.config 31.0 -> 20.4 ms (-34%)
Since dist-packages is writable on an installed image, a root-run script would
eventually populate __pycache__ by itself; this makes it deterministic and
covers live boot, where the overlay is tmpfs and the cost is paid every boot.
Diffstat (limited to 'scripts/cli')
0 files changed, 0 insertions, 0 deletions
