From 740668aab7abe02f47d7a69e800c61b8b5e52f51 Mon Sep 17 00:00:00 2001 From: Marcel Plch Date: Tue, 14 Jul 2020 12:58:56 +0200 Subject: [PATCH] POC: keep only cache for large, autogenerated files This saves about 2 MiB from the package. When all rpms get extracted, the comparison is as follows on an ext4 filesystem: With this patch: $ du -s usr 195828 usr/ Without this patch: $ du -s usr 198224 usr/ Which is a difference of 2.396 MiB. To reduce the filesystem footprint of the Python installation, some files are now being removed and only one level of their pycache (non-optimized) is being kept. These particular files were chosen for their size and the fact that they are autogenerated, thus hard to read. --- python3.9.spec | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/python3.9.spec b/python3.9.spec index f4488ac..b877dc0 100644 --- a/python3.9.spec +++ b/python3.9.spec @@ -17,7 +17,7 @@ URL: https://www.python.org/ %global prerel b4 %global upstream_version %{general_version}%{?prerel} Version: %{general_version}%{?prerel:~%{prerel}} -Release: 1%{?dist} +Release: 2%{?dist} License: Python @@ -1014,6 +1014,13 @@ ln -s ./python3-debug %{buildroot}%{_bindir}/python-debug %endif %endif +# Remove large, autogenerated sources and keep only the non-optimized pycache +for file in %{buildroot}%{pylibdir}/pydoc_data/topics.py $(grep --include='*.py' -lr %{buildroot}%{pylibdir}/encodings -e 'Python Character Mapping Codec .* from .* with gencodec.py'); do + directory=$(dirname ${file}) + module=$(basename ${file%%.py}) + mv ${directory}/{__pycache__/${module}.cpython-%{pyshortver}.pyc,${module}.pyc} + rm ${directory}/{__pycache__/${module}.cpython-%{pyshortver}.opt-?.pyc,${module}.py} +done # ====================================================== # Checks for packaging issues @@ -1595,6 +1602,9 @@ CheckPython optimized # ====================================================== %changelog +* Thu Jul 16 2020 Marcel Plch - 3.9.0~b4-2 +- Remove large, autogenerated Python sources and redundant pycache levels to reduce filesystem footprint + * Sat Jul 04 2020 Tomas Hrnciar - 3.9.0~b4-1 - Update to 3.9.0b4