Debian (and hence Ubuntu) doesn't have anything equivalent to RPM's %ghost, so we don't currently have a mechanism to make sure Python's compile cache files are removed when ThinLinc is removed (or upgraded and some files have been removed). Normally this just means some crap left on disk. On upgrade however it might causes issues as Python will gladly still load .pyc files without a corresponding .py file. So if we rely on getting an ImportError, or Python trying another import directory, then things will break. On Debian the tool dh-python is available to help packagers deal with Python cache files. Might be worth a look to see how it deals with this.
Handling uninstallation is probably easy as we have a list of expected .pyc files. Upgrade is a lot more difficult though as we need to figure out the difference before and after the upgrade and only remove the relevant files.
Here is the repo for dh-python: https://salsa.debian.org/python-team/tools/dh-python The stuff we are interested in are the postinst and prerm scripts: https://salsa.debian.org/python-team/tools/dh-python/-/tree/master/autoscripts In short, Debian will after installation list all the files included in the package (dpkg -L <pkg>) and compile each one (using the helper py3compile). And just before removal it will again list all the files included in the package, and remove any cache files it can compute based on the package file names. On an upgrade the removal of the old package is run before the compilation of the new one. So everything gets cleaned out and then re-generated.
*** This bug has been marked as a duplicate of bug 5071 ***