diff --git a/.github/FUNDING.yml b/.github/FUNDING.yaml similarity index 100% rename from .github/FUNDING.yml rename to .github/FUNDING.yaml diff --git a/.github/dependabot.yml b/.github/dependabot.yaml similarity index 100% rename from .github/dependabot.yml rename to .github/dependabot.yaml diff --git a/.github/workflows/readme_example.yaml b/.github/workflows/readme_example.yaml index a7d8c8e..911694e 100644 --- a/.github/workflows/readme_example.yaml +++ b/.github/workflows/readme_example.yaml @@ -1,6 +1,6 @@ # This file is a part of the detect-pythons project. # https://github.com/kurtmckee/detect-pythons -# Copyright 2023 Kurt McKee +# Copyright 2023-2025 Kurt McKee # SPDX-License-Identifier: MIT # This workflow exists for several purposes: @@ -46,13 +46,13 @@ jobs: - uses: "actions/setup-python@v5" with: python-version: | - graalpy-23.1 - pypy-3.10 - 3.12 + graalpy-24 + pypy-3.11 + 3.13 - uses: "kurtmckee/detect-pythons@v1" - - uses: "actions/cache@v3" + - uses: "actions/cache@v4" id: "restore-cache" with: # You may need to augment the list of files to hash. @@ -64,7 +64,8 @@ jobs: - name: "Identify .venv path" shell: "bash" - run: "echo 'venv-path=.venv/${{ runner.os == 'Windows' && 'Scripts' || 'bin' }}' >> $GITHUB_ENV" + run: | + echo 'venv-path=.venv/${{ runner.os == 'Windows' && 'Scripts' || 'bin' }}' >> "$GITHUB_ENV" - name: "Create a virtual environment" if: "steps.restore-cache.outputs.cache-hit == false" @@ -95,7 +96,7 @@ jobs: - uses: "kurtmckee/detect-pythons@v1" - - uses: "actions/cache@v3" + - uses: "actions/cache@v4" id: "restore-cache" with: # You may need to augment the list of files to hash. @@ -107,7 +108,8 @@ jobs: - name: "Identify .venv path" shell: "bash" - run: "echo 'venv-path=.venv/${{ runner.os == 'Windows' && 'Scripts' || 'bin' }}' >> $GITHUB_ENV" + run: | + echo 'venv-path=.venv/${{ runner.os == 'Windows' && 'Scripts' || 'bin' }}' >> "$GITHUB_ENV" - name: "Create a virtual environment" if: "steps.restore-cache.outputs.cache-hit == false" diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 37f6ad4..8a59960 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,4 +1,4 @@ -name: "🔬 Test" +name: "🧪 Test" on: pull_request: null @@ -8,70 +8,52 @@ on: - "releases" jobs: - tox: - name: "Tox (${{ matrix.os.name }})" + code: + name: + "Code (${{ + (startswith(matrix.runner, 'ubuntu') && 'Linux') + || (startswith(matrix.runner, 'macos') && 'macOS') + || (startswith(matrix.runner, 'windows') && 'Windows') + }})" strategy: - matrix: - os: - - name: "Linux" - runner: "ubuntu-latest" - - name: "macOS" - runner: "macos-latest" - - name: "Windows" - runner: "windows-latest" fail-fast: false + matrix: + runner: + - "ubuntu-latest" + - "macos-latest" + - "windows-latest" + + # Each operating system should test all Python interpreters simultaneously. + # + # Note: The CPython interpreter versions should be in ascending order + # because the last-listed version will be the default CPython version. + # + include: + - cpythons: + - "3.8" + - "3.9" + - "3.10" + - "3.11" + - "3.12" + - "3.13" + cpython-beta: "3.14" + pypys: + - "3.8" + - "3.9" + - "3.10" + - "3.11" + + uses: "kurtmckee/github-workflows/.github/workflows/tox.yaml@ca26472ada33aa277527450aa46436f530e3d2c1" # v1.4 + with: + config: "${{ toJSON(matrix) }}" - runs-on: "${{ matrix.os.runner }}" - steps: - - name: "Checkout the repository" - uses: "actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11" # v4.1.1 - - - name: "Setup Pythons" - uses: "actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c" # v5.0.0 - with: - python-version: | - pypy3.8 - pypy3.9 - pypy3.10 - 3.8 - 3.9 - 3.10 - 3.11 - 3.12 - allow-prereleases: true - cache: "pip" - - - name: "Detect Pythons" - uses: "./" - - - name: "Restore cache" - id: "restore-cache" - uses: "actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84" # v3.3.2 - with: - path: | - .tox/ - .venv - key: "tox-os=${{ matrix.os.runner }}-hash=${{ hashFiles('.python-identifiers', 'tox.ini') }}" - - - name: "Identify .venv path" - shell: "bash" - run: "echo 'venv-path=.venv/${{ runner.os == 'Windows' && 'Scripts' || 'bin' }}' >> $GITHUB_ENV" - - - name: "Create a virtual environment" - if: "steps.restore-cache.outputs.cache-hit == false" - run: | - python -m venv .venv - ${{ env.venv-path }}/python -m pip install --upgrade pip setuptools wheel - ${{ env.venv-path }}/pip install tox - - - name: "Run the test suite" - run: "${{ env.venv-path }}/tox" inputs: name: "Inputs (${{ matrix.os.name }})" strategy: + fail-fast: false matrix: os: - name: "Linux" @@ -80,12 +62,11 @@ jobs: runner: "macos-latest" - name: "Windows" runner: "windows-latest" - fail-fast: false runs-on: "${{ matrix.os.runner }}" steps: - name: "Checkout the repository" - uses: "actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11" # v4.1.1 + uses: "actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683" # v4.2.2 - name: "Test: Disable output file" uses: "./" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4c18700..3b1146d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,9 @@ ci: autoupdate_schedule: "monthly" +default_language_version: + python: "python3.13" + repos: - repo: "meta" hooks: @@ -8,7 +11,7 @@ repos: - id: "check-useless-excludes" - repo: "https://github.com/pre-commit/pre-commit-hooks" - rev: "v4.5.0" + rev: "v5.0.0" hooks: - id: "check-yaml" - id: "check-added-large-files" @@ -23,34 +26,39 @@ repos: hooks: - id: "update-headers" + - repo: "https://github.com/sirosen/slyp" + rev: 0.8.2 + hooks: + - id: "slyp" + - repo: "https://github.com/psf/black-pre-commit-mirror" - rev: "23.12.0" + rev: "25.1.0" hooks: - id: "black" - repo: "https://github.com/pycqa/isort" - rev: "5.13.2" + rev: "6.0.1" hooks: - id: "isort" - repo: "https://github.com/pycqa/flake8" - rev: "6.1.0" + rev: "7.1.2" hooks: - id: "flake8" additional_dependencies: - - "flake8-bugbear==23.12.2" + - "flake8-bugbear==24.12.12" - - repo: "https://github.com/editorconfig-checker/editorconfig-checker.python" - rev: "2.7.3" + - repo: "https://github.com/editorconfig-checker/editorconfig-checker" + rev: "v3.2.0" hooks: - id: "editorconfig-checker" - # The README contain YAML samples indented with 2 spaces. + # The README contains YAML samples indented with 2 spaces. # The .editorconfig file requires 4 spaces for indentation, # so this pre-commit hook will ignore the README. exclude: "README.rst" - repo: "https://github.com/shellcheck-py/shellcheck-py" - rev: "v0.9.0.6" + rev: "v0.10.0.1" hooks: - id: "shellcheck" args: @@ -66,7 +74,12 @@ repos: pass_filenames: false - repo: "https://github.com/python-jsonschema/check-jsonschema" - rev: "0.27.3" + rev: "0.31.2" hooks: - id: "check-github-workflows" - id: "check-dependabot" + + - repo: "https://github.com/rhysd/actionlint" + rev: "v1.7.7" + hooks: + - id: "actionlint" diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 76ef915..008691d 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,7 +1,7 @@ .. This file is a part of the detect-pythons project. https://github.com/kurtmckee/detect-pythons - Copyright 2023 Kurt McKee + Copyright 2023-2025 Kurt McKee SPDX-License-Identifier: MIT .. @@ -24,6 +24,23 @@ Please see the fragment files in the `changelog.d directory`_. .. scriv-insert-here +.. _changelog-1.1.1: + +1.1.1 - 2025-03-06 +================== + +Python support +-------------- + +* Support CPython 3.13 and PyPy 3.11. +* Test against early versions of Python 3.14. + +Development +----------- + +* Migrate to PEP 621 project metadata. +* Migrate to a reusable CI workflow. + .. _changelog-1.1.0: 1.1.0 - 2023-12-16 diff --git a/LICENSE.txt b/LICENSE.txt index a8c5822..f681486 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ MIT License -Copyright 2023 Kurt McKee +Copyright 2023-2025 Kurt McKee Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.rst b/README.rst index 6df9ea5..6d2efe9 100644 --- a/README.rst +++ b/README.rst @@ -1,7 +1,7 @@ .. This file is a part of the detect-pythons project. https://github.com/kurtmckee/detect-pythons - Copyright 2023 Kurt McKee + Copyright 2023-2025 Kurt McKee SPDX-License-Identifier: MIT Detect Python interpreters @@ -52,13 +52,13 @@ and tox test environments stored in ``.tox/``. - uses: "actions/setup-python@v5" with: python-version: | - graalpy-23.1 - pypy-3.10 - 3.12 + graalpy-24 + pypy-3.11 + 3.13 - uses: "kurtmckee/detect-pythons@v1" - - uses: "actions/cache@v3" + - uses: "actions/cache@v4" id: "restore-cache" with: # You may need to augment the list of files to hash. @@ -70,7 +70,8 @@ and tox test environments stored in ``.tox/``. - name: "Identify .venv path" shell: "bash" - run: "echo 'venv-path=.venv/${{ runner.os == 'Windows' && 'Scripts' || 'bin' }}' >> $GITHUB_ENV" + run: | + echo 'venv-path=.venv/${{ runner.os == 'Windows' && 'Scripts' || 'bin' }}' >> "$GITHUB_ENV" - name: "Create a virtual environment" if: "steps.restore-cache.outputs.cache-hit == false" @@ -153,8 +154,8 @@ System CPython interpreters --------------------------- GitHub's Linux and macOS runners have system CPython interpreters installed. -These are available at paths like ``/usr/bin/python``, -which contains no useful information. +These are available at paths which contain no useful information, +like ``/usr/bin/python``. For these interpreters, the interpreter is executed and the value of ``sysconfig.get_config_var("EXT_SUFFIX")`` is extracted. @@ -166,31 +167,11 @@ This results in a value like the following: "Linux", "``.cpython-310-x86_64-linux-gnu.so``" "macOS", "``.cpython-311-darwin.so``" - -macOS runner variability ------------------------- - -At the time of writing, GitHub's macOS runners sometimes have CPython 2.7 pre-installed. -CPython 2.7 doesn't have an ``EXT_SUFFIX`` config value, -so ``detect-pythons`` constructs one. +Extremely old Python versions might not have an ``EXT_SUFFIX`` value. +For example, CPython 2.7 doesn't have this value. +If this is detected then an equivalent value is constructed. .. csv-table:: :header: "Platform", "Constructed ``EXT_SUFFIX`` equivalent" - "macOS 12.6", "``.cpython-27-darwin-x86_64``" - -Note that CPython 2.7 is only installed *sometimes*; sometimes it isn't. -This is because ``macos-latest`` is sometimes macOS 12.6, and sometimes it's macOS 12.7. -See `actions/runner-images#8642`_ for more information. - -When using ``detect-pythons`` to help with cache-busting, -this variability means that you may see two caches appear in regular use -for your macOS-based workflows; -one that is valid when CPython 2.7 is pre-installed, -and another that is valid when it *isn't* installed. - - -.. Links -.. ----- -.. -.. _actions/runner-images#8642: https://github.com/actions/runner-images/issues/8642 + "macOS", "``.cpython-27-darwin-x86_64``" diff --git a/action.yml b/action.yml index 21df35a..d9c4fd5 100644 --- a/action.yml +++ b/action.yml @@ -1,6 +1,6 @@ # This file is a part of the detect-pythons project. # https://github.com/kurtmckee/detect-pythons -# Copyright 2023 Kurt McKee +# Copyright 2023-2025 Kurt McKee # SPDX-License-Identifier: MIT author: "Kurt McKee" diff --git a/pyproject.toml b/pyproject.toml index 55c90e8..17ccaf0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,20 +1,35 @@ -[tool.poetry] +[project] name = "detect_pythons" -version = "1.1.0" +version = "1.1.1" description = "A GitHub action to detect installed Pythons. Suitable for cache-busting." -authors = ["Kurt McKee "] +authors = [{ name = "Kurt McKee", email = "contactme@kurtmckee.org" }] license = "MIT" readme = "README.rst" +requires-python = ">=3.8" +classifiers = ["Private :: Do not Upload"] +[build-system] +requires = ["poetry-core>=2.0.0,<3.0.0"] +build-backend = "poetry.core.masonry.api" -[tool.poetry.dependencies] -python = ">=3.8" +# chipshot +# -------- + +[tool.chipshot] +template = """ +This file is a part of the detect-pythons project. +https://github.com/kurtmckee/detect-pythons +Copyright 2023-{{ year }} Kurt McKee +SPDX-License-Identifier: MIT +""" +exclusions = [ + "changelog.d/", +] -[build-system] -requires = ["poetry-core"] -build-backend = "poetry.core.masonry.api" +# coverage +# -------- [tool.coverage.run] parallel = true @@ -24,28 +39,31 @@ source = [ "tests", ] - [tool.coverage.paths] source = [ "src", "*/site-packages", ] - [tool.coverage.report] skip_covered = true fail_under = 100 - [tool.coverage.html] skip_covered = false directory = "htmlcov/" +# isort +# ----- + [tool.isort] profile = "black" +# pytest +# ------ + [tool.pytest.ini_options] addopts = "--color=yes" filterwarnings = [ @@ -53,8 +71,11 @@ filterwarnings = [ ] +# scriv +# ----- + [tool.scriv] -version = "literal: pyproject.toml: tool.poetry.version" +version = "literal: pyproject.toml: project.version" categories = [ "Python support", "Added", @@ -70,15 +91,3 @@ fragment_directory = "changelog.d" insert_marker = "scriv-insert-here" main_branches = ["main", "releases"] new_fragment_template = "file: fragment-template.rst.txt" - - -[tool.chipshot] -template = """ -This file is a part of the detect-pythons project. -https://github.com/kurtmckee/detect-pythons -Copyright 2023 Kurt McKee -SPDX-License-Identifier: MIT -""" -exclusions = [ - "changelog.d/", -] diff --git a/src/detect_pythons/detector.ps1 b/src/detect_pythons/detector.ps1 index 0f679f1..7f4f0e7 100644 --- a/src/detect_pythons/detector.ps1 +++ b/src/detect_pythons/detector.ps1 @@ -1,6 +1,6 @@ # This file is a part of the detect-pythons project. # https://github.com/kurtmckee/detect-pythons -# Copyright 2023 Kurt McKee +# Copyright 2023-2025 Kurt McKee # SPDX-License-Identifier: MIT # Search paths in $PATH for Python interpreters. diff --git a/src/detect_pythons/detector.sh b/src/detect_pythons/detector.sh index be8f537..9a0f426 100644 --- a/src/detect_pythons/detector.sh +++ b/src/detect_pythons/detector.sh @@ -1,6 +1,6 @@ # This file is a part of the detect-pythons project. # https://github.com/kurtmckee/detect-pythons -# Copyright 2023 Kurt McKee +# Copyright 2023-2025 Kurt McKee # SPDX-License-Identifier: MIT IDENTIFY_PY="${GITHUB_ACTION_PATH}/src/detect_pythons/identify.py" diff --git a/src/detect_pythons/identify.py b/src/detect_pythons/identify.py index 0e73d1c..57497c2 100644 --- a/src/detect_pythons/identify.py +++ b/src/detect_pythons/identify.py @@ -1,6 +1,6 @@ # This file is a part of the detect-pythons project. # https://github.com/kurtmckee/detect-pythons -# Copyright 2023 Kurt McKee +# Copyright 2023-2025 Kurt McKee # SPDX-License-Identifier: MIT from __future__ import print_function diff --git a/src/detect_pythons/sync_readme_example.py b/src/detect_pythons/sync_readme_example.py index 71fe0a8..cb52d3a 100644 --- a/src/detect_pythons/sync_readme_example.py +++ b/src/detect_pythons/sync_readme_example.py @@ -1,6 +1,6 @@ # This file is a part of the detect-pythons project. # https://github.com/kurtmckee/detect-pythons -# Copyright 2023 Kurt McKee +# Copyright 2023-2025 Kurt McKee # SPDX-License-Identifier: MIT import pathlib diff --git a/tests/test_identify.py b/tests/test_identify.py index a06b6a3..6a33abb 100644 --- a/tests/test_identify.py +++ b/tests/test_identify.py @@ -1,6 +1,6 @@ # This file is a part of the detect-pythons project. # https://github.com/kurtmckee/detect-pythons -# Copyright 2023 Kurt McKee +# Copyright 2023-2025 Kurt McKee # SPDX-License-Identifier: MIT import platform diff --git a/tests/test_sync_readme_example.py b/tests/test_sync_readme_example.py index 8312871..9e888fc 100644 --- a/tests/test_sync_readme_example.py +++ b/tests/test_sync_readme_example.py @@ -1,6 +1,6 @@ # This file is a part of the detect-pythons project. # https://github.com/kurtmckee/detect-pythons -# Copyright 2023 Kurt McKee +# Copyright 2023-2025 Kurt McKee # SPDX-License-Identifier: MIT import unittest.mock diff --git a/tox.ini b/tox.ini index 06b842d..e485d17 100644 --- a/tox.ini +++ b/tox.ini @@ -1,13 +1,12 @@ [tox] min_version = 4.3.5 - envlist = coverage_erase - py{313, 312, 311, 310, 39, 38, py310, py39, py38} + py{3.14, 3.13, 3.12, 3.11, 3.10, 3.9, 3.8} + pypy{3.11, 3.10, 3.9, 3.8} coverage_report - -skip_missing_interpreters = True -isolated_build = True +labels = + update=update [testenv] @@ -15,7 +14,7 @@ package = wheel wheel_build_env = build_wheel depends = - py{313, 312, 311, 310, 39, 38, py310, py39, py38}: coverage_erase + py{3.14, 3.13, 3.12, 3.11, 3.10, 3.9, 3.8}, pypy{3.11, 3.10, 3.9, 3.8}: coverage_erase deps = coverage[toml] pytest @@ -25,7 +24,6 @@ commands = [testenv:coverage_erase] -skipsdist = true skip_install = true deps = coverage[toml] commands = coverage erase @@ -33,8 +31,7 @@ commands = coverage erase [testenv:coverage_report] depends = - py{313, 312, 311, 310, 39, 38, py310, py39, py38} -skipsdist = true + py{3.14, 3.13, 3.12, 3.11, 3.10, 3.9, 3.8}, pypy{3.11, 3.10, 3.9, 3.8} skip_install = true deps = coverage[toml] commands_pre = @@ -44,17 +41,20 @@ commands = coverage report [testenv:update] +description = Update tool versions +base_python = py3.13 +recreate = true +skip_install = true deps = pre-commit upadup -skip_install = true commands = # Update pre-commit hooks and additional dependencies. pre-commit autoupdate upadup - # Run pre-commit. - pre-commit run --all-files + # Run pre-commit immediately, but ignore its exit code. + - pre-commit run -a [flake8]