Skip to content

Commit

Permalink
Merge pull request #390 from Pylons/remove-pkg-resources
Browse files Browse the repository at this point in the history
drop setuptools / pkg_resources
  • Loading branch information
mmerickel authored Feb 4, 2024
2 parents aef15b4 + 08a0415 commit c4e7528
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 11 deletions.
6 changes: 6 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
unreleased
----------

- Remove dependency on setuptools / pkg_resources.
See https://github.com/Pylons/pyramid_debugtoolbar/pull/390

4.11 (2024-01-27)
-----------------

Expand Down
8 changes: 6 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@
#sys.path.append(os.path.abspath('some/directory'))

import datetime
import pkg_resources
import pylons_sphinx_themes
import sys, os

try:
import importlib.metadata as metadata
except ImportError:
import importlib_metadata as metadata

# General configuration
# ---------------------

Expand Down Expand Up @@ -54,7 +58,7 @@
# other places throughout the built documents.
#
# The short X.Y version.
version = pkg_resources.get_distribution('pyramid_debugtoolbar').version
version = metadata.distribution('pyramid_debugtoolbar').version

# The full version, including alpha/beta/rc tags.
release = version
Expand Down
3 changes: 1 addition & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ install_requires =
pyramid>=1.4
pyramid_mako>=0.3.1
Pygments
importlib-metadata; python_version<"3.8"
include_package_data = True
python_requires = >=3.7

Expand All @@ -54,5 +55,3 @@ testing =
docs =
Sphinx >= 1.7.5
pylons-sphinx-themes >= 0.3
# need pkg_resources in docs/conf.py
setuptools
4 changes: 2 additions & 2 deletions src/pyramid_debugtoolbar/panels/templates/versions.dbtmako
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
<tr>
<th>Package Name</th>
<th>Version</th>
<th>Location</th>
<th>Summary</th>
</tr>
</thead>
<tbody>
% for i, package in enumerate(packages):
<tr>
<td>${package['name']|h}</td>
<td>${package['version']|h}</td>
<td>${package['location']|h}</td>
<td>${package['summary']|h}</td>
</tr>
% endfor
</tbody>
Expand Down
14 changes: 9 additions & 5 deletions src/pyramid_debugtoolbar/panels/versions.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
from operator import itemgetter
import pkg_resources
import platform
import sys

from pyramid_debugtoolbar.panels import DebugPanel

try:
import importlib.metadata as metadata
except ImportError:
import importlib_metadata as metadata

_ = lambda x: x

packages = []
for distribution in pkg_resources.working_set:
name = distribution.project_name
for distribution in metadata.distributions():
name = distribution.metadata['Name']
packages.append(
{
'version': distribution.version,
'location': distribution.location,
'summary': distribution.metadata.get('Summary'),
'lowername': name.lower(),
'name': name,
}
)

packages = sorted(packages, key=itemgetter('lowername'))
pyramid_version = pkg_resources.get_distribution('pyramid').version
pyramid_version = metadata.distribution('pyramid').version


class VersionDebugPanel(DebugPanel):
Expand Down

0 comments on commit c4e7528

Please sign in to comment.