From c68aa29141b8906d50909290792b80cdf43e75b0 Mon Sep 17 00:00:00 2001 From: Artur Glavic Date: Mon, 6 Oct 2025 16:53:52 +0200 Subject: [PATCH] deal with backport StrEnum doesn't work with python <3.10 and requirements.txt for backports --- .github/workflows/unit_tests.yml | 10 ---------- eos/options.py | 7 ++++++- requirements.txt | 2 ++ 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 4ce6de2..58295b5 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -33,16 +33,6 @@ jobs: pip install pytest pip install -r requirements.txt - - name: Backport to 3.8 - if: matrix.python-version == '3.8' - run: | - pip install backports.zoneinfo - - - name: Backport StrEnum - if: matrix.python-version < '3.11' - run: | - pip install backports.strenum - - name: Test with pytest run: | python -m pytest tests diff --git a/eos/options.py b/eos/options.py index 0c217ed..c97f6bf 100644 --- a/eos/options.py +++ b/eos/options.py @@ -13,7 +13,12 @@ import logging try: from enum import StrEnum except ImportError: - from backports.strenum import StrEnum + try: + # python <3.11 try to use backports + from backports.strenum import StrEnum + except ImportError: + # python <3.10 use Enum instead + from enum import Enum as StrEnum @dataclass class CommandlineParameterConfig: diff --git a/requirements.txt b/requirements.txt index b86897a..8dddb81 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,5 @@ numpy h5py orsopy numba +backports.strenum; python_version<"3.11" +backports.zoneinfo; python_version<"3.9"