From 5e3bc5437326e8bb8d16c1099f51780bc24f259b Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Thu, 3 Apr 2025 16:55:40 +0000 Subject: [PATCH] Update Python versions and boilerplate Drop support for Python 3.8, add 3.12, switch from tox to nox, openstack's release jobs to opendev's, and use updated pyproject packaging standards. Depends-On: https://review.opendev.org/946280 Change-Id: I462014b08ec3ecb74674365a2fd1f532f61dfa0c --- .flake8 | 6 +++++ .gitignore | 1 + .stestr.conf | 3 +++ .zuul.yaml | 24 +++++++++++++++++-- README.rst | 2 +- noxfile.py | 39 ++++++++++++++++++++++++++++++ pyproject.toml | 56 +++++++++++++++++++++++++++++++++++++++++++ requirements.txt | 5 ---- setup.cfg | 29 +--------------------- setup.py | 20 +++++++++++++--- test-requirements.txt | 8 ------- tox.ini | 24 ------------------- 12 files changed, 146 insertions(+), 71 deletions(-) create mode 100644 .flake8 create mode 100644 .stestr.conf create mode 100644 noxfile.py create mode 100644 pyproject.toml delete mode 100644 requirements.txt delete mode 100644 test-requirements.txt delete mode 100644 tox.ini diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..614267f --- /dev/null +++ b/.flake8 @@ -0,0 +1,6 @@ +[flake8] +exclude=.venv,.git,.nox,.tox,dist,doc,*lib/python*,*egg,build +# E123, E125 and W503 are invalid per PEP-8; OpenStack's H rules don't apply +# TODO: drop W504 once the scripts are adjusted to suit it +ignore = E123,E125,H,W503,W504 +show-source = True diff --git a/.gitignore b/.gitignore index 72f3108..a33ab5c 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ pip-log.txt .tox nosetests.xml .testrepository +.stestr # Translations *.mo diff --git a/.stestr.conf b/.stestr.conf new file mode 100644 index 0000000..224afe9 --- /dev/null +++ b/.stestr.conf @@ -0,0 +1,3 @@ +[DEFAULT] +test_path=yaml2ical/tests +top_dir=./ diff --git a/.zuul.yaml b/.zuul.yaml index 6de3b87..0a41b3a 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -1,3 +1,23 @@ - project: - templates: - - openstack-python3-jobs + check: + jobs: + - build-python-release + - nox-linters + - nox-py39: + nodeset: ubuntu-focal + - nox-py312: + nodeset: ubuntu-noble + gate: + jobs: + - build-python-release + - nox-linters + - nox-py39: + nodeset: ubuntu-focal + - nox-py312: + nodeset: ubuntu-noble + promote: + jobs: + - opendev-promote-python + release: + jobs: + - opendev-release-python diff --git a/README.rst b/README.rst index 29796c4..315c284 100644 --- a/README.rst +++ b/README.rst @@ -24,7 +24,7 @@ Running Locally from Command Line To test this project locally, you must have the following requirements installed: -* Python 3.3+ +* Python * `iCalendar` python library * `PyYaml` python library diff --git a/noxfile.py b/noxfile.py new file mode 100644 index 0000000..76a06db --- /dev/null +++ b/noxfile.py @@ -0,0 +1,39 @@ +import nox + + +nox.options.error_on_external_run = True +nox.options.reuse_existing_virtualenvs = True +nox.options.sessions = ["tests-3", "linters"] + + +# Convenience wrapper for running the project +@nox.session(python="3") +def mkical(session): + session.install(".") + session.run("yaml2ical", "-y", "meetings/", "-i", "icals/", "-f") + + +# Note setting python this way seems to give us a target name without +# python specific suffixes while still allowing us to force a specific +# version using --force-python. +@nox.session(python="3") +def linters(session): + # TODO: switch this line to 'session.install("--group", "test-linters")' + session.install(".[test-linters]") + session.run("flake8") + + +@nox.session(python="3") +def venv(session): + # TODO: switch to 'session.install("-e", ".", "--group", "test-unit")' + session.install("-e", ".[test-unit]") + session.run(*session.posargs) + + +# This will attempt to run python3 tests by default. +@nox.session(python=["3"]) +def tests(session): + # TODO: switch to 'session.install("-e", ".", "--group", "test-unit")' + session.install("-e", ".[test-unit]") + session.run("stestr", "run", *session.posargs) + session.run("stestr", "slowest") diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..4ed8f92 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,56 @@ + +[build-system] +requires = ["pbr>=6.1.1"] +build-backend = "pbr.build" + +[project] +authors = [ + {name = "OpenDev Contributors", email = "service-discuss@lists.opendev.org"}, + {name = "NDSU IBM Capstone", email = "service-discuss@lists.opendev.org"}, +] +classifiers = [ + "Intended Audience :: Information Technology", + "Intended Audience :: System Administrators", + "Operating System :: POSIX :: Linux", + "Programming Language :: Python", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", +] +dependencies = [ + "Jinja2>=2.8", # BSD License (3 clause) + "PyYAML>=3.1.0", # MIT + "icalendar", + "pbr>=1.6", # Apache-2.0 + "pytz", +] +description = "Convert YAML meeting descriptions into iCalendar files" +dynamic = ["version"] +license = "Apache-2.0" +name = "yaml2ical" +readme = {charset = "UTF-8", content-type = "text/x-rst", file = "README.rst"} +requires-python = ">=3.9" + +# TODO: replace this with '[dependency-groups]' once pip 25.1 is released +[project.optional-dependencies] +test-linters = [ + "hacking>=7,<8", # Apache-2.0 +] +test-unit = [ + "coverage>=3.6", # Apache-2.0 + "fixtures>=3.0.0", # Apache-2.0/BSD + "python-subunit>=0.0.18", # Apache-2.0/BSD + "stestr>=1.0.0", + "testtools>=1.4.0", # MIT +] + +[project.scripts] + yaml2ical = "yaml2ical.cli:main" + +[project.urls] +"Browse Source" = "https://opendev.org/opendev/yaml2ical" +"Bug Reporting" = "https://storyboard.openstack.org/#!/project/opendev/yaml2ical" +"Documentation" = "https://opendev.org/opendev/yaml2ical/src/branch/master/README.rst" +"Git Clone URL" = "https://opendev.org/opendev/yaml2ical" +"License Texts" = "https://opendev.org/opendev/yaml2ical/src/branch/master/LICENSE" diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index b5a25d9..0000000 --- a/requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -pbr>=1.6 # Apache-2.0 -icalendar -Jinja2>=2.8 # BSD License (3 clause) -PyYAML>=3.1.0 # MIT -pytz diff --git a/setup.cfg b/setup.cfg index ea42870..7ba3b22 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,30 +1,3 @@ +# TODO: Delete this file once PBR can read project names from pyproject.toml [metadata] name = yaml2ical -summary = Convert YAML meeting descriptions into iCalendar files -description_file = - README.rst -author = NDSU IBM Capstone Group & OpenStack Infrastructure Team -author_email = openstack-infra@lists.openstack.org -home_page = http://docs.openstack.org/infra/system-config/ -python_requires = >=3.8 -classifier = - Intended Audience :: Information Technology - Intended Audience :: System Administrators - License :: OSI Approved :: Apache Software License - Operating System :: POSIX :: Linux - Programming Language :: Python - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3.11 - -[global] -setup-hooks = - pbr.hooks.setup_hook - -[files] -packages = yaml2ical - -[entry_points] -console_scripts = - yaml2ical = yaml2ical.cli:main diff --git a/setup.py b/setup.py index b96e399..11f2269 100755 --- a/setup.py +++ b/setup.py @@ -1,7 +1,21 @@ #!/usr/bin/env python +# Copyright OpenDev Contributors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# TODO: Delete this file once PBR gains the ability to act as a build hook import setuptools -setuptools.setup( - setup_requires=['pbr'], - pbr=True) +setuptools.setup(pbr=True) diff --git a/test-requirements.txt b/test-requirements.txt deleted file mode 100644 index 072380f..0000000 --- a/test-requirements.txt +++ /dev/null @@ -1,8 +0,0 @@ -hacking>=3.2.0 # Apache-2.0 - -coverage>=3.6 # Apache-2.0 -fixtures>=3.0.0 # Apache-2.0/BSD -python-subunit>=0.0.18 # Apache-2.0/BSD -testrepository>=0.0.18 # Apache-2.0/BSD -testscenarios>=0.4 # Apache-2.0/BSD -testtools>=1.4.0 # MIT diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 0e4789d..0000000 --- a/tox.ini +++ /dev/null @@ -1,24 +0,0 @@ -[tox] -minversion = 1.6 -envlist = py3,pep8 -ignore_basepython_conflict = True - -[testenv] -basepython = python3 -deps = -r{toxinidir}/requirements.txt - -r{toxinidir}/test-requirements.txt -commands = python setup.py testr --slowest --testr-args='{posargs}' -usedevelop = true - -[testenv:pep8] -commands = flake8 - -[testenv:venv] -commands = {posargs} - -[testenv:mkical] -commands = yaml2ical -y meetings/ -i icals/ -f - -[flake8] -show-source = True -exclude = .venv,.tox,dist,doc,*.egg