Skip to content

Commit

Permalink
Revert "Drop support for python 3.8 and 3.9"
Browse files Browse the repository at this point in the history
This reverts commit b6be86d.
  • Loading branch information
HakonSohoel committed Dec 19, 2024
1 parent 07dfa0f commit 5e671b9
Show file tree
Hide file tree
Showing 29 changed files with 141 additions and 135 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
with:
fetch-depth: 0

- name: Set up Python 3.12
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.12
python-version: 3.11

- name: Install dependencies
run: |
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13']
python-version: ['3.8', '3.10', '3.11', '3.12']

runs-on: ubuntu-latest

Expand All @@ -32,7 +32,7 @@ jobs:
- name: Setup Komodo
run: |
pip install -U pip
pip install -U pip wheel setuptools
pip install ".[dev]"
- name: Unit tests
Expand All @@ -48,13 +48,13 @@ jobs:
run: |
komodo-transpiler transpile \
--matrix-file="ci/${{env.RELEASE_NAME}}.yml" \
--output ci --matrix-coordinates "{rhel: ['8'], py: ['${{matrix.python-version}}']}"
--output ci --matrix-coordinates "{rhel: ['7'], py: ['${{matrix.python-version}}']}"
- name: Full integration test
run: |
py_version_number=$(echo "${{ matrix.python-version }}" | sed 's/\.//g')
kmd \
ci/${{env.RELEASE_NAME}}-py$py_version_number-rhel8.yml \
ci/${{env.RELEASE_NAME}}-py$py_version_number-rhel7.yml \
ci/${{env.REPOSITORY}} \
--workspace ${{ runner.temp }}/kmd-ws \
--prefix ${{ runner.temp }}/prefix \
Expand Down
7 changes: 4 additions & 3 deletions ci/release-matrix.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
numpy:
py38: 1.23.5
py39: 1.23.5
py310: 1.23.5
py311: 1.23.5
py312: 1.26.4
py313: 2.2.0
python: 3-builtin
setuptools: 75.6.0
wheel: 0.45.1
setuptools: 69.0.3
wheel: 0.42.0
8 changes: 2 additions & 6 deletions ci/repository.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
numpy:
2.2.0:
source: pypi
make: pip
maintainer: ci
1.26.4:
source: pypi
make: pip
Expand All @@ -20,13 +16,13 @@ python:
makeopts: --virtualenv-interpreter python3

setuptools:
75.6.0:
69.0.3:
source: pypi
make: pip
maintainer: ci

wheel:
0.45.1:
0.42.0:
source: pypi
make: pip
maintainer: ci
5 changes: 3 additions & 2 deletions komodo/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import re
import stat
from pathlib import Path
from typing import Dict

import requests

Expand Down Expand Up @@ -183,7 +184,7 @@ def pypaths(prefix, version):


