criu/scripts
Radostin Stoyanov edb6fbb820 scripts/uninstall_module: fix package discovery
The `uninstall_module.py` script is a wrapper for the `pip uninstall`
command that enables support for specifying installation prefix
(i.e., `--prefix`). When this functionality is used, we intentionally
set `sys.path` to include only search paths for the specified prefix
to avoid unintentional uninstallation of packages in system paths.

Since `importlib_metadata` version 8.1.0, the `Distribution.from_name()`
method has been modified [1] to perform additional pre-processing of
Distribution objects [2] that requires loading distribution metadata
and results in the following error:

  File "/usr/local/lib/python3.12/site-packages/importlib_metadata/__init__.py", line 422, in <lambda>
    buckets = bucket(dists, lambda dist: bool(dist.metadata))
                                              ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/importlib_metadata/__init__.py", line 454, in metadata
    from . import _adapters
  File "/usr/local/lib/python3.12/site-packages/importlib_metadata/_adapters.py", line 3, in <module>
    import email.message
  File "/usr/lib64/python3.12/email/message.py", line 11, in <module>
    import quopri
  ModuleNotFoundError: No module named 'quopri'

This error occurs because we have excluded system paths from the list
of search paths (`sys.path`).

However, this pre-processing is not required for our use case, as we
only use the discovery mechanism of importlib_metadata to resolve the
metadata directory path of the module being uninstalled.

To fix this problem, this patch updates `uninstall_module` to avoid the
`from_name()` method and use `discover(name=package_name)` directly.

[1] a65c29adc0
[2] a65c29ad/importlib_metadata/__init__.py (L391)

Fixes: #2468

Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
2024-09-19 15:23:42 -07:00
..
build ci: enable cross compile testing for amdgpu-plugin 2024-09-19 15:23:42 -07:00
ci scripts/ci: run tests with the mocked cuda-checkpoint tool 2024-09-11 16:02:11 -07:00
nmk ci: fix codespell errors 2023-11-27 16:47:16 -08:00
criu-ns criu-ns: fix lint error 2024-09-11 16:02:11 -07:00
fake-restore.sh zdtm: check an exit code of a straced restore 2018-05-12 11:45:31 +03:00
feature-tests.mak criu: fix conflicting headers 2023-04-15 21:17:21 -07:00
fetch-clang-format.sh clang-format: disable column limit constraint 2023-10-22 13:29:25 -07:00
flake8.cfg coredump: remove unused import 2022-04-28 17:53:52 -07:00
github-indent-warnings.py lint: don't fail workflow on indent fail 2023-10-22 13:29:25 -07:00
install-criu-image-streamer.sh scripts: run shellcheck on the scripts folder 2020-10-20 00:18:24 -07:00
install-debian-pkgs.sh scripts: make newer versions of shellcheck happy 2023-10-22 13:29:25 -07:00
magic-gen.py make: remove checks for python 2 binary 2023-10-22 13:29:25 -07:00
protobuf-gen.sh scripts/protobuf-gen.sh: fix (not ignore) shellcheck warnings 2023-04-15 21:17:21 -07:00
ruff.toml make: replace flake8 with ruff 2024-09-11 16:02:11 -07:00
systemd-autofs-restart.sh Fix some codespell warnings 2022-04-28 17:53:52 -07:00
tmp-files.sh scripts: fix shellcheck warnings 2021-09-03 10:31:00 -07:00
uninstall_module.py scripts/uninstall_module: fix package discovery 2024-09-19 15:23:42 -07:00