From 1cba640e157cd7316d4541e3435639c3e36cf8da Mon Sep 17 00:00:00 2001 From: Jens Vagelpohl Date: Tue, 27 Aug 2024 16:11:12 +0200 Subject: [PATCH] - apply latest meta/config templates and drop Python 3.7 --- .github/workflows/pre-commit.yml | 33 +++++++++ .github/workflows/tests.yml | 116 +++++-------------------------- .manylinux-install.sh | 2 - .meta.toml | 3 +- .pre-commit-config.yaml | 28 ++++++++ CHANGES.rst | 4 +- MANIFEST.in | 1 + setup.py | 5 +- src/ExtensionClass/tests.py | 2 +- tox.ini | 20 ++---- 10 files changed, 90 insertions(+), 124 deletions(-) create mode 100644 .github/workflows/pre-commit.yml create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 0000000..325ae0e --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,33 @@ +# Generated from: +# https://github.com/zopefoundation/meta/tree/master/config/c-code +name: pre-commit + +on: + pull_request: + push: + branches: + - master + # Allow to run this workflow manually from the Actions tab + workflow_dispatch: + +env: + FORCE_COLOR: 1 + +jobs: + pre-commit: + name: linting + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.x + - uses: pre-commit/action@v3.0.1 + with: + extra_args: --all-files --show-diff-on-failure + env: + PRE_COMMIT_COLOR: always + - uses: pre-commit-ci/lite-action@v1.0.2 + if: always() + with: + msg: Apply pre-commit code formatting diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ac0804b..0d5a476 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,7 +9,7 @@ # Original comment follows. ### ### -# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# This workflow will install Python dependencies, run tests with a variety of Python versions # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions ### @@ -81,7 +81,7 @@ jobs: # other people to test/debug), the strategy is to divide the process # into several different jobs. The first builds and saves the binary # wheels. It has dependent jobs that download and install the wheel - # to run tests, build docs, and perform linting. Building the + # to run tests, and build docs. Building the # manylinux wheels is an independent set of jobs. # # This division is time-saving for projects that take awhile to @@ -97,7 +97,6 @@ jobs: matrix: python-version: - "pypy-3.10" - - "3.7" - "3.8" - "3.9" - "3.10" @@ -106,13 +105,8 @@ jobs: - "3.13" os: [ubuntu-latest, macos-latest, windows-latest] exclude: - - os: macos-latest - python-version: "3.7" - os: macos-latest python-version: "pypy-3.10" - include: - - python-version: "3.7" - os: macos-12 steps: - name: checkout @@ -169,11 +163,10 @@ jobs: pip install -U pip pip install -U "setuptools<69" wheel twine - - name: Build ExtensionClass (macOS x86_64, Python 3.8+) + - name: Build ExtensionClass (macOS x86_64) if: > startsWith(runner.os, 'Mac') - && !(startsWith(matrix.python-version, 'pypy') - || matrix.python-version == '3.7') + && !startsWith(matrix.python-version, 'pypy') env: MACOSX_DEPLOYMENT_TARGET: 10.9 _PYTHON_HOST_PLATFORM: macosx-10.9-x86_64 @@ -183,11 +176,10 @@ jobs: # output (pip install uses a random temporary directory, making this difficult). python setup.py build_ext -i python setup.py bdist_wheel - - name: Build ExtensionClass (macOS arm64, Python 3.8+) + - name: Build ExtensionClass (macOS arm64) if: > startsWith(runner.os, 'Mac') - && !(startsWith(matrix.python-version, 'pypy') - || matrix.python-version == '3.7') + && !startsWith(matrix.python-version, 'pypy') env: MACOSX_DEPLOYMENT_TARGET: 11.0 _PYTHON_HOST_PLATFORM: macosx-11.0-arm64 @@ -201,7 +193,6 @@ jobs: if: > !startsWith(runner.os, 'Mac') || startsWith(matrix.python-version, 'pypy') - || matrix.python-version == '3.7' run: | # Next, build the wheel *in place*. This helps ccache, and also lets us cache the configure # output (pip install uses a random temporary directory, making this difficult). @@ -230,19 +221,18 @@ jobs: startsWith(runner.os, 'Mac') uses: actions/upload-artifact@v4 with: - name: ExtensionClass-${{ runner.os }}-${{ matrix.python-version }}.whl + # The x86_64 wheel is uploaded with a different name just so it can be + # manually downloaded when desired. The wheel itself *cannot* be tested + # on the GHA runner, which uses arm64 architecture. + name: ExtensionClass-${{ runner.os }}-${{ matrix.python-version }}-x86_64.whl path: dist/*x86_64.whl - name: Upload ExtensionClass wheel (macOS arm64) if: > startsWith(runner.os, 'Mac') - && !(startsWith(matrix.python-version, 'pypy') - || matrix.python-version == '3.7') + && !startsWith(matrix.python-version, 'pypy') uses: actions/upload-artifact@v4 with: - # The arm64 wheel is uploaded with a different name just so it can be - # manually downloaded when desired. The wheel itself *cannot* be tested - # on the GHA runner, which uses x86_64 architecture. - name: ExtensionClass-${{ runner.os }}-${{ matrix.python-version }}-arm64.whl + name: ExtensionClass-${{ runner.os }}-${{ matrix.python-version }}.whl path: dist/*arm64.whl - name: Upload ExtensionClass wheel (all other platforms) if: > @@ -274,7 +264,6 @@ jobs: matrix: python-version: - "pypy-3.10" - - "3.7" - "3.8" - "3.9" - "3.10" @@ -283,13 +272,8 @@ jobs: - "3.13" os: [ubuntu-latest, macos-latest, windows-latest] exclude: - - os: macos-latest - python-version: "3.7" - os: macos-latest python-version: "pypy-3.10" - include: - - python-version: "3.7" - os: macos-12 steps: - name: checkout @@ -340,7 +324,7 @@ jobs: with: name: ExtensionClass-${{ runner.os }}-${{ matrix.python-version }}.whl path: dist/ - - name: Install ExtensionClass 3.13 ${{ matrix.python-version }} + - name: Install ExtensionClass ${{ matrix.python-version }} if: matrix.python-version == '3.13' run: | pip install -U wheel "setuptools<69" @@ -395,83 +379,13 @@ jobs: with: parallel-finished: true - lint: - needs: build-package - runs-on: ${{ matrix.os }} - strategy: - matrix: - python-version: ["3.9"] - os: [ubuntu-latest] - - steps: - - name: checkout - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - allow-prereleases: true - ### - # Caching. - # This actually *restores* a cache and schedules a cleanup action - # to save the cache. So it must come before the thing we want to use - # the cache. - ### - - name: Get pip cache dir (default) - id: pip-cache-default - if: ${{ !startsWith(runner.os, 'Windows') }} - run: | - echo "dir=$(pip cache dir)" >>$GITHUB_OUTPUT - - - name: Get pip cache dir (Windows) - id: pip-cache-windows - if: ${{ startsWith(runner.os, 'Windows') }} - run: | - echo "dir=$(pip cache dir)" >> $Env:GITHUB_OUTPUT - - - name: pip cache (default) - uses: actions/cache@v4 - if: ${{ !startsWith(runner.os, 'Windows') }} - with: - path: ${{ steps.pip-cache-default.outputs.dir }} - key: ${{ runner.os }}-pip-${{ matrix.python-version }} - restore-keys: | - ${{ runner.os }}-pip- - - - name: pip cache (Windows) - uses: actions/cache@v4 - if: ${{ startsWith(runner.os, 'Windows') }} - with: - path: ${{ steps.pip-cache-windows.outputs.dir }} - key: ${{ runner.os }}-pip-${{ matrix.python-version }} - restore-keys: | - ${{ runner.os }}-pip- - - - name: Download ExtensionClass wheel - uses: actions/download-artifact@v4 - with: - name: ExtensionClass-${{ runner.os }}-${{ matrix.python-version }}.whl - path: dist/ - - name: Install ExtensionClass - run: | - pip install -U pip - pip install -U wheel - pip install -U `ls dist/ExtensionClass-*`[test] - - name: Lint - # We only need to do this on one version, and it should be Python 3, because - # pylint has stopped updating for Python 2. - # TODO: Pick a linter and configuration and make this step right. - run: | - pip install -U pylint - # python -m pylint --limit-inference-results=1 --rcfile=.pylintrc ExtensionClass -f parseable -r n - manylinux: runs-on: ubuntu-latest if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name # We use a regular Python matrix entry to share as much code as possible. strategy: matrix: - python-version: ["3.9"] + python-version: ["3.11"] image: [manylinux2014_x86_64, manylinux2014_i686, manylinux2014_aarch64] steps: @@ -552,6 +466,8 @@ jobs: name: manylinux_${{ matrix.image }}_wheels.zip - name: Restore pip cache permissions run: sudo chown -R $(whoami) ${{ steps.pip-cache-default.outputs.dir }} + - name: Prevent publishing wheels for unreleased Python versions + run: VER=$(echo '3.13' | tr -d .) && ls -al wheelhouse && sudo rm -f wheelhouse/*-cp${VER}*.whl && ls -al wheelhouse - name: Publish package to PyPI uses: pypa/gh-action-pypi-publish@release/v1 if: > diff --git a/.manylinux-install.sh b/.manylinux-install.sh index e4a4b86..8866512 100755 --- a/.manylinux-install.sh +++ b/.manylinux-install.sh @@ -29,7 +29,6 @@ yum -y install libffi-devel tox_env_map() { case $1 in *"cp313"*) echo 'py313';; - *"cp37"*) echo 'py37';; *"cp38"*) echo 'py38';; *"cp39"*) echo 'py39';; *"cp310"*) echo 'py310';; @@ -45,7 +44,6 @@ for PYBIN in /opt/python/*/bin; do [[ "${PYBIN}" == *"cp313/"* ]] || \ [[ "${PYBIN}" == *"cp311/"* ]] || \ [[ "${PYBIN}" == *"cp312/"* ]] || \ - [[ "${PYBIN}" == *"cp37/"* ]] || \ [[ "${PYBIN}" == *"cp38/"* ]] || \ [[ "${PYBIN}" == *"cp39/"* ]] || \ [[ "${PYBIN}" == *"cp310/"* ]] ; then diff --git a/.meta.toml b/.meta.toml index 10d8e4d..b61f9e2 100644 --- a/.meta.toml +++ b/.meta.toml @@ -2,10 +2,9 @@ # https://github.com/zopefoundation/meta/tree/master/config/c-code [meta] template = "c-code" -commit-id = "4dc0484e" +commit-id = "4eec7859" [python] -with-appveyor = false with-windows = true with-pypy = true with-sphinx-doctests = false diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..b5d6386 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,28 @@ +# Generated from: +# https://github.com/zopefoundation/meta/tree/master/config/c-code +minimum_pre_commit_version: '3.6' +repos: + - repo: https://github.com/pycqa/isort + rev: "5.13.2" + hooks: + - id: isort + - repo: https://github.com/hhatto/autopep8 + rev: "v2.3.1" + hooks: + - id: autopep8 + args: [--in-place, --aggressive, --aggressive] + - repo: https://github.com/asottile/pyupgrade + rev: v3.17.0 + hooks: + - id: pyupgrade + args: [--py38-plus] + - repo: https://github.com/isidentical/teyit + rev: 0.4.3 + hooks: + - id: teyit + - repo: https://github.com/PyCQA/flake8 + rev: "7.1.1" + hooks: + - id: flake8 + additional_dependencies: + - flake8-debugger == 4.1.2 diff --git a/CHANGES.rst b/CHANGES.rst index 0b95990..87da087 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -2,13 +2,15 @@ Changelog =========== -5.2 (unreleased) +6.0 (unreleased) ================ - Build Windows wheels on GHA. - Add preliminary support for Python 3.13 as of 3.13b1. +- Drop support for Python 3.7. + 5.1 (2023-10-05) ================ diff --git a/MANIFEST.in b/MANIFEST.in index d450d3c..72b2cf0 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -5,6 +5,7 @@ include *.rst include *.txt include buildout.cfg include tox.ini +include .pre-commit-config.yaml include .coveragerc recursive-include src *.py diff --git a/setup.py b/setup.py index 638fcaa..29c2c3e 100644 --- a/setup.py +++ b/setup.py @@ -49,7 +49,7 @@ include_dirs=['src']), ] -version = '5.2.dev0' +version = '6.0.dev0' setup( name='ExtensionClass', @@ -70,7 +70,6 @@ "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", @@ -87,5 +86,5 @@ 'zope.testrunner', ], }, - python_requires='>=3.7', + python_requires='>=3.8', ) diff --git a/src/ExtensionClass/tests.py b/src/ExtensionClass/tests.py index cb2b684..ee61b2f 100644 --- a/src/ExtensionClass/tests.py +++ b/src/ExtensionClass/tests.py @@ -24,7 +24,7 @@ def print_dict(d): d = d.items() print('{%s}' % (', '.join( - [('{!r}: {!r}'.format(k, v)) for (k, v) in sorted(d)] + [(f'{k!r}: {v!r}') for (k, v) in sorted(d)] ))) diff --git a/tox.ini b/tox.ini index fb31ca7..cdc56d3 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,6 @@ minversion = 4.0 envlist = lint - py37,py37-pure py38,py38-pure py39,py39-pure py310,py310-pure @@ -15,10 +14,9 @@ envlist = coverage [testenv] -usedevelop = true pip_pre = py313: true deps = - setuptools < 69 + setuptools < 69 setenv = pure: PURE_PYTHON=1 !pure-!pypy3: PURE_PYTHON=0 @@ -42,6 +40,7 @@ commands = coverage run -m zope.testrunner --test-path=src {posargs:-vc} coverage html -i coverage report -i -m --fail-under=100 + [testenv:release-check] description = ensure that the distribution is ready to release basepython = python3 @@ -60,20 +59,11 @@ commands = twine check dist/* [testenv:lint] +description = This env runs all linters configured in .pre-commit-config.yaml basepython = python3 skip_install = true deps = - isort - flake8 -commands = - isort --check-only --diff {toxinidir}/src {toxinidir}/setup.py - flake8 src setup.py - -[testenv:isort-apply] -basepython = python3 -skip_install = true + pre-commit commands_pre = -deps = - isort commands = - isort {toxinidir}/src {toxinidir}/setup.py [] + pre-commit run --all-files --show-diff-on-failure