You are not logged in.

#1 2023-10-20 13:50:09

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,650
Website

Deal with a python package leaving tons of .pyc files [SOLVED]

What is the is the correct way to deal cleaning up after a python package creating tons of .pyc files?  They are not owned by the package, rather created by the executable post-install.  Is a post_remove scriptlet the correct way to deal with them?

Package is backintime.

Example after removing it:

/usr/share/backintime % tree
[4.0K]  .
├── [4.0K]  common
│   ├── [4.0K]  __pycache__
│   │   ├── [3.3K]  applicationinstance.cpython-34.pyc
│   │   ├── [5.9K]  applicationinstance.cpython-35.pyc
│   │   ├── [ 10K]  backintime.cpython-34.pyc
│   │   ├── [ 23K]  backintime.cpython-35.pyc
│   │   ├── [ 423]  bcolors.cpython-35.pyc
│   │   ├── [3.7K]  cli.cpython-34.pyc
│   │   ├── [6.4K]  cli.cpython-35.pyc
│   │   ├── [ 57K]  config.cpython-34.pyc
│   │   ├── [ 61K]  config.cpython-35.pyc
│   │   ├── [ 11K]  configfile.cpython-34.pyc
│   │   ├── [ 23K]  configfile.cpython-35.pyc
│   │   ├── [ 21K]  encfstools.cpython-34.pyc
│   │   ├── [ 23K]  encfstools.cpython-35.pyc
│   │   ├── [1.8K]  exceptions.cpython-34.pyc
│   │   ├── [1.8K]  exceptions.cpython-35.pyc
│   │   ├── [2.7K]  guiapplicationinstance.cpython-34.pyc
│   │   ├── [1.9K]  guiapplicationinstance.cpython-35.pyc
│   │   ├── [1.2K]  logger.cpython-34.pyc
│   │   ├── [2.7K]  logger.cpython-35.pyc
│   │   ├── [ 14K]  mount.cpython-34.pyc
│   │   ├── [ 15K]  mount.cpython-35.pyc
│   │   ├── [ 14K]  password.cpython-34.pyc
│   │   ├── [ 13K]  password.cpython-35.pyc
│   │   ├── [4.0K]  password_ipc.cpython-34.pyc
│   │   ├── [4.0K]  password_ipc.cpython-35.pyc
│   │   ├── [5.1K]  pluginmanager.cpython-34.pyc
│   │   ├── [6.3K]  pluginmanager.cpython-35.pyc
│   │   ├── [1.1K]  progress.cpython-34.pyc
│   │   ├── [1.1K]  progress.cpython-35.pyc
│   │   ├── [ 50K]  snapshots.cpython-34.pyc
│   │   ├── [ 57K]  snapshots.cpython-35.pyc
│   │   ├── [ 16K]  sshtools.cpython-34.pyc
│   │   ├── [ 19K]  sshtools.cpython-35.pyc
│   │   ├── [ 29K]  tools.cpython-34.pyc
│   │   └── [ 35K]  tools.cpython-35.pyc
│   ├── [1.9K]  applicationinstance.pyc
│   ├── [ 10K]  backintime.pyc
│   ├── [3.1K]  cli.pyc
│   ├── [ 55K]  config.pyc
│   ├── [ 12K]  configfile.pyc
│   ├── [ 21K]  encfstools.pyc
│   ├── [2.2K]  guiapplicationinstance.pyc
│   ├── [1.4K]  logger.pyc
│   ├── [ 16K]  mount.pyc
│   ├── [ 15K]  password.pyc
│   ├── [4.6K]  password_ipc.pyc
│   ├── [4.4K]  pluginmanager.pyc
│   ├── [ 46K]  snapshots.pyc
│   ├── [ 16K]  sshtools.pyc
│   └── [ 19K]  tools.pyc
├── [4.0K]  gnome
│   ├── [2.7K]  fileicons.pyc
│   ├── [2.5K]  gnometools.pyc
│   ├── [5.1K]  logviewdialog.pyc
│   ├── [2.5K]  messagebox.pyc
│   ├── [3.6K]  restoredialog.pyc
│   ├── [ 33K]  settingsdialog.pyc
│   └── [ 15K]  snapshotsdialog.pyc
├── [4.0K]  plugins
│   └── [4.0K]  __pycache__
│       ├── [2.0K]  notifyplugin.cpython-34.pyc
│       ├── [2.0K]  notifyplugin.cpython-35.pyc
│       ├── [1.5K]  qt4plugin.cpython-34.pyc
│       ├── [1.5K]  qt4plugin.cpython-35.pyc
│       ├── [3.1K]  usercallbackplugin.cpython-34.pyc
│       ├── [3.3K]  usercallbackplugin.cpython-35.pyc
│       ├── [1.9K]  userscriptsplugin.cpython-34.pyc
│       └── [1.9K]  userscriptsplugin.cpython-35.pyc
└── [4.0K]  qt4
    └── [4.0K]  __pycache__
        ├── [1.9K]  icon.cpython-34.pyc
        ├── [3.9K]  logviewdialog.cpython-34.pyc
        ├── [5.7K]  logviewdialog.cpython-35.pyc
        ├── [1.5K]  messagebox.cpython-34.pyc
        ├── [2.8K]  messagebox.cpython-35.pyc
        ├── [4.5K]  qt4tools.cpython-34.pyc
        ├── [ 12K]  qt4tools.cpython-35.pyc
        ├── [4.4K]  restoredialog.cpython-34.pyc
        ├── [4.4K]  restoredialog.cpython-35.pyc
        ├── [ 59K]  settingsdialog.cpython-34.pyc
        ├── [ 61K]  settingsdialog.cpython-35.pyc
        ├── [ 12K]  snapshotsdialog.cpython-34.pyc
        └── [ 13K]  snapshotsdialog.cpython-35.pyc

8 directories, 78 files

Last edited by graysky (2023-10-24 17:44:24)


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#2 2023-10-20 13:52:57

Scimmia
Fellow
Registered: 2012-09-01
Posts: 12,185

Re: Deal with a python package leaving tons of .pyc files [SOLVED]

They should be part of the package, then they get removed on update/uninstall.

Offline

#3 2023-10-20 15:09:32

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,650
Website

Re: Deal with a python package leaving tons of .pyc files [SOLVED]

Based on how I am building/packaging, they are not present in the pkg.tar at all.  They must be getting created after executing, no?


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#4 2023-10-20 16:39:39

tethys
Member
Registered: 2019-08-13
Posts: 115

Re: Deal with a python package leaving tons of .pyc files [SOLVED]

I just leave them there, they are cache files. If you delete them, they will again be created after execution. Sometimes they are recreated after upgrading python.

Offline

#5 2023-10-20 18:03:07

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,650
Website

Re: Deal with a python package leaving tons of .pyc files [SOLVED]

I understand that, but if the user removes the package, the goal would be to have these now orphaned cache files removed.  I only know of a post_install scriptlet to accomplish this.  Am I missing other packaging strategy?


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#6 2023-10-20 18:42:21

loqs
Member
Registered: 2014-03-06
Posts: 18,135

Re: Deal with a python package leaving tons of .pyc files [SOLVED]

Offline

#7 2023-10-20 20:27:50

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,650
Website

Re: Deal with a python package leaving tons of .pyc files [SOLVED]

Thanks for the tip, loqs, this seems to work: https://aur.archlinux.org/cgit/aur.git/ … de360b3b70


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

Board footer

Powered by FluxBB