Skip to content

Commit f6aec98

Browse files
authored
remove pkg_resources unpin setuptools (#538)
* remove pkg_resources unpin setuptools * fix lint
1 parent 6f606eb commit f6aec98

7 files changed

Lines changed: 17 additions & 15 deletions

File tree

deform/renderer.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Renderer."""
22

3-
from pkg_resources import resource_filename
3+
# Standard Library
4+
from importlib.resources import files
45

56
# Deform
67
import deform
@@ -44,7 +45,7 @@ def translator(term):
4445
paths = []
4546
for path in search_path:
4647
pkg, resource_name = path.split(":")
47-
paths.append(resource_filename(pkg, resource_name))
48+
paths.append(str(files(pkg).joinpath(resource_name)))
4849

4950
deform.form.Form.default_renderer = deform.ZPTRendererFactory(
5051
tuple(paths) + default_paths, translator=translator

deform/template.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
"""Template."""
22

33
# Standard Library
4+
from importlib.resources import files
45
import os.path
56

67
from chameleon.zpt.loader import TemplateLoader
7-
from pkg_resources import resource_filename
88
from translationstring import ChameleonTranslate
99

1010
from .exception import TemplateError
@@ -39,7 +39,7 @@ def __init__(self, *args, **kwargs):
3939
def load(self, filename, *args, **kwargs):
4040
if ":" in filename:
4141
pkg_name, fn = filename.split(":", 1)
42-
filename = resource_filename(pkg_name, fn)
42+
filename = str(files(pkg_name).joinpath(fn))
4343
else:
4444
path, ext = os.path.splitext(filename)
4545
if not ext:
@@ -58,7 +58,7 @@ class ZPTRendererFactory(object):
5858
5959
If the template name is an asset spec (has a colon in it, e.g.
6060
``mypackage:subdir/subdir2/mytemplate.pt``), use
61-
``pkg_resources.resource_filename`` to resolve it.
61+
``importlib.resources`` to resolve it.
6262
Otherwise, fall back to search-path-based machinery to resolve it.
6363
6464
Allowing an asset spec allows users to specify templates without the
@@ -122,5 +122,5 @@ def load(self, template_name):
122122
return self.loader.load(template_name)
123123

124124

125-
default_dir = resource_filename("deform", "templates/")
125+
default_dir = str(files("deform").joinpath("templates"))
126126
default_renderer = ZPTRendererFactory((default_dir,))

deform/tests/test_field.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,10 @@ def test_set_default_resource_registry(self):
154154
def test_set_zpt_renderer(self):
155155
cls = self._getTargetClass()
156156
old = cls.default_renderer
157-
from pkg_resources import resource_filename
157+
# Standard Library
158+
from importlib.resources import files
158159

159-
template_dir = resource_filename("deform", "templates/")
160+
template_dir = str(files("deform").joinpath("templates"))
160161

161162
class Field:
162163
oid = None

deform/tests/test_template.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,10 @@ def _makeOne(self, dirs, **kw):
119119
return ZPTRendererFactory(dirs, **kw)
120120

121121
def test_functional(self):
122-
from pkg_resources import resource_filename
122+
# Standard Library
123+
from importlib.resources import files
123124

124-
default_dir = resource_filename("deform", "tests/fixtures/")
125+
default_dir = str(files("deform").joinpath("tests/fixtures"))
125126
renderer = self._makeOne((default_dir,))
126127
result = renderer("test")
127128
self.assertEqual(result.strip(), str("<div>Test</div>"))

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["setuptools<81.0.0", "wheel"]
2+
requires = ["setuptools", "wheel"]
33

44
[tool.black]
55
line-length = 79

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ def readfile(name):
3131
"peppercorn>=0.3", # rename operation type
3232
"translationstring>=1.0", # add format mapping with %
3333
"zope.deprecation",
34-
"setuptools<81.0.0",
3534
]
3635

3736
lint_extras = [

tox.ini

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ commands =
1414
python --version
1515
pytest {posargs:}
1616
deps =
17-
setuptools<81.0.0
17+
setuptools
1818

1919
[testenv:py311-cover]
2020
commands =
2121
python --version
2222
pytest --cov {posargs:}
2323
deps =
24-
setuptools<81.0.0
24+
setuptools
2525

2626
[testenv:lint]
2727
commands =
@@ -92,5 +92,5 @@ commands =
9292
# build wheel from sdist
9393
pip wheel -v --no-deps --no-index --no-build-isolation --wheel-dir {toxinidir}/dist --find-links {toxinidir}/dist deform
9494
deps =
95-
setuptools<81.0.0
95+
setuptools
9696
wheel

0 commit comments

Comments
 (0)