diff --git a/src/flask_debugtoolbar/panels/versions.py b/src/flask_debugtoolbar/panels/versions.py index 7d8e239..6af8b81 100644 --- a/src/flask_debugtoolbar/panels/versions.py +++ b/src/flask_debugtoolbar/panels/versions.py @@ -17,16 +17,6 @@ _ = lambda x: x -def relpath(location, python_lib): - location = os.path.normpath(location) - relative = os.path.relpath(location, python_lib) - if relative == os.path.curdir: - return '' - elif relative.startswith(os.path.pardir): - return location - return relative - - class VersionDebugPanel(DebugPanel): """ Panel that displays the Flask version. @@ -48,15 +38,14 @@ def title(self): def content(self): try: - import pkg_resources + import importlib.metadata except ImportError: packages = [] else: - packages = sorted(pkg_resources.working_set, - key=lambda p: p.project_name.lower()) + packages_metadata = [p.metadata for p in importlib.metadata.distributions()] + packages = sorted(packages_metadata, key=lambda p: p['Name'].lower()) return self.render('panels/versions.html', { 'packages': packages, - 'python_lib': os.path.normpath(get_path('platlib')), - 'relpath': relpath, + 'python_lib_dir': os.path.normpath(get_path('platlib')), }) diff --git a/src/flask_debugtoolbar/templates/panels/versions.html b/src/flask_debugtoolbar/templates/panels/versions.html index 9e9c64e..6125dff 100644 --- a/src/flask_debugtoolbar/templates/panels/versions.html +++ b/src/flask_debugtoolbar/templates/panels/versions.html @@ -1,10 +1,10 @@
- Installation paths relative to: + Current Site Packages Directory:
-{{ python_lib }} +{{ python_lib_dir }}
Package | Version | -Installed Path | +Homepage | +Summary | ||
---|---|---|---|---|---|---|
{{ package.project_name }} | -{{ package.version }} | -{{ relpath(package.location, python_lib) }} | +{{ package.get('Name') }} | +{{ package.get('Version') }} | +{{ package.get('Home-page') }} | +{{ package.get('Summary') }} |
setuptools | +Python 3.8 | NOT INSTALLED | -Install setuptools to display installed packages and version information | +This panel requires Python >= 3.8 in order to display installed packages and version information. |