Skip to content

Commit

Permalink
Merge pull request #544 from iiasa/python-3.13
Browse files Browse the repository at this point in the history
Confirm support for Python 3.13 and drop 3.8
  • Loading branch information
khaeru authored Nov 20, 2024
2 parents 02c887a + dcf15af commit 02dadfa
Show file tree
Hide file tree
Showing 30 changed files with 175 additions and 280 deletions.
23 changes: 9 additions & 14 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ jobs:
- ubuntu-latest
- windows-latest
python-version:
- "3.8" # Earliest version supported by ixmp
- "3.9"
- "3.9" # Earliest version supported by ixmp
- "3.10"
- "3.11"
- "3.12" # Latest supported by ixmp
- "3.12"
- "3.13" # Latest supported by ixmp
gams-version:
# Version used until 2024-07; disabled
# - 25.1.1
Expand All @@ -43,17 +43,13 @@ jobs:

exclude:
# Specific version combinations that are invalid / not to be used
# No arm64 distribution for this version of GAMS
# - { os: macos-latest, gams-version: 25.1.1}
# No arm64 distributions of JPype for these Pythons
- { os: macos-latest, python-version: "3.8" }
- { os: macos-latest, python-version: "3.9" }
# Redundant with macos-latest
- { os: macos-13, python-version: "3.10" }
- { os: macos-13, python-version: "3.11" }
- { os: macos-13, python-version: "3.12" }
# Example: pandas 2.0 requires Python >= 3.8
# - { python-version: "3.7", pandas-version: "==2.0.0rc0" }
- { os: macos-13, python-version: "3.13" }

fail-fast: false

Expand All @@ -80,6 +76,8 @@ jobs:

- uses: r-lib/actions/setup-r@v2
id: setup-r
with:
r-version: "4.4.1"

- name: Cache GAMS installer and R packages
uses: actions/cache@v4
Expand Down Expand Up @@ -109,12 +107,9 @@ jobs:
# commented: use with "pandas-version" in the matrix, above
# pip install --upgrade pandas${{ matrix.pandas-version }}
# TEMPORARY Work around hgrecco/pint#2007;
# see https://github.com/iiasa/ixmp/issues/534
pip install "pint != 0.24.0" "numpy < 2"
# TEMPORARY Work around pretenders/pretenders#153
pip install "bottle < 0.13"
# TEMPORARY With Python 3.13 pyam-iamc resolves to 1.3.1, which in turn
# limits pint < 0.17. Override. cf. iiasa/ixmp#544
pip install --upgrade pint
- name: Install R dependencies and tutorial requirements
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ prof/

# Editors and IDEs
.editorconfig
.vscode
*.iml
/**/.idea

Expand Down
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ repos:
- pandas-stubs
- pytest
- sphinx
- werkzeug
- xarray
args: ["."]
- repo: https://github.com/astral-sh/ruff-pre-commit
Expand Down
2 changes: 2 additions & 0 deletions RELEASE_NOTES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Next release
============

- :mod:`ixmp` is tested and compatible with `Python 3.13 <https://www.python.org/downloads/release/python-3130/>`__ (:pull:`544`).
- Support for Python 3.8 is dropped (:pull:`544`), as it has reached end-of-life.
- :mod:`ixmp` locates GAMS API libraries needed for the Java code underlying :class:`.JDBCBackend` based on the system GAMS installation (:pull:`532`).
As a result:

Expand Down
4 changes: 2 additions & 2 deletions doc/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Install system dependencies
Python
------

Python version 3.8 or later is required.
Python version 3.9 or later is required.

GAMS (required)
---------------
Expand Down Expand Up @@ -89,7 +89,7 @@ After installing GAMS, we recommend that new users install Anaconda, and then us
Advanced users may choose to install :mod:`ixmp` from source code (next section).

4. Install Python via either `Miniconda`_ or `Anaconda`_. [1]_
We recommend the latest version; currently Python 3.10. [2]_
We recommend the latest version; currently Python 3.13. [2]_

5. Open a command prompt.
We recommend Windows users use the “Anaconda Prompt” to avoid issues with permissions and environment variables when installing and using :mod:`ixmp`.
Expand Down
10 changes: 5 additions & 5 deletions ixmp/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from copy import copy
from dataclasses import asdict, dataclass, field, fields, make_dataclass
from pathlib import Path
from typing import Any, Dict, Optional, Tuple, Type
from typing import Any, Optional

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -121,7 +121,7 @@ def delete_field(self, name):
data.pop(name)
return new_cls, new_cls(**data)

def keys(self) -> Tuple[str, ...]:
def keys(self) -> tuple[str, ...]:
return tuple(map(lambda f: f.name.replace("_", " "), fields(self)))

def set(self, name: str, value: Any, strict: bool = True):
Expand Down Expand Up @@ -214,7 +214,7 @@ class Config:
#: ``ixmp.config.values["platform"]["platform name"]…``.
values: BaseValues

_ValuesClass: Type
_ValuesClass: type[BaseValues]

def __init__(self, read: bool = True):
self._ValuesClass = BaseValues
Expand Down Expand Up @@ -261,7 +261,7 @@ def get(self, name: str) -> Any:
"""Return the value of a configuration key `name`."""
return self.values[name]

def keys(self) -> Tuple[str, ...]:
def keys(self) -> tuple[str, ...]:
"""Return the names of all registered configuration keys."""
return self.values.keys()

Expand Down Expand Up @@ -383,7 +383,7 @@ def add_platform(self, name: str, *args, **kwargs):

self.values["platform"][name] = info

def get_platform_info(self, name: str) -> Tuple[str, Dict[str, Any]]:
def get_platform_info(self, name: str) -> tuple[str, dict[str, Any]]:
"""Return information on configured Platform `name`.
Parameters
Expand Down
9 changes: 6 additions & 3 deletions ixmp/backend/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
"""Backend API."""

from enum import IntFlag
from typing import Dict, List, Type, Union
from typing import TYPE_CHECKING, Union

if TYPE_CHECKING:
import ixmp.backend.base

#: Lists of field names for tuples returned by Backend API methods.
#:
Expand Down Expand Up @@ -46,12 +49,12 @@
#: Partial list of dimensions for the IAMC data structure, or “IAMC format”. This omits
#: "year" and "subannual" which appear in some variants of the structure, but not in
#: others.
IAMC_IDX: List[Union[str, int]] = ["model", "scenario", "region", "variable", "unit"]
IAMC_IDX: list[Union[str, int]] = ["model", "scenario", "region", "variable", "unit"]


#: Mapping from names to available backends. To register additional backends, add
#: entries to this dictionary.
BACKENDS: Dict[str, Type] = {}
BACKENDS: dict[str, type["ixmp.backend.base.Backend"]] = {}


class ItemType(IntFlag):
Expand Down
Loading

0 comments on commit 02dadfa

Please sign in to comment.