From 5e5c5130aea0b57dbc73bbbb521afcde7df1c526 Mon Sep 17 00:00:00 2001
From: Jackson <jackson@jacksonchen666.com>
Date: Tue, 4 Aug 2026 07:39:44 +0200
Subject: [PATCH] plugins manager: always check dist-info's METADATA instead

this is a hack to make installed plugins show up with metadata for
gentoo system's, due to a specific thing explained below

in python's dist-info format[1], METADATA is required, and everything else
is optional

importlib.metadata.files()[2] (equivilent to
importlib.metadata.Distribution.files) is allowed to return None if the
thing cannot find a RECORD file, recording the list of installed files
for a python module. however, the RECORD file is optional (as it's not
METADATA).

in the case of gentoo's distutils-r1.eclass, [module].dist-info/RECORD
(and others) is deleted when installing wheels[3], which means the
aforementioned `importlib.metadata.Distribution.files` will always
return None on a lot of packages, including the separately packaged
plover plugins (which would use distutils-r1.eclass to install and
stuff)

so when this part of the code runs, `dist.files` is practically always
None, which sets `metadata_entry` to "PKG-INFO" (egg packaging format,
which is deprecated), and metadata reading is attempted, but failed,
which results in installed plugins having no metadata

making this part of the code always check METADATA and never PKG-INFO is
a hack that doesn't account egg packaging format. a better solution
would possibly be to use importlib.metadata.metadata()[4] and/or
re-evaluating the needs of this code and probably not trying to do your
own egg/dist-info detection if possible

(using `dist.files` to determine if package information is egg package
or dist-info is also very likely wrong, and a regression from previous
versions of this code, which checked whether the package was actually
dist-info properly and reading the right metadata file accordingly)

[1]: https://packaging.python.org/en/latest/specifications/recording-installed-packages/
[2]: https://docs.python.org/3/library/importlib.metadata.html#importlib.metadata.files
[3]: https://codeberg.org/gentoo/gentoo/src/commit/4e48a7cdf3242a372997581a943cf0f7f5af7507/eclass/distutils-r1.eclass#L962
[4]: https://docs.python.org/3/library/importlib.metadata.html#importlib.metadata.metadata
---
 plover/plugins_manager/local_registry.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/plover/plugins_manager/local_registry.py b/plover/plugins_manager/local_registry.py
index 85b4b4c..81d06c0 100644
--- a/plover/plugins_manager/local_registry.py
+++ b/plover/plugins_manager/local_registry.py
@@ -20,7 +20,7 @@ def list_plugins():
             continue
 
         # Determine the metadata entry type
-        metadata_entry = "METADATA" if dist.files else "PKG-INFO"
+        metadata_entry = "METADATA"
 
         # Check if the distribution has metadata
         try:
-- 
2.54.0

