Skip to content

Commit

Permalink
chore: Support Python 3.12
Browse files Browse the repository at this point in the history
Fixes #732
  • Loading branch information
probberechts committed Jun 22, 2024
1 parent 430c9c5 commit 8e79a0a
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 58 deletions.
45 changes: 6 additions & 39 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
name: CI

on:
- push
- pull_request

jobs:
setup:
runs-on: ${{ matrix.os }}
Expand All @@ -17,56 +15,46 @@ jobs:
with:
path: tests/datasets/statsbomb
key: cache-statsbomb-data

- name: Cache public Wyscout test data
id: cache-public-wyscout
uses: actions/cache@v4
with:
path: tests/datasets/wyscout_public
key: cache-public-wyscout-data

- name: Check out the repository
if: steps.cache-statsbomb.outputs.cache-hit != 'true' || steps.cache-public-wyscout.outputs.cache-hit != 'true'
uses: actions/checkout@v4

- name: Set up Python
if: steps.cache-statsbomb.outputs.cache-hit != 'true' || steps.cache-public-wyscout.outputs.cache-hit != 'true'
uses: actions/setup-python@v5
with:
python-version: "3.11"

python-version: "3.12"
- name: Upgrade pip
if: steps.cache-statsbomb.outputs.cache-hit != 'true' || steps.cache-public-wyscout.outputs.cache-hit != 'true'
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip --version
- name: Install Poetry
if: steps.cache-statsbomb.outputs.cache-hit != 'true' || steps.cache-public-wyscout.outputs.cache-hit != 'true'
run: |
pip install --constraint=.github/workflows/constraints.txt poetry
poetry --version
- name: Install Nox
if: steps.cache-statsbomb.outputs.cache-hit != 'true' || steps.cache-public-wyscout.outputs.cache-hit != 'true'
run: |
pip install --constraint=.github/workflows/constraints.txt nox nox-poetry
nox --version
- name: Install dependencies
if: steps.cache-statsbomb.outputs.cache-hit != 'true' || steps.cache-public-wyscout.outputs.cache-hit != 'true'
run: poetry install --no-dev
env:
PYTHON_KEYRING_BACKEND: keyring.backends.null.Keyring

- name: Download StatsBomb test data
if: steps.cache-statsbomb.outputs.cache-hit != 'true'
run: poetry run python tests/datasets/download.py --download-statsbomb

- name: Download Wyscout test data
if: steps.cache-public-wyscout.outputs.cache-hit != 'true'
run: poetry run python tests/datasets/download.py --download-wyscout

tests:
name: ${{ matrix.session }} ${{ matrix.python-version }} / ${{ matrix.os }}
needs: setup
Expand All @@ -75,57 +63,49 @@ jobs:
fail-fast: false
matrix:
include:
- { python-version: "3.11", os: ubuntu-latest, session: "pre-commit" }
- { python-version: "3.11", os: ubuntu-latest, session: "mypy" }
- { python-version: "3.12", os: ubuntu-latest, session: "pre-commit" }
- { python-version: "3.12", os: ubuntu-latest, session: "mypy" }
- { python-version: "3.12", os: ubuntu-latest, session: "tests" }
- { python-version: "3.11", os: ubuntu-latest, session: "tests" }
- { python-version: "3.10", os: ubuntu-latest, session: "tests" }
- { python-version: "3.9", os: ubuntu-latest, session: "tests" }
- { python-version: "3.11", os: windows-latest, session: "tests" }
- { python-version: "3.11", os: ubuntu-latest, session: "docs-build" }

- { python-version: "3.12", os: windows-latest, session: "tests" }
- { python-version: "3.12", os: ubuntu-latest, session: "docs-build" }
env:
NOXSESSION: ${{ matrix.session }}

steps:
- name: Check out the repository
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip --version
- name: Install Poetry
run: |
pip install --constraint=.github/workflows/constraints.txt poetry
poetry --version
- name: Install Nox
run: |
pip install --constraint=.github/workflows/constraints.txt nox nox-poetry
nox --version
- name: Load cached StatsBomb test data
if: matrix.session == 'tests'
id: cache-statsbomb
uses: actions/cache@v4
with:
path: tests/datasets/statsbomb
key: cache-statsbomb-data

- name: Load cached Wyscout test data
if: matrix.session == 'tests'
id: cache-public-wyscout
uses: actions/cache@v4
with:
path: tests/datasets/wyscout_public
key: cache-public-wyscout-data

