diff --git a/src/flask_debugtoolbar/panels/versions.py b/src/flask_debugtoolbar/panels/versions.py index 4a90d48..a13619e 100644 --- a/src/flask_debugtoolbar/panels/versions.py +++ b/src/flask_debugtoolbar/panels/versions.py @@ -7,16 +7,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. @@ -38,15 +28,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 @@

Installed Packages

- Installation paths relative to: + Current Site Packages Directory:

-{{ python_lib }}
+{{ python_lib_dir }}
 
@@ -12,21 +12,23 @@

Installed Packages

- + + {% for package in packages %} - - - + + + + {% else %} - + - + {% endfor %}
Package VersionInstalled PathHomepageSummary
{{ package.project_name }}{{ package.version }}{{ relpath(package.location, python_lib) }}{{ package.get('Name') }}{{ package.get('Version') }}{{ package.get('Home-page') }}{{ package.get('Summary') }}
setuptoolsPython 3.8 NOT INSTALLEDInstall setuptools to display installed packages and version informationThis panel requires Python >= 3.8 in order to display installed packages and version information.