#1043543 autopkgtest: /usr/share/autopkgtest/lib/__pycache__ is not managed

#1043543#5
Date:
2023-08-12 17:42:08 UTC
From:
To:
Hi,

I have got old, stale, python3.10 cache files from autopkgtest on my system.


I think that simply using some modern DebHelper plugin
would ensure that the .pyc files are correctly generated on postinst
and correctly removed in post rm.

To clean-up the past I suggest a
"rm -f /usr/share/autopkgtest/lib/__pycache__/*-cpython-310.pyc"
in preinst/postinst.

Greetings,



$ ls /usr/share/autopkgtest/lib/__pycache__ -l
total 108
-rw-r--r-- 1 root root  4276  3 nov  2022 adt_binaries.cpython-310.pyc
-rw-r--r-- 1 root root  2940  3 nov  2022 adtlog.cpython-310.pyc
-rw-r--r-- 1 root root 40030  3 nov  2022 adt_testbed.cpython-310.pyc
-rw-r--r-- 1 root root 12270  3 nov  2022 autopkgtest_args.cpython-310.pyc
-rw-r--r-- 1 root root 17628  3 nov  2022 testdesc.cpython-310.pyc
-rw-r--r-- 1 root root 21171  3 nov  2022 VirtSubproc.cpython-310.pyc
$ py3versions -s
python3.11



https://www.debian.org/doc/packaging-manuals/python-policy

#1043543#10
Date:
2023-08-12 18:01:54 UTC
From:
To:
Sorry to spam, but cruft needs the full filenames in the BTS
to build a greylist of files. (along came a spider)

/usr/share/autopkgtest/lib/__pycache__/VirtSubproc.cpython-310.pyc
/usr/share/autopkgtest/lib/__pycache__/adt_binaries.cpython-310.pyc
/usr/share/autopkgtest/lib/__pycache__/adt_testbed.cpython-310.pyc
/usr/share/autopkgtest/lib/__pycache__/adtlog.cpython-310.pyc
/usr/share/autopkgtest/lib/__pycache__/autopkgtest_args.cpython-310.pyc
/usr/share/autopkgtest/lib/__pycache__/testdesc.cpython-310.pyc

#1043543#15
Date:
2023-08-12 18:16:52 UTC
From:
To:
Hi,

Call me innocent, but I'm not even seeing cache files on my system for
the recent python. When are these files created?

Paul

#1043543#20
Date:
2023-08-12 19:07:44 UTC
From:
To:
Le sam. 12 août 2023 à 20:16, Paul Gevers <elbrus@debian.org> a écrit :

I think I just ran autopkgtest once, as root, on this day at 2am...
I think I should sleep more.

So they are created anytime a user with write access to
/usr/share/autopkgtest/lib
run autopkgtest, which means root.

dh_python3 would add the calls to py3compile/py3clean,
but might have other side effects for your package that have to be
backportable to oldstable(?not sure) so you might consider calling
py3{compile/clean} directly.

Not having the .pyc files at all induce a tiny performance drop.

Another attempt right now:

$ ls -l /usr/share/autopkgtest/lib/__pycache__/*310*.pyc --full-time
-rw-r--r-- 1 root root  4276 2022-11-03 02:34:17.512478073 +0100
/usr/share/autopkgtest/lib/__pycache__/adt_binaries.cpython-310.pyc
-rw-r--r-- 1 root root  2940 2022-11-03 02:34:17.412477486 +0100
/usr/share/autopkgtest/lib/__pycache__/adtlog.cpython-310.pyc
-rw-r--r-- 1 root root 40030 2022-11-03 02:34:17.488477932 +0100
/usr/share/autopkgtest/lib/__pycache__/adt_testbed.cpython-310.pyc
-rw-r--r-- 1 root root 12270 2022-11-03 02:34:17.520478120 +0100
/usr/share/autopkgtest/lib/__pycache__/autopkgtest_args.cpython-310.pyc
-rw-r--r-- 1 root root 17628 2022-11-03 02:34:17.428477580 +0100
/usr/share/autopkgtest/lib/__pycache__/testdesc.cpython-310.pyc
-rw-r--r-- 1 root root 21171 2022-11-03 02:34:17.508478050 +0100
/usr/share/autopkgtest/lib/__pycache__/VirtSubproc.cpython-310.pyc

Original timestamps, that don't match any release date or migration to testing
or the time of day when unattended-upgrades run:

tchet@brix ~/git/cruft-ng $ ls -l
/usr/share/autopkgtest/lib/__pycache__/*311*.pyc --full-time
-rw-r--r-- 1 root root  7748 2023-08-12 20:52:27.131803347 +0200
/usr/share/autopkgtest/lib/__pycache__/adt_binaries.cpython-311.pyc
-rw-r--r-- 1 root root  5248 2023-08-12 20:52:27.067803064 +0200
/usr/share/autopkgtest/lib/__pycache__/adtlog.cpython-311.pyc
-rw-r--r-- 1 root root 79617 2023-08-12 20:52:27.179803560 +0200
/usr/share/autopkgtest/lib/__pycache__/adt_testbed.cpython-311.pyc
-rw-r--r-- 1 root root 21495 2023-08-12 20:52:27.215803720 +0200
/usr/share/autopkgtest/lib/__pycache__/autopkgtest_args.cpython-311.pyc
-rw-r--r-- 1 root root 31364 2023-08-12 20:52:27.087803152 +0200
/usr/share/autopkgtest/lib/__pycache__/testdesc.cpython-311.pyc
-rw-r--r-- 1 root root 41735 2023-08-12 20:52:27.203803667 +0200
/usr/share/autopkgtest/lib/__pycache__/VirtSubproc.cpython-311.pyc

Some minimal package that do the right thing:

$ cat /var/lib/dpkg/info/python3-six.postinst
# Automatically added by dh_python3
if command -v py3compile >/dev/null 2>&1; then
        py3compile -p python3-six
fi
# End automatically added section

$ cat /var/lib/dpkg/info/python3-six.prerm
# Automatically added by dh_python3
if command -v py3clean >/dev/null 2>&1; then
        py3clean -p python3-six
fi
# End automatically added section