Skip to content

Commit 51a61e3

Browse files
authored
Merge pull request #91 from plone/fix-setuptools
replace usage of pkg_resources with importlib.metadata
2 parents ecaa2be + 1838b2d commit 51a61e3

10 files changed

Lines changed: 71 additions & 91 deletions

File tree

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
python-version: [3.7, 3.8, 3.9, '3.10']
18+
python-version: ["3.11", "3.12", "3.13", "3.14"]
1919

2020
steps:
2121
- uses: actions/checkout@v2

CHANGES.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ History
44
2.6 (unreleased)
55
----------------
66

7-
- Nothing changed yet.
7+
- Support only python 3.11 - 3.14
8+
[erral]
9+
10+
- Require setuptools < 82.0.0
11+
[erral]
812

913

1014
2.5 (2022-11-03)

plonecli/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# -*- coding: utf-8 -*-
22
"""Top-level package for Plone CLI."""
33

4-
import pkg_resources
4+
import importlib.metadata
55

66

77
__author__ = """Maik Derstappen"""
88
__email__ = "md@derico.de"
9-
__version__ = pkg_resources.require("plonecli")[0].version
9+
__version__ = importlib.metadata.version("plonecli")

plonecli/cli.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33

44
from __future__ import absolute_import
55

6+
import importlib.metadata
7+
68
from click_aliases import ClickAliasedGroup
79
from mrbob.cli import main as mrbobmain
8-
from pkg_resources import WorkingSet
10+
911
from plonecli.configure_mrbob import is_venv_disabled
1012
from plonecli.exceptions import NoSuchValue
1113
from plonecli.exceptions import NotInPackageError
@@ -58,10 +60,8 @@ def cli(context, list_templates, versions):
5860
if list_templates:
5961
click.echo(reg.list_templates())
6062
if versions:
61-
ws = WorkingSet()
62-
bobtemplates_dist = ws.by_key["bobtemplates.plone"]
63-
bobtemplates_version = bobtemplates_dist.version
64-
plonecli_version = ws.by_key["plonecli"].version
63+
bobtemplates_version = importlib.metadata.version("bobtemplates.plone")
64+
plonecli_version = importlib.metadata.version("plonecli")
6565
version_str = """Available packages:\n
6666
plonecli : {0}\n
6767
bobtemplates.plone: {1}\n""".format(

plonecli/configure_mrbob.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,17 @@ def configoverride_warning_post_question(configurator, question, answer):
5252

5353
def mrbob_config_exists(configurator, answer):
5454
target_directory = home_path
55-
file_name = u".mrbob"
55+
file_name = ".mrbob"
5656
file_list = os.listdir(target_directory)
5757
if file_name not in file_list:
5858
raise SkipQuestion(
59-
u"No existing mrbob config file found, so we skip this question."
59+
"No existing mrbob config file found, so we skip this question."
6060
)
6161

6262

6363
def check_git_disabled(configurator, answer):
6464
if configurator.variables["configure_mrbob.package.git.disabled"]:
65-
raise SkipQuestion(u"GIT is disabled, so we skip git related questions.")
65+
raise SkipQuestion("GIT is disabled, so we skip git related questions.")
6666

6767

6868
def get_mrbob_config_variable(varname, dirname):
@@ -73,7 +73,7 @@ def get_mrbob_config_variable(varname, dirname):
7373
file_list = os.listdir(dirname)
7474
if file_name not in file_list:
7575
return
76-
config.readfp(codecs.open(config_path, "r", "utf-8"))
76+
config.read_file(codecs.open(config_path, "r", "utf-8"))
7777
if not config.sections():
7878
return
7979
if config.has_option("variables", varname):
@@ -145,7 +145,7 @@ def is_venv_disabled():
145145

146146

147147
def generate_mrbob_ini(configurator, directory_path, answers):
148-
file_name = u".mrbob"
148+
file_name = ".mrbob"
149149
file_path = directory_path + "/" + file_name
150150
template = """[mr.bob]
151151
verbose = False
@@ -166,11 +166,14 @@ def generate_mrbob_ini(configurator, directory_path, answers):
166166
safe_string(answers["package.git.disabled"]),
167167
)
168168
if not configurator.variables["configure_mrbob.package.git.disabled"]:
169-
template = template + """package.git.init = {0}
169+
template = (
170+
template
171+
+ """package.git.init = {0}
170172
package.git.autocommit = {1}
171173
""".format(
172-
safe_string(answers["package.git.init"]),
173-
safe_string(answers["package.git.autocommit"]),
174+
safe_string(answers["package.git.init"]),
175+
safe_string(answers["package.git.autocommit"]),
176+
)
174177
)
175178
template = (
176179
template
@@ -225,6 +228,6 @@ def post_render(configurator, target_directory=None):
225228
target_directory = configurator.target_directory
226229
generate_mrbob_ini(configurator, target_directory, mrbob_config)
227230
echo(
228-
u"\nMrbob's settings have been saved to {0}/.mrbob\n".format(target_directory),
231+
"\nMrbob's settings have been saved to {0}/.mrbob\n".format(target_directory),
229232
msg_type="info",
230233
)

plonecli/registry.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
from __future__ import print_function
44

5+
import importlib.metadata
56
import os
6-
import pkg_resources
7-
87

98
try:
109
from six.moves.configparser import ConfigParser
@@ -76,7 +75,8 @@ def __init__(self, cur_dir=None):
7675
self.bob_config = read_bob_config(self.root_folder)
7776
self.templates = {}
7877
self.template_infos = {}
79-
for entry_point in pkg_resources.iter_entry_points("mrbob_templates"):
78+
79+
for entry_point in importlib.metadata.entry_points(group="mrbob_templates"):
8080
template_info_method = entry_point.load()
8181
self.template_infos[entry_point.name] = template_info_method()
8282

setup.cfg

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@ classifiers =
2121
Framework :: Plone
2222
Framework :: Plone :: 6.0
2323
Intended Audience :: Developers
24-
Programming Language :: Python :: 3
25-
Programming Language :: Python :: 3.6
26-
Programming Language :: Python :: 3.7
27-
Programming Language :: Python :: 3.8
28-
Programming Language :: Python :: 3.9
29-
Programming Language :: Python :: 3.10
24+
Programming Language :: Python :: 3.11
25+
Programming Language :: Python :: 3.12
26+
Programming Language :: Python :: 3.13
27+
Programming Language :: Python :: 3.14
3028

3129
[bumpversion]
3230
current_version = 0.1.1
@@ -42,7 +40,7 @@ universal = 1
4240

4341
[flake8]
4442
exclude = docs,tmp,tmpdist,local,lib,build,bin,dist,include,man
45-
ignore = W503, C812, E501, T001 # E203, E266
43+
ignore = W503, C812, E501, T001
4644
max-line-length = 88
4745
max-complexity = 18
4846
select = B,C,E,F,W,T4,B

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
include_package_data=True,
2121
python_requires=">=3.6",
2222
install_requires=[
23-
"setuptools",
23+
"setuptools<82.0.0",
2424
"Click>=7.0",
2525
"click-aliases",
2626
"mr.bob",

tests/test_plonecli.py

Lines changed: 15 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -70,25 +70,29 @@ def test_plonecli_test():
7070
context.obj["target_dir"] = os.path.dirname(os.path.abspath("bobtemplate.cfg"))
7171

7272
test_command_result_a = runner.invoke(
73-
cli.run_test, args=["--all"], obj=context.obj,
73+
cli.run_test,
74+
args=["--all"],
75+
obj=context.obj,
7476
)
75-
assert u"\nRUN: ./bin/test --all" in test_command_result_a.output
77+
assert "\nRUN: ./bin/test --all" in test_command_result_a.output
7678

7779
test_command_result_t_a = runner.invoke(
7880
cli.run_test,
7981
args=["-t src/collective/todo/tests/test_robot.py", "-a"],
8082
obj=context.obj,
8183
)
8284
assert (
83-
u"./bin/test --test src/collective/todo/tests/test_robot.py --all"
85+
"./bin/test --test src/collective/todo/tests/test_robot.py --all"
8486
in test_command_result_t_a.output
8587
) # NOQA: E501
8688

8789
test_command_result_s_a = runner.invoke(
88-
cli.run_test, args=["-s collective.todo", "-a"], obj=context.obj,
90+
cli.run_test,
91+
args=["-s collective.todo", "-a"],
92+
obj=context.obj,
8993
)
9094
assert (
91-
u"./bin/test --package collective.todo --all"
95+
"./bin/test --package collective.todo --all"
9296
in test_command_result_s_a.output
9397
) # NOQA: E501
9498

@@ -98,7 +102,7 @@ def test_plonecli_test():
98102
obj=context.obj,
99103
)
100104
assert (
101-
u"./bin/test --test src/collective/todo/tests/test_robot.py --package collective.todo"
105+
"./bin/test --test src/collective/todo/tests/test_robot.py --package collective.todo"
102106
in test_command_result_t_s.output
103107
) # NOQA: E501
104108

@@ -112,7 +116,7 @@ def test_plonecli_test():
112116
obj=context.obj,
113117
)
114118
assert (
115-
u"./bin/test --test src/collective/todo/tests/test_robot.py --package collective.todo --all"
119+
"./bin/test --test src/collective/todo/tests/test_robot.py --package collective.todo --all"
116120
in test_command_result.output
117121
) # NOQA: E501
118122

@@ -142,7 +146,7 @@ def test_plonecli_build_default_py(tmpdir, plonecli_bin):
142146
with open("bobtemplate.cfg", "w") as f:
143147
f.write(template)
144148
result = subprocess.check_output([plonecli_bin, "build"], cwd=target_path)
145-
assert u"\nRUN: python3 -m venv venv" in result.decode()
149+
assert "\nRUN: python3 -m venv venv" in result.decode()
146150

147151

148152
@pytest.mark.skipif(sys.version_info < (3, 7), reason="requires explicitly python3.7")
@@ -171,9 +175,10 @@ def test_plonecli_build_py_option(tmpdir, plonecli_bin):
171175
f.write(template)
172176

173177
result = subprocess.check_output(
174-
[plonecli_bin, "build", "-p", "python3"], cwd=target_path,
178+
[plonecli_bin, "build", "-p", "python3"],
179+
cwd=target_path,
175180
)
176-
assert u"\nRUN: python3 -m venv venv" in result.decode()
181+
assert "\nRUN: python3 -m venv venv" in result.decode()
177182

178183

179184
@pytest.mark.skipif(sys.version_info < (3, 0), reason="requires python3")
@@ -203,32 +208,3 @@ def test_plonecli_build_py_conf(tmpdir, plonecli_bin):
203208

204209
result = subprocess.check_output([plonecli_bin, "build"], cwd=target_path)
205210
assert "\nRUN: python3 -m venv venv" in result.decode()
206-
207-
208-
@pytest.mark.skipif(sys.version_info < (3, 0), reason="requires python3")
209-
def test_plonecli_build_target_py27(tmpdir, plonecli_bin):
210-
target_path = tmpdir.strpath
211-
os.chdir(target_path)
212-
template = """
213-
setuptools==40.8.0
214-
zc.buildout==2.13.1
215-
"""
216-
with open("requirements.txt", "w") as f:
217-
f.write(template)
218-
219-
template = """[buildout]
220-
parts =
221-
"""
222-
with open("buildout.cfg", "w") as f:
223-
f.write(template)
224-
225-
template = """[main]
226-
version = 5.2.2
227-
template = plone_addon
228-
python = python2.7
229-
"""
230-
with open("bobtemplate.cfg", "w") as f:
231-
f.write(template)
232-
233-
result = subprocess.check_output([plonecli_bin, "build"], cwd=target_path)
234-
assert "\nRUN: virtualenv -p python2.7 venv" in result.decode()

tox.ini

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
[tox]
22
envlist =
3-
{py37,py38,py39,py310},
4-
{lint-py37,lint-py38,lint-py39,lint-py310},
3+
{py311,py312,py313,py314},
4+
{lint-py311,lint-py312,lint-py313,lint-py314},
55
coverage-report,
66

77
skip_missing_interpreters = True
88

99
[travis]
1010
python =
11-
3.7: py37
12-
3.8: py38
13-
3.9: py39
14-
3.10: py310
11+
3.11: py311
12+
3.12: py312
13+
3.13: py313
14+
3.14: py314
1515

1616

1717
[testenv]
@@ -20,11 +20,10 @@ extras =
2020
test
2121

2222
basepython:
23-
py36: python3.6
24-
py37: python3.7
25-
py38: python3.8
26-
py39: python3.8
27-
py310: python3.10
23+
py311: python3.11
24+
py312: python3.12
25+
py313: python3.13
26+
py314: python3.14
2827
# pypy: pypy
2928

3029
commands =
@@ -49,12 +48,12 @@ deps =
4948
pytest-mock
5049
pytest-html
5150

52-
whitelist_externals =
51+
allowlist_externals =
5352
mkdir
5453

5554
[testenv:coverage-report]
5655
usedevelop = True
57-
basepython = python3.9
56+
basepython = python3.13
5857
deps =
5958
coverage
6059

@@ -71,15 +70,15 @@ commands =
7170
coverage xml
7271

7372
[testenv:isort-apply]
74-
basepython = python3.9
73+
basepython = python3.13
7574
deps =
7675
isort
7776

7877
commands =
7978
isort {toxinidir}/plonecli setup.py tests
8079

8180
[testenv:autopep8]
82-
basepython = python3.9
81+
basepython = python3.13
8382
skip_install = true
8483
deps =
8584
autopep8
@@ -120,29 +119,29 @@ commands =
120119
whitelist_externals =
121120
mkdir
122121

123-
[testenv:lint-py37]
124-
basepython = python3.7
122+
[testenv:lint-py311]
123+
basepython = python3.11
125124
skip_install = true
126125
deps = {[lint]deps}
127126
commands = {[lint]commands}
128127
whitelist_externals = {[lint]whitelist_externals}
129128

130-
[testenv:lint-py38]
131-
basepython = python3.8
129+
[testenv:lint-py312]
130+
basepython = python3.12
132131
skip_install = true
133132
deps = {[lint]deps}
134133
commands = {[lint]commands}
135134
whitelist_externals = {[lint]whitelist_externals}
136135

137-
[testenv:lint-py39]
138-
basepython = python3.9
136+
[testenv:lint-py313]
137+
basepython = python3.13
139138
skip_install = true
140139
deps = {[lint]deps}
141140
commands = {[lint]commands}
142141
whitelist_externals = {[lint]whitelist_externals}
143142

144-
[testenv:lint-py310]
145-
basepython = python3.10
143+
[testenv:lint-py314]
144+
basepython = python3.14
146145
skip_install = true
147146
deps = {[lint]deps}
148147
commands = {[lint]commands}

0 commit comments

Comments
 (0)