From 77f47ccb08f6728ef302f32abbf23ff3ad67ff61 Mon Sep 17 00:00:00 2001 From: Sebastian Straub Date: Thu, 10 Aug 2023 17:38:30 +0200 Subject: [PATCH] set min version to python 3.8 (3.7 is EOL) --- .github/workflows/tests-conda.yml | 2 +- .github/workflows/tests-pip.yml | 2 +- .pre-commit-config.yaml | 1 - README.md | 4 ++-- cookiecutter.json | 2 +- hooks/pre_gen_project.py | 6 +++--- tests/version_check.py | 2 +- {{cookiecutter.project_slug}}/.pre-commit-config.yaml | 2 +- {{cookiecutter.project_slug}}/docker-compose.yml | 2 +- {{cookiecutter.project_slug}}/pyproject.toml | 1 - {{cookiecutter.project_slug}}/setup.py | 2 +- .../src/{{cookiecutter.module_name}}/version.py | 7 ++----- 12 files changed, 14 insertions(+), 19 deletions(-) diff --git a/.github/workflows/tests-conda.yml b/.github/workflows/tests-conda.yml index 4ea7e1d..cfbfe1c 100644 --- a/.github/workflows/tests-conda.yml +++ b/.github/workflows/tests-conda.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.7, 3.11] + python-version: [3.8, 3.12] os: [ubuntu-latest, windows-latest] name: "Test: Python ${{ matrix.python-version }}, conda, ${{ matrix.os }}" steps: diff --git a/.github/workflows/tests-pip.yml b/.github/workflows/tests-pip.yml index 0eb5218..5614204 100644 --- a/.github/workflows/tests-pip.yml +++ b/.github/workflows/tests-pip.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.7, 3.11] + python-version: [3.8, 3.12] os: [ubuntu-latest, windows-latest] name: "Test: Python ${{ matrix.python-version }}, pip, ${{ matrix.os }}" steps: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 37341c9..968b50d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,6 @@ repos: rev: v4.4.0 hooks: - id: check-added-large-files - - id: check-ast - id: check-merge-conflict - id: end-of-file-fixer - id: mixed-line-ending diff --git a/README.md b/README.md index 1a02ab9..1e69045 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # AT Python Template [![build](https://img.shields.io/github/actions/workflow/status/at-gmbh/at-python-template/tests-pip.yml?branch=master)](https://github.com/at-gmbh/at-python-template/actions?query=branch%3Amaster+) -![Python Version](https://img.shields.io/badge/python-3.7%20--%203.11-blue) +![Python Version](https://img.shields.io/badge/python-3.8%20--%203.12-blue) [![License](https://img.shields.io/github/license/at-gmbh/at-python-template)](https://github.com/at-gmbh/at-python-template/blob/master/LICENSE) ![GitHub Repo stars](https://img.shields.io/github/stars/at-gmbh/at-python-template?style=social) @@ -13,7 +13,7 @@ This is the official Python Project Template of Alexander Thamm GmbH (AT). It is 2. `cookiecutter https://github.com/at-gmbh/at-python-template` 3. profit! -This will install or update cookiecutter on your system and create a new project in the current folder using the AT Python Template. Please note: Python 3.7 or higher is required. +This will install or update cookiecutter on your system and create a new project in the current folder using the AT Python Template. Please note: Python 3.8 or higher is required. > This template requires `cookiecutter>=1.7.2`. If you experience issues installing it into your default conda environment, we recommend to create a new clean environment with nothing but the `cookiecutter` package installed. diff --git a/cookiecutter.json b/cookiecutter.json index be82fea..663becc 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -9,7 +9,7 @@ "package_manager": ["conda", "pip", "poetry"], "use_notebooks": ["no", "yes"], "use_docker": ["no", "yes"], - "ci_pipeline": ["none", "gitlab"], + "ci_pipeline": ["none", "gitlab"], "create_cli": ["no", "yes"], "config_file": ["none", "hocon", "yaml"], "code_formatter": ["none", "black"], diff --git a/hooks/pre_gen_project.py b/hooks/pre_gen_project.py index 71c5b0b..7cf604e 100644 --- a/hooks/pre_gen_project.py +++ b/hooks/pre_gen_project.py @@ -19,9 +19,9 @@ with warnings.catch_warnings(): warnings.simplefilter("ignore", category=DeprecationWarning) - # check Python version (3.7 or higher) - if StrictVersion(platform.python_version()) < StrictVersion("3.7.0"): - print("ERROR: You are using Python {}, but Python 3.7 or higher is required " + # check Python version (3.8 or higher) + if StrictVersion(platform.python_version()) < StrictVersion("3.8.0"): + print("ERROR: You are using Python {}, but Python 3.8 or higher is required " "to use this template".format(platform.python_version())) sys.exit(1) # check cookiecutter version (1.7.2 or higher) diff --git a/tests/version_check.py b/tests/version_check.py index 81a7c4e..1caecc9 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.7 or higher' in stdout or b'successfully created' in stdout: +if b'Python 3.8 or higher' in stdout or b'successfully created' in stdout: if actual_fail == expect_fail: print("Python {} {} as expected".format( platform.python_version(), diff --git a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml index 64337cd..32091a9 100644 --- a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml +++ b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml @@ -16,7 +16,7 @@ repos: rev: stable hooks: - id: black - language_version: python3.7 + language_version: python3.8 exclude: ^notebooks{% else %} - repo: https://github.com/PyCQA/flake8 rev: '5.0.4' diff --git a/{{cookiecutter.project_slug}}/docker-compose.yml b/{{cookiecutter.project_slug}}/docker-compose.yml index a55f316..d7c7871 100644 --- a/{{cookiecutter.project_slug}}/docker-compose.yml +++ b/{{cookiecutter.project_slug}}/docker-compose.yml @@ -6,6 +6,6 @@ services: build: context: .{% if cookiecutter.package_manager != 'poetry' %} args: - PYTHON_IMAGE_TAG: {% if cookiecutter.package_manager == 'conda' %}"4.8.2"{% else %}"3.7-stretch"{% endif %}{% endif %} + PYTHON_IMAGE_TAG: {% if cookiecutter.package_manager == 'conda' %}"4.8.2"{% else %}"3.8-stretch"{% endif %}{% endif %} command: '{% if cookiecutter.create_cli == 'yes' %}--help{% endif %}' tty: true diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index 402f11b..b03fe76 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -15,7 +15,6 @@ python = "^3.10"{% if cookiecutter.config_file == 'hocon' %} pyhocon = "^0.3.59"{% elif cookiecutter.config_file == 'yaml' %} PyYAML = "^6.0"{% endif %}{% if cookiecutter.create_cli == 'yes' %} typer = {extras = ["all"], version = "^0.7.0"}{% endif %} -importlib-metadata = {version = "^1.0", python = "<3.8"} [tool.poetry.dev-dependencies]{% if cookiecutter.code_formatter == 'black' %} black = "^22.10"{% endif %} diff --git a/{{cookiecutter.project_slug}}/setup.py b/{{cookiecutter.project_slug}}/setup.py index ade8190..8ff3637 100644 --- a/{{cookiecutter.project_slug}}/setup.py +++ b/{{cookiecutter.project_slug}}/setup.py @@ -35,5 +35,5 @@ def read(fname): 'pre-commit', ], platforms='any', - python_requires='>=3.7', + python_requires='>=3.8', ) diff --git a/{{cookiecutter.project_slug}}/src/{{cookiecutter.module_name}}/version.py b/{{cookiecutter.project_slug}}/src/{{cookiecutter.module_name}}/version.py index 5c86dd1..c5441b0 100644 --- a/{{cookiecutter.project_slug}}/src/{{cookiecutter.module_name}}/version.py +++ b/{{cookiecutter.project_slug}}/src/{{cookiecutter.module_name}}/version.py @@ -1,7 +1,4 @@ -{% if cookiecutter.package_manager == 'poetry' %}try: - import importlib.metadata as importlib_metadata -except ModuleNotFoundError: - import importlib_metadata +{% if cookiecutter.package_manager == 'poetry' %}from importlib.metadata import version -__version__ = importlib_metadata.version("{{ cookiecutter.project_slug }}") +__version__ = version("{{ cookiecutter.project_slug }}") {%- else %}__version__ = '0.1.0'{% endif %}