def make(
pkgs: dict[str, str],
pkgs: Dict[str, str],
repo,
data,
prefix,
Expand Down Expand Up @@ -227,7 +228,7 @@ def make(
def resolve(input_str):
return input_str.replace("$(prefix)", prefix)

for package_name, path in zip(pkgorder, pkgpaths, strict=False):
for package_name, path in zip(pkgorder, pkgpaths):
ver = pkgs[package_name]
current = repo[package_name][ver]
make = current["make"]
Expand Down
3 changes: 2 additions & 1 deletion komodo/check_unused_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import argparse
import os
import sys
from typing import Dict

import yaml

Expand All @@ -15,7 +16,7 @@ def check_for_unused_package(
release_file: ReleaseFile,
package_status_file: str,
repository: RepositoryFile,
builtin_python_versions: dict[str, str],
builtin_python_versions: Dict[str, str],
):
package_status = load_yaml(package_status_file)
public_and_plugin_packages = [
Expand Down
5 changes: 3 additions & 2 deletions komodo/check_up_to_date_pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pathlib
import re
import sys
from typing import Dict, List

import requests
import ruamel.yaml
Expand Down Expand Up @@ -56,7 +57,7 @@ def get_python_requirement(sources: list):
return ""


def is_platform_compatible(build_info: list[dict], platform: str) -> bool:
def is_platform_compatible(build_info: List[Dict], platform: str) -> bool:
if platform == "darwin":
platform = "macos"
if platform == "linux2":
Expand All @@ -72,7 +73,7 @@ def is_platform_compatible(build_info: list[dict], platform: str) -> bool:

def compatible_versions(
releases: dict, python_version, platform: str
) -> list[get_version.Version]:
) -> List[get_version.Version]:
compatible_versions = []
for version_str, build_info in releases.items():
try:
Expand Down
3 changes: 2 additions & 1 deletion komodo/cleanup.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/usr/bin/env python

import sys
from typing import List

from komodo.yaml_file_types import ReleaseFile, RepositoryFile


def cleanup(repository_file_path: str, release_files_path: list[str]):
def cleanup(repository_file_path: str, release_files_path: List[str]):
repository_file = RepositoryFile()(repository_file_path)
repository = repository_file.content

Expand Down
29 changes: 14 additions & 15 deletions komodo/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
import os
import sys
import uuid
from collections.abc import Callable, Mapping, Sequence
from pathlib import Path
from typing import Any
from typing import Any, Callable, Dict, List, Mapping, Optional, Sequence, Tuple, Union

import jinja2
from ruamel.yaml import YAML
Expand Down Expand Up @@ -41,7 +40,7 @@ class KomodoNamespace(argparse.Namespace):
cmake: str
pip: str
workspace: str
extra_data_dirs: list[str]
extra_data_dirs: List[str]
postinst: str


Expand Down Expand Up @@ -89,7 +88,7 @@ def create_enable_scripts(komodo_prefix: str, komodo_release: str) -> None:


def _print_timing(
timing_element: tuple[str, datetime.timedelta],
timing_element: Tuple[str, datetime.timedelta],
adjust: bool = False,
) -> None:
if adjust:
Expand Down Expand Up @@ -126,10 +125,10 @@ def is_download_only(args: KomodoNamespace) -> bool:
@profile_time("Fetching all packages")
def download_packages(
release_file_content: Mapping[str, str],
repository_file_content: Mapping[str, Mapping[str, str | Sequence[str]]],
repository_file_content: Mapping[str, Mapping[str, Union[str, Sequence[str]]]],
download_destination: str,
pip_executable: str = "pip",
) -> dict[str, str]:
) -> Dict[str, str]:
"""Downloads all PyPI packages to destination. Tries to download other
packages to destination too.
Git packages are collected, and a dict of all git hashes is returned.
Expand Down Expand Up @@ -206,14 +205,14 @@ def generate_release_root(release_path: Path) -> Path:
def generate_release_manifest(
release_name: Path,
release_file_content: Mapping[str, str],
repository_file_content: Mapping[str, Mapping[str, str | Sequence[str]]],
git_hashes: Mapping[str, str] | None = None,
repository_file_content: Mapping[str, Mapping[str, Union[str, Sequence[str]]]],
git_hashes: Optional[Mapping[str, str]] = None,
) -> None:
releasedoc = Path(release_name) / Path(release_name)
with open(releasedoc, mode="w", encoding="utf-8") as filehandle:
release: dict[str, dict[str, str]] = {}
release: Dict[str, Dict[str, str]] = {}
for package, version in release_file_content.items():
entry: dict[str, str] = repository_file_content[package][version]
entry: Dict[str, str] = repository_file_content[package][version]
maintainer = repository_file_content[package][version]["maintainer"]
if entry.get("fetch") == "git":
version = git_hashes[package]
Expand Down Expand Up @@ -251,7 +250,7 @@ def delete_old_previously_moved_releases(prefix_path: Path, release_name: Path)
)


def apply_fallback_tmpdir_for_pip_if_set(tmp_dir: str | None = None):
def apply_fallback_tmpdir_for_pip_if_set(tmp_dir: Optional[str] = None):
"""Allows e.g. pip to use this folder as a destination for "pip
download", instead of in some cases falling back to /tmp, which is
undesired when building on nfs.
Expand All @@ -266,7 +265,7 @@ def apply_fallback_tmpdir_for_pip_if_set(tmp_dir: str | None = None):
@profile_time("pip install to final destination")
def install_previously_downloaded_pip_packages(
release_file_content: Mapping[str, str],
repository_file_content: Mapping[str, Mapping[str, str | Sequence[str]]],
repository_file_content: Mapping[str, Mapping[str, Union[str, Sequence[str]]]],
downloads_directory: str,
pip_executable: str,
release_root: Path,
Expand Down Expand Up @@ -296,7 +295,7 @@ def install_previously_downloaded_pip_packages(


def run_post_installation_scripts_if_set(
postinst: str | None, release_path: Path
postinst: Optional[str], release_path: Path
) -> None:
if postinst:
timing_func = profile_time("Running post-install scripts")
Expand Down Expand Up @@ -329,7 +328,7 @@ def compile_python_bytecode_files_and_fix_permissions(
compile_python_bytecode_files(release_root)


timings: list[tuple[str, datetime.timedelta]] = []
timings: List[Tuple[str, datetime.timedelta]] = []


def _main(args: KomodoNamespace) -> None:
Expand Down Expand Up @@ -417,7 +416,7 @@ def cli_main():
_main(args)


def parse_args(args: list[str]) -> KomodoNamespace:
def parse_args(args: List[str]) -> KomodoNamespace:
"""Parse the arguments from the command line into an `argparse.Namespace`.
Having a separated function makes it easier to test the CLI.
Expand Down
7 changes: 4 additions & 3 deletions komodo/deployed.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import argparse
import json
import os
from typing import List, Optional

from komodo.matrix import get_matrix_base
from komodo.yaml_file_types import ReleaseDir
Expand Down Expand Up @@ -34,13 +35,13 @@ def _fetch_non_deployed_releases(install_root, release_folder):
def fetch_non_deployed(
install_root: str,
releases_folder: str,
limit: int | None = None,
) -> list[str]:
limit: Optional[int] = None,
) -> List[str]:
non_deployed = _fetch_non_deployed_releases(install_root, releases_folder)
return non_deployed[:limit]


def output_formatter(release_list: list[str], do_json: bool = False) -> str:
def output_formatter(release_list: List[str], do_json: bool = False) -> str:
if do_json:
return json.dumps(release_list, separators=(",", ":"))
return "\n".join(release_list)
Expand Down
18 changes: 9 additions & 9 deletions komodo/insert_proposals.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import difflib
import os
from base64 import b64decode
from collections.abc import Mapping, MutableSet
from datetime import datetime
from typing import Dict, Mapping, MutableSet, Optional, Union

import github
from github import Github, UnknownObjectException
Expand All @@ -21,8 +21,8 @@


def recursive_update(
to_be_upgraded: Mapping[str, str | Mapping[str, str]],
upgrades: Mapping[str, str | Mapping[str, str]] | None,
to_be_upgraded: Mapping[str, Union[str, Mapping[str, str]]],
upgrades: Optional[Mapping[str, Union[str, Mapping[str, str]]]],
) -> None:
"""Updates release in place with upgrades/additions of packages from upgrades.
Expand Down Expand Up @@ -115,7 +115,7 @@ def get_upgrade_key(target: str) -> str:


def validate_upgrades(
upgrade_section: dict[str, str], repofile: RepositoryFile
upgrade_section: Dict[str, str], repofile: RepositoryFile
) -> None:
errors = set()
for package_name, package_version in upgrade_section.items():
Expand All @@ -128,7 +128,7 @@ def validate_upgrades(

def recursive_validate_package_entries(
package_name,
package_version_or_matrix: str | Mapping | None,
package_version_or_matrix: Union[str, Mapping, None],
repository_file: RepositoryFile,
errors: MutableSet,
) -> None:
Expand All @@ -151,7 +151,7 @@ def recursive_validate_package_entries(
def generate_contents_of_new_release_matrix(
base_release_matrix_content: Mapping,
repofile: RepositoryFile,
upgrade: dict | None,
upgrade: Optional[Dict],
) -> str:
if upgrade:
validate_upgrades(upgrade, repofile)
Expand Down Expand Up @@ -207,7 +207,7 @@ def create_pr_with_changes(
tmp_target: str,
tmp_ref: GitRef,
pr_msg: str,
rhel8: bool | None = False,
rhel8: Optional[bool] = False,
):
commit_title = (
f"Add release {target} (+rhel8)" if rhel8 else f"Add release {target}"
Expand Down Expand Up @@ -258,7 +258,7 @@ def insert_proposals(
git_ref: str,
jobname: str,
joburl: str,
rhel8: bool | None = False,
rhel8: Optional[bool] = False,
) -> None:
tmp_target = target + ".tmp"

Expand All @@ -274,7 +274,7 @@ def insert_proposals(
base_file = f"releases/matrices/{base}.yml"
release_file_yaml_string = load_yaml_from_repo(base_file, repo, git_ref)
release_matrix_file = ReleaseMatrixFile.from_yaml_string(release_file_yaml_string)
upgrade: dict[str, str] = proposal_file.content.get(upgrade_key)
upgrade: Dict[str, str] = proposal_file.content.get(upgrade_key)

repofile_yaml_string = load_yaml_from_repo("repository.yml", repo, git_ref)
repofile = RepositoryFile().from_yaml_string(repofile_yaml_string)
Expand Down
5 changes: 3 additions & 2 deletions komodo/lint_maturity.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import argparse
import os
import warnings
from typing import List

import yaml
from packaging.version import InvalidVersion, Version
Expand Down Expand Up @@ -125,7 +126,7 @@ def get_release_version(release_basename, tag_exceptions_release):
return release_version


def run(files_to_lint: list[str], tag_exceptions):
def run(files_to_lint: List[str], tag_exceptions):
system_exit_msg = ""
system_warning_msg = ""

Expand Down Expand Up @@ -180,7 +181,7 @@ def read_yaml_file_and_convert_to_release_file(release_file_path: str) -> Releas
return ReleaseFile().from_yaml_string(value=release_file_yaml_string)


def get_files_to_lint(release_folder: str, release_file: str) -> list[str]:
def get_files_to_lint(release_folder: str, release_file: str) -> List[str]:
if release_folder is None:
files_to_lint = [release_file]
else:
Expand Down
Loading

0 comments on commit 5e671b9

Please sign in to comment.