Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.7, 3.8, 3.9, '3.10']
python-version: ["3.11", "3.12", "3.13", "3.14"]

steps:
- uses: actions/checkout@v2
Expand Down
6 changes: 5 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ History
2.6 (unreleased)
----------------

- Nothing changed yet.
- Support only python 3.11 - 3.14
[erral]

- Require setuptools < 82.0.0
[erral]


2.5 (2022-11-03)
Expand Down
4 changes: 2 additions & 2 deletions plonecli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
"""Top-level package for Plone CLI."""

import pkg_resources
import importlib.metadata


__author__ = """Maik Derstappen"""
__email__ = "md@derico.de"
__version__ = pkg_resources.require("plonecli")[0].version
__version__ = importlib.metadata.version("plonecli")
10 changes: 5 additions & 5 deletions plonecli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@

from __future__ import absolute_import

import importlib.metadata

from click_aliases import ClickAliasedGroup
from mrbob.cli import main as mrbobmain
from pkg_resources import WorkingSet

from plonecli.configure_mrbob import is_venv_disabled
from plonecli.exceptions import NoSuchValue
from plonecli.exceptions import NotInPackageError
Expand Down Expand Up @@ -58,10 +60,8 @@ def cli(context, list_templates, versions):
if list_templates:
click.echo(reg.list_templates())
if versions:
ws = WorkingSet()
bobtemplates_dist = ws.by_key["bobtemplates.plone"]
bobtemplates_version = bobtemplates_dist.version
plonecli_version = ws.by_key["plonecli"].version
bobtemplates_version = importlib.metadata.version("bobtemplates.plone")
plonecli_version = importlib.metadata.version("plonecli")
version_str = """Available packages:\n
plonecli : {0}\n
bobtemplates.plone: {1}\n""".format(
Expand Down
21 changes: 12 additions & 9 deletions plonecli/configure_mrbob.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@ def configoverride_warning_post_question(configurator, question, answer):

def mrbob_config_exists(configurator, answer):
target_directory = home_path
file_name = u".mrbob"
file_name = ".mrbob"
file_list = os.listdir(target_directory)
if file_name not in file_list:
raise SkipQuestion(
u"No existing mrbob config file found, so we skip this question."
"No existing mrbob config file found, so we skip this question."
)


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


def get_mrbob_config_variable(varname, dirname):
Expand All @@ -73,7 +73,7 @@ def get_mrbob_config_variable(varname, dirname):
file_list = os.listdir(dirname)
if file_name not in file_list:
return
config.readfp(codecs.open(config_path, "r", "utf-8"))
config.read_file(codecs.open(config_path, "r", "utf-8"))
if not config.sections():
return
if config.has_option("variables", varname):
Expand Down Expand Up @@ -145,7 +145,7 @@ def is_venv_disabled():


def generate_mrbob_ini(configurator, directory_path, answers):
file_name = u".mrbob"
file_name = ".mrbob"
file_path = directory_path + "/" + file_name
template = """[mr.bob]
verbose = False
Expand All @@ -166,11 +166,14 @@ def generate_mrbob_ini(configurator, directory_path, answers):
safe_string(answers["package.git.disabled"]),
)
if not configurator.variables["configure_mrbob.package.git.disabled"]:
template = template + """package.git.init = {0}
template = (
template
+ """package.git.init = {0}
package.git.autocommit = {1}
""".format(
safe_string(answers["package.git.init"]),
safe_string(answers["package.git.autocommit"]),
safe_string(answers["package.git.init"]),
safe_string(answers["package.git.autocommit"]),
)
)
template = (
template
Expand Down Expand Up @@ -225,6 +228,6 @@ def post_render(configurator, target_directory=None):
target_directory = configurator.target_directory
generate_mrbob_ini(configurator, target_directory, mrbob_config)
echo(
u"\nMrbob's settings have been saved to {0}/.mrbob\n".format(target_directory),
"\nMrbob's settings have been saved to {0}/.mrbob\n".format(target_directory),
msg_type="info",
)
6 changes: 3 additions & 3 deletions plonecli/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

from __future__ import print_function

import importlib.metadata
import os
import pkg_resources


try:
from six.moves.configparser import ConfigParser
Expand Down Expand Up @@ -76,7 +75,8 @@ def __init__(self, cur_dir=None):
self.bob_config = read_bob_config(self.root_folder)
self.templates = {}
self.template_infos = {}
for entry_point in pkg_resources.iter_entry_points("mrbob_templates"):

for entry_point in importlib.metadata.entry_points(group="mrbob_templates"):
template_info_method = entry_point.load()
self.template_infos[entry_point.name] = template_info_method()

Expand Down
12 changes: 5 additions & 7 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ classifiers =
Framework :: Plone
Framework :: Plone :: 6.0
Intended Audience :: Developers
Programming Language :: Python :: 3
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Programming Language :: Python :: 3.13
Programming Language :: Python :: 3.14

[bumpversion]
current_version = 0.1.1
Expand All @@ -42,7 +40,7 @@ universal = 1

[flake8]
exclude = docs,tmp,tmpdist,local,lib,build,bin,dist,include,man
ignore = W503, C812, E501, T001 # E203, E266
ignore = W503, C812, E501, T001
max-line-length = 88
max-complexity = 18
select = B,C,E,F,W,T4,B
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
include_package_data=True,
python_requires=">=3.6",
install_requires=[
"setuptools",
"setuptools<82.0.0",
"Click>=7.0",
"click-aliases",
"mr.bob",
Expand Down
54 changes: 15 additions & 39 deletions tests/test_plonecli.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,25 +70,29 @@ def test_plonecli_test():
context.obj["target_dir"] = os.path.dirname(os.path.abspath("bobtemplate.cfg"))

test_command_result_a = runner.invoke(
cli.run_test, args=["--all"], obj=context.obj,
cli.run_test,
args=["--all"],
obj=context.obj,
)
assert u"\nRUN: ./bin/test --all" in test_command_result_a.output
assert "\nRUN: ./bin/test --all" in test_command_result_a.output

test_command_result_t_a = runner.invoke(
cli.run_test,
args=["-t src/collective/todo/tests/test_robot.py", "-a"],
obj=context.obj,
)
assert (
u"./bin/test --test src/collective/todo/tests/test_robot.py --all"
"./bin/test --test src/collective/todo/tests/test_robot.py --all"
in test_command_result_t_a.output
) # NOQA: E501

test_command_result_s_a = runner.invoke(
cli.run_test, args=["-s collective.todo", "-a"], obj=context.obj,
cli.run_test,
args=["-s collective.todo", "-a"],
obj=context.obj,
)
assert (
u"./bin/test --package collective.todo --all"
"./bin/test --package collective.todo --all"
in test_command_result_s_a.output
) # NOQA: E501

Expand All @@ -98,7 +102,7 @@ def test_plonecli_test():
obj=context.obj,
)
assert (
u"./bin/test --test src/collective/todo/tests/test_robot.py --package collective.todo"
"./bin/test --test src/collective/todo/tests/test_robot.py --package collective.todo"
in test_command_result_t_s.output
) # NOQA: E501

Expand All @@ -112,7 +116,7 @@ def test_plonecli_test():
obj=context.obj,
)
assert (
u"./bin/test --test src/collective/todo/tests/test_robot.py --package collective.todo --all"
"./bin/test --test src/collective/todo/tests/test_robot.py --package collective.todo --all"
in test_command_result.output
) # NOQA: E501

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


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

result = subprocess.check_output(
[plonecli_bin, "build", "-p", "python3"], cwd=target_path,
[plonecli_bin, "build", "-p", "python3"],
cwd=target_path,
)
assert u"\nRUN: python3 -m venv venv" in result.decode()
assert "\nRUN: python3 -m venv venv" in result.decode()


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

result = subprocess.check_output([plonecli_bin, "build"], cwd=target_path)
assert "\nRUN: python3 -m venv venv" in result.decode()


@pytest.mark.skipif(sys.version_info < (3, 0), reason="requires python3")
def test_plonecli_build_target_py27(tmpdir, plonecli_bin):
target_path = tmpdir.strpath
os.chdir(target_path)
template = """
setuptools==40.8.0
zc.buildout==2.13.1
"""
with open("requirements.txt", "w") as f:
f.write(template)

template = """[buildout]
parts =
"""
with open("buildout.cfg", "w") as f:
f.write(template)

template = """[main]
version = 5.2.2
template = plone_addon
python = python2.7
"""
with open("bobtemplate.cfg", "w") as f:
f.write(template)

result = subprocess.check_output([plonecli_bin, "build"], cwd=target_path)
assert "\nRUN: virtualenv -p python2.7 venv" in result.decode()
45 changes: 22 additions & 23 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[tox]
envlist =
{py37,py38,py39,py310},
{lint-py37,lint-py38,lint-py39,lint-py310},
{py311,py312,py313,py314},
{lint-py311,lint-py312,lint-py313,lint-py314},
coverage-report,

skip_missing_interpreters = True

[travis]
python =
3.7: py37
3.8: py38
3.9: py39
3.10: py310
3.11: py311
3.12: py312
3.13: py313
3.14: py314


[testenv]
Expand All @@ -20,11 +20,10 @@ extras =
test

basepython:
py36: python3.6
py37: python3.7
py38: python3.8
py39: python3.8
py310: python3.10
py311: python3.11
py312: python3.12
py313: python3.13
py314: python3.14
# pypy: pypy

commands =
Expand All @@ -49,12 +48,12 @@ deps =
pytest-mock
pytest-html

whitelist_externals =
allowlist_externals =
mkdir

[testenv:coverage-report]
usedevelop = True
basepython = python3.9
basepython = python3.13
deps =
coverage

Expand All @@ -71,15 +70,15 @@ commands =
coverage xml

[testenv:isort-apply]
basepython = python3.9
basepython = python3.13
deps =
isort

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

[testenv:autopep8]
basepython = python3.9
basepython = python3.13
skip_install = true
deps =
autopep8
Expand Down Expand Up @@ -120,29 +119,29 @@ commands =
whitelist_externals =
mkdir

[testenv:lint-py37]
basepython = python3.7
[testenv:lint-py311]
basepython = python3.11
skip_install = true
deps = {[lint]deps}
commands = {[lint]commands}
whitelist_externals = {[lint]whitelist_externals}

[testenv:lint-py38]
basepython = python3.8
[testenv:lint-py312]
basepython = python3.12
skip_install = true
deps = {[lint]deps}
commands = {[lint]commands}
whitelist_externals = {[lint]whitelist_externals}

[testenv:lint-py39]
basepython = python3.9
[testenv:lint-py313]
basepython = python3.13
skip_install = true
deps = {[lint]deps}
commands = {[lint]commands}
whitelist_externals = {[lint]whitelist_externals}

[testenv:lint-py310]
basepython = python3.10
[testenv:lint-py314]
basepython = python3.14
skip_install = true
deps = {[lint]deps}
commands = {[lint]commands}
Expand Down