Skip to content

Add support for Python 3.12 #508

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Oct 11, 2023
Merged
9 changes: 9 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
coverage:
status:
project:
default:
informational: true
patch:
default:
informational: true
changes: false
comment: off
ignore:
- graphblas/viz.py
4 changes: 3 additions & 1 deletion .github/workflows/imports.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,19 @@ jobs:
3.9
3.10
3.11
3.12
weights: |
1
1
1
1
test_imports:
needs: rngs
runs-on: ${{ needs.rngs.outputs.os }}
# runs-on: ${{ matrix.os }}
# strategy:
# matrix:
# python-version: ["3.9", "3.10", "3.11"]
# python-version: ["3.9", "3.10", "3.11", "3.12"]
# os: ["ubuntu-latest", "macos-latest", "windows-latest"]
steps:
- uses: actions/checkout@v4
Expand Down
39 changes: 31 additions & 8 deletions .github/workflows/test_and_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,12 @@ jobs:
3.9
3.10
3.11
3.12
weights: |
1
1
1
1
- name: RNG for source of python-suitesparse-graphblas
uses: ddradar/choose-random-action@v2.0.2
id: sourcetype
Expand Down Expand Up @@ -178,11 +180,16 @@ jobs:
spver=$(python -c 'import random ; print(random.choice(["=1.8", "=1.9", "=1.10", "=1.11", ""]))')
pdver=$(python -c 'import random ; print(random.choice(["=1.3", "=1.4", "=1.5", "=2.0", "=2.1", ""]))')
akver=$(python -c 'import random ; print(random.choice(["=1.9", "=1.10", "=2.0", "=2.1", "=2.2", "=2.3", "=2.4", ""]))')
else # Python 3.11
elif [[ ${{ startsWith(steps.pyver.outputs.selected, '3.11') }} == true ]]; then
npver=$(python -c 'import random ; print(random.choice(["=1.23", "=1.24", "=1.25", "=1.26", ""]))')
spver=$(python -c 'import random ; print(random.choice(["=1.9", "=1.10", "=1.11", ""]))')
pdver=$(python -c 'import random ; print(random.choice(["=1.5", "=2.0", "=2.1", ""]))')
akver=$(python -c 'import random ; print(random.choice(["=1.10", "=2.0", "=2.1", "=2.2", "=2.3", "=2.4", ""]))')
else # Python 3.12
npver=$(python -c 'import random ; print(random.choice(["=1.26", ""]))')
spver=$(python -c 'import random ; print(random.choice(["=1.11", ""]))')
pdver=$(python -c 'import random ; print(random.choice(["=2.1", ""]))')
akver=$(python -c 'import random ; print(random.choice(["=2.4", ""]))')
fi
if [[ ${{ steps.sourcetype.outputs.selected }} == "source" || ${{ steps.sourcetype.outputs.selected }} == "upstream" ]]; then
# TODO: there are currently issues with some numpy versions when
Expand All @@ -195,16 +202,23 @@ jobs:
# That is, we don't need to support versions of it that are two years old.
# But, it's still useful for us to test with different versions!
psg=""
if [[ ${{ steps.sourcetype.outputs.selected}} == "conda-forge" ]] ; then
psgver=$(python -c 'import random ; print(random.choice(["=7.4.0", "=7.4.1", "=7.4.2", "=7.4.3.0", "=7.4.3.1", "=7.4.3.2", "=8.0.2.1", ""]))')
if [[ ${{ steps.sourcetype.outputs.selected}} == "upstream" ]] ; then
psgver=""
elif [[ ${{ startsWith(steps.pyver.outputs.selected, '3.12') }} == true ]] ; then
if [[ ${{ steps.sourcetype.outputs.selected}} == "conda-forge" ]] ; then
psgver=$(python -c 'import random ; print(random.choice(["=8.2.0.1", ""]))')
psg=python-suitesparse-graphblas${psgver}
else
psgver=$(python -c 'import random ; print(random.choice(["==8.2.0.1", ""]))')
fi
elif [[ ${{ steps.sourcetype.outputs.selected}} == "conda-forge" ]] ; then
psgver=$(python -c 'import random ; print(random.choice(["=7.4.0", "=7.4.1", "=7.4.2", "=7.4.3.0", "=7.4.3.1", "=7.4.3.2", "=8.0.2.1", "=8.2.0.1", ""]))')
psg=python-suitesparse-graphblas${psgver}
elif [[ ${{ steps.sourcetype.outputs.selected}} == "wheel" ]] ; then
psgver=$(python -c 'import random ; print(random.choice(["==7.4.3.2", "==8.0.2.1", ""]))')
psgver=$(python -c 'import random ; print(random.choice(["==7.4.3.2", "==8.0.2.1", "==8.2.0.1", ""]))')
elif [[ ${{ steps.sourcetype.outputs.selected}} == "source" ]] ; then
# These should be exact versions
psgver=$(python -c 'import random ; print(random.choice(["==7.4.0.0", "==7.4.1.0", "==7.4.2.0", "==7.4.3.0", "==7.4.3.1", "==7.4.3.2", "==8.0.2.1", ""]))')
else
psgver=""
psgver=$(python -c 'import random ; print(random.choice(["==7.4.0.0", "==7.4.1.0", "==7.4.2.0", "==7.4.3.0", "==7.4.3.1", "==7.4.3.2", "==8.0.2.1", "==8.2.0.1", ""]))')
fi
if [[ ${npver} == "=1.26" ]] ; then
numbaver=""
Expand Down Expand Up @@ -258,10 +272,15 @@ jobs:
numba=numba${numbaver}
sparse=sparse${sparsever}
fi
if [[ ${{ startsWith(steps.pyver.outputs.selected, '3.12') }} == true ]]; then
coveralls=""
else
coveralls="coveralls=3.3.1"
fi
echo "versions: np${npver} sp${spver} pd${pdver} ak${akver} nx${nxver} numba${numbaver} yaml${yamlver} sparse${sparsever} psg${psgver}"