- name: Compute pre-commit cache key
if: matrix.session == 'pre-commit'
id: pre-commit-cache
Expand All @@ -140,7 +120,6 @@ jobs:
result = "${{ runner.os }}-{}-{}-pre-commit".format(python, digest[:8])
print("::set-output name=result::{}".format(result))
- name: Restore pre-commit cache
uses: actions/cache@v4
if: matrix.session == 'pre-commit'
Expand All @@ -149,65 +128,53 @@ jobs:
key: ${{ steps.pre-commit-cache.outputs.result }}-${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: |
${{ steps.pre-commit-cache.outputs.result }}-
- name: Run Nox
run: |
nox --force-color --python=${{ matrix.python-version }}
- name: Upload coverage data
if: always() && matrix.session == 'tests' && matrix.os == 'ubuntu-latest'
uses: "actions/upload-artifact@v4"
with:
name: coverage-data-${{ matrix.os }}-${{ matrix.python-version }}
path: ".coverage.*"

- name: Upload documentation
if: matrix.session == 'docs-build'
uses: actions/upload-artifact@v4
with:
name: docs
path: docs/_build

coverage:
runs-on: ubuntu-latest
needs: tests
steps:
- name: Check out the repository
uses: actions/checkout@v4

- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.11

- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip --version
- name: Install Poetry
run: |
pip install --constraint=.github/workflows/constraints.txt poetry
poetry --version
- name: Install Nox
run: |
pip install --constraint=.github/workflows/constraints.txt nox nox-poetry
nox --version
- name: Download coverage data
uses: actions/download-artifact@v4
with:
pattern: coverage-data-*
merge-multiple: true

- name: Combine coverage data and display human readable report
run: |
nox --force-color --session=coverage
- name: Create coverage report
run: |
nox --force-color --session=coverage -- xml
- name: Upload coverage report
uses: codecov/codecov-action@v4
14 changes: 1 addition & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
name: Release

on:
push:
branches:
- main
- master

jobs:
release:
name: Release
Expand All @@ -15,61 +13,51 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

python-version: "3.12"
- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip --version
- name: Install Poetry
run: |
pip install --constraint=.github/workflows/constraints.txt poetry
poetry --version
- name: Check if there is a parent commit
id: check-parent-commit
run: |
echo "::set-output name=sha::$(git rev-parse --verify --quiet HEAD^)"
- name: Detect and tag new version
id: check-version
if: steps.check-parent-commit.outputs.sha
uses: salsify/[email protected]
with:
version-command: |
bash -o pipefail -c "poetry version | awk '{ print \$2 }'"
- name: Bump version for developmental release
if: "! steps.check-version.outputs.tag"
run: |
poetry version patch &&
version=$(poetry version | awk '{ print $2 }') &&
poetry version $version.dev.$(date +%s)
- name: Build package
run: |
poetry build --ansi
- name: Publish package on PyPI
if: steps.check-version.outputs.tag
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}

- name: Publish package on TestPyPI
if: "! steps.check-version.outputs.tag"
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.TEST_PYPI_TOKEN }}
repository_url: https://test.pypi.org/legacy/

- name: Publish the release notes
uses: release-drafter/[email protected]
with:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Socceraction contains the following components:

## Installation / Getting started

The recommended way to install `socceraction` is to simply use pip. The latest version officially supports Python 3.9 - 3.11.
The recommended way to install `socceraction` is to simply use pip. The latest version officially supports Python 3.9 - 3.12.

```sh
$ pip install socceraction
Expand Down
2 changes: 1 addition & 1 deletion docs/documentation/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Install Python
==============

Being a Python library, socceraction requires Python.
Currently, socceraction supports Python version 3.9 -- 3.11.
Currently, socceraction supports Python version 3.9 -- 3.12.
Get the latest version of Python at https://www.python.org/downloads/ or with
your operating system's package manager.

Expand Down
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@


package = "socceraction"
python_versions = ["3.11", "3.10", "3.9"]
python_versions = ["3.12", "3.11", "3.10", "3.9"]
nox.needs_version = ">= 2021.6.6"
nox.options.sessions = (
"pre-commit",
Expand Down
5 changes: 3 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ classifiers = [
Changelog = "https://github.com/ML-KULeuven/socceraction/releases"

[tool.poetry.dependencies]
python = ">=3.9,<3.12"
python = ">=3.9,<3.13"
pandas = "^2.1.1"
numpy = "^1.26.0"
scikit-learn = "^1.3.1"
Expand Down

0 comments on commit 8e79a0a

Please sign in to comment.