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
42 changes: 42 additions & 0 deletions src/zope/meta/tests/test_update_python_support.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
##############################################################################
#
# Copyright (c) 2025 Zope Foundation and Contributors.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################

import tempfile
import textwrap
import unittest

from zope.meta.update_python_support import get_tox_ini_python_versions


class TestUpdatePythonSupport(unittest.TestCase):

def test_update_python_support__get_tox_ini_python_versions__1(self):
"""It filters out c-code pure versions and custom versions."""

with tempfile.NamedTemporaryFile(mode='w') as tox_ini:
tox_ini.write(textwrap.dedent("""
[tox]
minversion = 4.0
envlist =
lint
py39,py39-pure
py310,py310-pure
py311,py311-pure
pypy3
docs
coverage
py39-watch, py311-watch
"""))
tox_ini.flush()
versions = get_tox_ini_python_versions(tox_ini.name)
self.assertEqual({'3.9', '3.10', '3.11'}, versions)
29 changes: 23 additions & 6 deletions src/zope/meta/update_python_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,24 @@
from .shared.call import wait_for_accept
from .shared.git import get_branch_name
from .shared.git import git_branch
from .shared.packages import FUTURE_PYTHON_VERSION
from .shared.packages import OLDEST_PYTHON_VERSION
from .shared.packages import supported_python_versions
from .shared.path import change_dir


def get_tox_ini_python_versions(path):
def get_tox_ini_python_versions(path) -> set:
config = configparser.ConfigParser()
config.read(path)
envs = config['tox']['envlist'].split()
versions = [
raw_versions = {
env.replace('py3', '3.') for env in envs
if env.startswith('py') and env != 'pypy3'
]
return versions
}
# c-code template uses `py313,py313-pure`, get rid of the pure version:
versions = {v.partition(',')[0] for v in raw_versions}
# some packages use `py38-watch` or similar, get rid of the suffix:
return {v.partition('-')[0] for v in versions}


def main():
Expand All @@ -61,6 +65,12 @@ def main():
action='store_false',
default=True,
help='Don\'t "git commit" changes made by this script.')
parser.add_argument(
'--with-future-python',
dest='with_future_python',
action='store_true',
default=False,
help='Also enable testing the future Python version.')
parser.add_argument(
'--interactive',
dest='interactive',
Expand Down Expand Up @@ -91,12 +101,12 @@ def main():

current_python_versions = get_tox_ini_python_versions('tox.ini')
no_longer_supported = (
set(current_python_versions) -
current_python_versions -
set(supported_python_versions(oldest_python_version))
)
not_yet_supported = (
set(supported_python_versions(oldest_python_version)) -
set(current_python_versions)
current_python_versions
)

non_interactive_params = []
Expand Down Expand Up @@ -130,6 +140,11 @@ def main():
'--add=' +
','.join(supported_python_versions(oldest_python_version))
)
if args.with_future_python:
call(
bin_dir / 'addchangelogentry',
f'Add preliminary support for Python {FUTURE_PYTHON_VERSION}.',
*non_interactive_params)

if no_longer_supported or not_yet_supported:
call(bin_dir / 'check-python-versions', '--only=setup.py',
Expand All @@ -143,6 +158,8 @@ def main():
f'--branch={branch_name}',
'--no-push',
]
if args.with_future_python:
config_package_args.append('--with-future-python')
if not args.commit:
config_package_args.append('--no-commit')
call(*config_package_args, cwd=cwd_str)
Expand Down