set -x # echo on
$(command -v mamba || command -v conda) install packaging pytest coverage coveralls=3.3.1 pytest-randomly cffi donfig tomli c-compiler make \
$(command -v mamba || command -v conda) install packaging pytest coverage ${coveralls} pytest-randomly cffi donfig tomli c-compiler make \
pyyaml${yamlver} ${sparse} pandas${pdver} scipy${spver} numpy${npver} ${awkward} \
networkx${nxver} ${numba} ${fmm} ${psg} \
${{ matrix.slowtask == 'pytest_bizarro' && 'black' || '' }} \
Expand Down Expand Up @@ -397,11 +416,15 @@ jobs:
if: matrix.slowtask == 'pytest_bizarro'
run: |
# This step uses `black`
if [[ ${{ startsWith(steps.pyver.outputs.selected, '3.12') }} == true ]]; then
pip install black # Latest version of black on conda-forge does not have builds for Python 3.12
fi
coverage run -a -m graphblas.core.automethods
coverage run -a -m graphblas.core.infixmethods
git diff --exit-code
- name: Coverage1
id: coverageAttempt1
if: startsWith(steps.pyver.outputs.selected, '3.12') != true
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ default_language_version:
python: python3
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand Down Expand Up @@ -51,7 +51,7 @@ repos:
- id: isort
# Let's keep `pyupgrade` even though `ruff --fix` probably does most of it
- repo: https://github.com/asottile/pyupgrade
rev: v3.14.0
rev: v3.15.0
hooks:
- id: pyupgrade
args: [--py39-plus]
Expand Down Expand Up @@ -126,7 +126,7 @@ repos:
args: [graphblas/]
pass_filenames: false
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: no-commit-to-branch # no commit directly to main
#
Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ dependencies:
# - flake8-simplify
# - gcc
# - gh
# - git
# - graph-tool
# - xorg-libxcursor # for graph-tool
# - grayskull
Expand Down
10 changes: 7 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3 :: Only",
"Intended Audience :: Developers",
"Intended Audience :: Other Audience",
Expand All @@ -62,7 +63,7 @@ dependencies = [
"pyyaml >=5.4",
# These won't be installed by default after 2024.3.0
# Use e.g. "python-graphblas[suitesparse]" or "python-graphblas[default]" instead
"suitesparse-graphblas >=7.4.0.0, <7.5",
"suitesparse-graphblas >=7.4.0.0, <9",
"numba >=0.55; python_version<'3.12'", # make optional where numba is not supported
]

Expand All @@ -74,7 +75,7 @@ changelog = "https://github.com/python-graphblas/python-graphblas/releases"

[project.optional-dependencies]
suitesparse = [
"suitesparse-graphblas >=7.4.0.0, <7.5",
"suitesparse-graphblas >=7.4.0.0, <9",
]
networkx = [
"networkx >=2.8",
Expand Down Expand Up @@ -156,7 +157,7 @@ dirty_template = "{tag}+{ccount}.g{sha}.dirty"

[tool.black]
line-length = 100
target-version = ["py39", "py310", "py311"]
target-version = ["py39", "py310", "py311", "py312"]

[tool.isort]
sections = ["FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"]
Expand Down Expand Up @@ -207,6 +208,9 @@ filterwarnings = [

# pypy gives this warning
"ignore:can't resolve package from __spec__ or __package__:ImportWarning:",

# Python 3.12 introduced this deprecation, which is triggered by pandas 2.1.1
"ignore:datetime.datetime.utcfromtimestamp:DeprecationWarning:dateutil",
]

[tool.coverage.run]
Expand Down
2 changes: 1 addition & 1 deletion scripts/check_versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ conda search 'numpy[channel=conda-forge]>=1.26.0'
conda search 'pandas[channel=conda-forge]>=2.1.1'
conda search 'scipy[channel=conda-forge]>=1.11.3'
conda search 'networkx[channel=conda-forge]>=3.1'
conda search 'awkward[channel=conda-forge]>=2.4.4'
conda search 'awkward[channel=conda-forge]>=2.4.5'
conda search 'sparse[channel=conda-forge]>=0.14.0'
conda search 'fast_matrix_market[channel=conda-forge]>=1.7.3'
conda search 'numba[channel=conda-forge]>=0.57.1'
Expand Down