From 25f6adc8803a9c8dde55e71c129b15450292959e Mon Sep 17 00:00:00 2001 From: Christian Baur Date: Wed, 8 Jan 2025 18:07:12 +0100 Subject: [PATCH 1/2] Fix pre_gen_project.py file because of missed adjustment of python version. --- hooks/pre_gen_project.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hooks/pre_gen_project.py b/hooks/pre_gen_project.py index 19b3457..e5f1ded 100644 --- a/hooks/pre_gen_project.py +++ b/hooks/pre_gen_project.py @@ -11,7 +11,7 @@ import platform import re import sys -from distutils.version import StrictVersion +from packaging.version import Version import warnings import cookiecutter @@ -19,14 +19,14 @@ with warnings.catch_warnings(): warnings.simplefilter("ignore", category=DeprecationWarning) - # check Python version (3.8 or higher) - if StrictVersion(platform.python_version()) < StrictVersion("3.8.0"): + # check Python version (3.9 or higher) + if Version(platform.python_version()) < Version("3.9.0"): print(f"ERROR: You are using Python {platform.python_version()},", - "but Python 3.8 or higher is required to use this template") + "but Python 3.9 or higher is required to use this template") sys.exit(1) # check cookiecutter version (1.7.2 or higher) - if StrictVersion(cookiecutter.__version__) < StrictVersion('1.7.2'): - print(f"ERROR: You are using cookiecutter {cookiecutter.__version__}" + if Version(cookiecutter.__version__) < Version('1.7.2'): + print(f"ERROR: You are using cookiecutter {cookiecutter.__version__}" "but cookiecutter 1.7.2 or higher is required to use this template") sys.exit(1) From a89938c570e864550e3b42967ab78b2003fe587f Mon Sep 17 00:00:00 2001 From: Christian Baur Date: Wed, 8 Jan 2025 18:14:00 +0100 Subject: [PATCH 2/2] simplify to ubuntu-latest for consistency --- .github/workflows/tests-pip.yml | 29 ++++++++++++++--------------- tests/version_check.py | 2 +- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/.github/workflows/tests-pip.yml b/.github/workflows/tests-pip.yml index 7e64fd8..8ea84cd 100644 --- a/.github/workflows/tests-pip.yml +++ b/.github/workflows/tests-pip.yml @@ -31,23 +31,22 @@ jobs: pytest tests version-check: - runs-on: ${{ matrix.os }} + runs-on: ubuntu-latest strategy: fail-fast: false matrix: - python-version: [3.6] - os: [ubuntu-20.04] + python-version: [ 3.9, 3.11 ] name: "Version Check: Python ${{ matrix.python-version }}" steps: - - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - name: Install Cookiecutter - run: | - python -m pip install --upgrade pip - pip install cookiecutter~=1.7.2 - - name: Run Version Check - run: | - python tests/version_check.py --fail + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install Cookiecutter and dependencies + run: | + python -m pip install --upgrade pip + python -m pip install cookiecutter packaging + - name: Run Version Check + run: | + python tests/version_check.py --fail diff --git a/tests/version_check.py b/tests/version_check.py index 95853c3..7a91128 100644 --- a/tests/version_check.py +++ b/tests/version_check.py @@ -23,7 +23,7 @@ shutil.rmtree(temp_dir, ignore_errors=True) # handle possible issues & give proper return codes -if b'Python 3.8 or higher' in stdout or b'successfully created' in stdout: +if b'Python 3.9 or higher' in stdout or b'successfully created' in stdout: status = {True: "failed", False: "succeded"} if actual_fail == expect_fail: print(f"Python {platform.python_version()} {status[expect_fail]} as expected")