🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.debian.bugs.dist
Article #845

Bug#1150896: dh-virtualenv: runtime __pycache__ left in /opt/venvs after remove and purge

#845
From: Nico Della Torre
Date: Wed, 14 Oct 2026 14:00
50 lines
3171 bytes
Package: dh-virtualenv
Version: 1.3
Severity: normal

Dear Maintainer,

packages built with dh-virtualenv leave files behind in
/opt/venvs/<pkg> after "dpkg -r" and even after "dpkg -P".

Python writes bytecode at runtime for the modules of the virtualenv
that were installed without it, for example the setuptools seeded by
virtualenv. dpkg does not know about these files, and the prerm
autoscript only removes lib/python*/__pycache__/*.pyc, not the
__pycache__ directories in site-packages.

With a test package built with "dh $@ --with python-virtualenv
--setuptools" in sid:

    $ dpkg -i hello_0.1_amd64.deb
    $ /opt/venvs/hello/bin/python -c 'import setuptools'
    $ dpkg -r hello
    dpkg: warning: while removing hello, directory
    '/opt/venvs/hello/lib/python3.14/site-packages/setuptools/config'
    not empty so not removed
    [...]
    $ dpkg -P hello
    $ find /opt/venvs -type f | wc -l
    82

The .deb ships 319 .pyc files; using the package added 82 more, and
all of them stayed after purge.

Removing every __pycache__ directory under the virtualenv in the prerm,
like py3clean does for regular Python packages, leaves nothing behind.

Nico Della Torre


-- System Information:
Debian Release: forky/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 7.2.9+deb14-amd64 (SMP w/12 CPU threads; PREEMPT)
Locale: LANG=it_IT.UTF-8, LC_CTYPE=it_IT.UTF-8 (charmap=UTF-8), LANGUAGE=it
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
Technical Details
Message-ID: <NO7Gp-5t3S-1@gated-at.bofh.it>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!fu-berlin.de!bofh.it!news.nic.it!robomod

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!fu-berlin.de!bofh.it!news.nic.it!robomod
From: Nico Della Torre <nicoz91@ubuntu.com>
Newsgroups: linux.debian.bugs.dist
Subject: Bug#1150896: dh-virtualenv: runtime __pycache__ left in /opt/venvs after remove and purge
Date: Wed, 14 Oct 2026 16:00:01 +0200
Message-ID: <NO7Gp-5t3S-1@gated-at.bofh.it>
X-Mailbox-Line: From debian-bugs-dist-request@lists.debian.org  Wed Oct 14 13:59:08 2026
Old-Return-Path: <debbugs@buxtehude.debian.org>
X-Spam-Flag: NO
X-Spam-Score: -1.651
Reply-To: Nico Della Torre <nicoz91@ubuntu.com>, 1150896@bugs.debian.org
Resent-To: debian-bugs-dist@lists.debian.org
Resent-Cc: team+python@tracker.debian.org
X-Debian-Pr-Message: report 1150896
X-Debian-Pr-Package: dh-virtualenv
X-Debian-Pr-Source: dh-virtualenv
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Mailer: reportbug 13.2.0+nmu1
X-Debian-Message: from BTS
X-Mailing-List: <debian-bugs-dist@lists.debian.org> archive/latest/1996766
List-ID: <debian-bugs-dist.lists.debian.org>
List-URL: <https://lists.debian.org/debian-bugs-dist/>
Approved: robomod@news.nic.it
Lines: 50
Organization: linux.* mail to news gateway
Sender: robomod@news.nic.it
X-Original-Date: Wed, 14 Oct 2026 15:57:10 +0200
X-Original-Message-ID: <179198623001.559694.10818055757265193859.reportbug@ryzendeb.linuxlab>