Skip to content

Commit 00df11d

Browse files
committed
Fix Python 3.11 and 3.14 support
1 parent 6ec7ca0 commit 00df11d

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

cookieplone/settings.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ class PythonVersionSupport:
1919
PLONE_MIN_VERSION = "6"
2020

2121
SUPPORTED_PYTHON_VERSIONS = [
22-
"3.10",
2322
"3.11",
2423
"3.12",
2524
"3.13",
25+
"3.14",
2626
]
2727

2828
# A matrix of Plone and Python version support.
@@ -34,21 +34,19 @@ class PythonVersionSupport:
3434
PLONE_PYTHON = {
3535
"6.0": PythonVersionSupport(
3636
[
37-
"3.10",
3837
"3.11",
3938
"3.12",
4039
],
41-
"3.10",
40+
"3.11",
4241
"3.12",
4342
),
4443
"6.1": PythonVersionSupport(
4544
[
46-
"3.10",
4745
"3.11",
4846
"3.12",
4947
"3.13",
5048
],
51-
"3.10",
49+
"3.11",
5250
"3.13",
5351
),
5452
}

cookieplone/utils/files.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,20 @@
77

88
from cookiecutter.utils import force_delete
99

10+
from cookieplone.utils.versions import current_python_version
11+
1012

1113
def rmtree(path: Path | str):
1214
"""Remove a directory and all its contents. Like rm -rf on Unix.
1315
1416
:param path: A directory path.
1517
"""
16-
shutil.rmtree(path, onexc=force_delete)
18+
if current_python_version() >= (3, 12):
19+
shutil.rmtree(path, onexc=force_delete)
20+
else:
21+
# Python 3.11 and earlier do not have the onexc parameter,
22+
# so we use onerror instead.
23+
shutil.rmtree(path, onerror=force_delete)
1724

1825

1926
def resolve_path(path: Path | str) -> Path:

cookieplone/utils/versions.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#
33
# SPDX-License-Identifier: MIT
44
import re
5+
import sys
56

67
import requests
78
import semver
@@ -163,3 +164,8 @@ def format_as_major_minor(version: str) -> str:
163164
version = version.split("-")[0]
164165
v = Version(version)
165166
return f"{v.major}.{v.minor}"
167+
168+
169+
def current_python_version() -> tuple[int, int]:
170+
"""Return the current Python version as tuple (major, minor)."""
171+
return sys.version_info.major, sys.version_info.minor

tests/utils/test_commands.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,18 @@ def test_check_command_is_available(cli: str, expected: str):
7070
[[], ""],
7171
[
7272
[
73-
"3.10",
7473
"3.11",
7574
"3.12",
7675
"3.13",
76+
"3.14",
7777
],
7878
"",
7979
],
8080
[
8181
[
8282
"1.5",
8383
"2.4",
84+
"3.10",
8485
],
8586
f"Python version is not supported: Got {sys.version}",
8687
],

0 commit comments

Comments
 (0)