From b3918e751538bac84c87c6fe94d9ef5edbcd5e5e Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 1 Dec 2023 16:06:52 -0500 Subject: [PATCH] Added diagnose script. Closes #461. --- importlib_metadata/diagnose.py | 21 +++++++++++++++++++++ newsfragments/461.feature.rst | 1 + 2 files changed, 22 insertions(+) create mode 100644 importlib_metadata/diagnose.py create mode 100644 newsfragments/461.feature.rst diff --git a/importlib_metadata/diagnose.py b/importlib_metadata/diagnose.py new file mode 100644 index 00000000..e405471a --- /dev/null +++ b/importlib_metadata/diagnose.py @@ -0,0 +1,21 @@ +import sys + +from . import Distribution + + +def inspect(path): + print("Inspecting", path) + dists = list(Distribution.discover(path=[path])) + if not dists: + return + print("Found", len(dists), "packages:", end=' ') + print(', '.join(dist.name for dist in dists)) + + +def run(): + for path in sys.path: + inspect(path) + + +if __name__ == '__main__': + run() diff --git a/newsfragments/461.feature.rst b/newsfragments/461.feature.rst new file mode 100644 index 00000000..bf07a91b --- /dev/null +++ b/newsfragments/461.feature.rst @@ -0,0 +1 @@ +Added diagnose script. \ No newline at end of file