Skip to content

Commit

Permalink
Make komodo RHEL agnostic
Browse files Browse the repository at this point in the history
  • Loading branch information
pinkwah committed Jan 10, 2024
1 parent 423fa31 commit 81dd696
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 168 deletions.
8 changes: 0 additions & 8 deletions docs/komodo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,6 @@ komodo.snyk\_reporting module
:undoc-members:
:show-inheritance:

komodo.switch module
--------------------

.. automodule:: komodo.switch
:members:
:undoc-members:
:show-inheritance:

komodo.yaml\_file\_type module
------------------------------

Expand Down
1 change: 0 additions & 1 deletion komodo/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import jinja2
from ruamel.yaml import YAML

from komodo import switch
from komodo.build import make
from komodo.data import Data
from komodo.fetch import fetch
Expand Down
12 changes: 0 additions & 12 deletions komodo/data/activator_switch.csh.tmpl

This file was deleted.

10 changes: 0 additions & 10 deletions komodo/data/activator_switch.tmpl

This file was deleted.

17 changes: 7 additions & 10 deletions komodo/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,33 @@
handling an arbitrary large and funky matrix, without having to guess and/or
repeat itself.
"""
import itertools
import re
from typing import Iterator, Sequence, Tuple
from typing import Iterable, Sequence


def get_matrix(
rhel_versions: Sequence[str],
py_versions: Sequence[str],
) -> Iterator[Tuple[str, str]]:
) -> Iterable[str]:
"""Return tuples of rhel version and Python version, representing the
current release matrix.
"""
for product in itertools.product(rhel_versions, py_versions):
rh_ver, py_ver = product
yield (f"rhel{rh_ver}", f"py{str(py_ver).replace('.', '')}")
for py_ver in py_versions:
yield f"py{str(py_ver).replace('.', '')}"


def format_release(base: str, rhel_ver: str, py_ver: str) -> str:
def format_release(base: str, py_ver: str) -> str:
"""Format a base (e.g. a matrix file without the .yml suffix) such that it
looks like a concrete release.
"""
return f"{base}-{py_ver}-{rhel_ver}"
return f"{base}-{py_ver}"


def get_matrix_base(release_name: str) -> str:
"""Return the base (e.g. matrix part of a concrete release). Should be the
inverse of format_release for actual, concrete matrix releases.
Hard-coded the suffix pattern '-py..-rhel.' or '-py...-rhel.'.
"""
suffix = format_release("", "rhel[0-9]", r"py\d{2,3}")
suffix = format_release("", r"py\d{2,3}")
if re.search(suffix, release_name):
return re.split(suffix, release_name)[0]
# no matrix suffix at all
Expand Down
6 changes: 2 additions & 4 deletions komodo/release_transpiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,19 +145,17 @@ def transpile_releases(matrix_file: str, output_folder: str, matrix: dict) -> No
Write one dimension file for each element in the matrix
(e.g. rhel7 and py3.8, rhel6 and py3.6).
"""
rhel_versions = matrix["rhel"]
python_versions = matrix["py"]

release_base = os.path.splitext(os.path.basename(matrix_file))[0]
release_folder = os.path.dirname(matrix_file)
release_matrix = load_yaml(f"{os.path.join(release_folder, release_base)}.yml")
for rhel_ver, py_ver in get_matrix(rhel_versions, python_versions):
for py_ver in get_matrix(python_versions):
release_dict = _pick_package_versions_for_release(
release_matrix,
rhel_ver,
py_ver,
)
filename = f"{format_release(release_base, rhel_ver, py_ver)}.yml"
filename = f"{format_release(release_base, py_ver)}.yml"
write_to_file(release_dict, os.path.join(output_folder, filename))


Expand Down
2 changes: 1 addition & 1 deletion komodo/show_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def get_komodo_path(release: str) -> Path:
"""Use the release name to find the 'real' release path in an ordinary
komodo environment. E.g., the release may be something like
'2023.01.02-py38' but the 'real' release (where the release manifest
is stored) might be platform-specific, e.g. '2023.01.02-py38-rhel7'.
is stored) might be platform-specific, e.g. '2023.01.02-py38'.
The real path is in the PATH, so we try to get it from there.
Args:
Expand Down
56 changes: 0 additions & 56 deletions komodo/switch.py

This file was deleted.

7 changes: 3 additions & 4 deletions komodo/yaml_file_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,9 @@ def lint_release_name(packagefile_path: str) -> List[komodo_error]:
relname = os.path.basename(packagefile_path)
found = False
for py_suffix in "-py27", "-py36", "-py38", "-py310":
for rh_suffix in "", "-rhel6", "-rhel7", "-rhel8":
if relname.endswith(py_suffix + rh_suffix + ".yml"):
found = True
break
if relname.endswith(f"{py_suffix}.yml"):
found = True
break
if not found:
return [
_komodo_error(
Expand Down
58 changes: 0 additions & 58 deletions tests/test_switch.py

This file was deleted.

5 changes: 1 addition & 4 deletions tests/test_yaml_file_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,9 @@ def test_release_file_yaml_type(content, expectations):
"valid",
(
"bleeding-py36.yml",
"/home/anyuser/komodo/2020.01.03-py36-rhel6.yml",
"/home/anyuser/komodo/2020.01.03-py36.yml",
"myrelease-py36.yml",
"myrelease-py310.yml",
"myrelease-py310-rhel8.yml",
"myrelease-py36-rhel6.yml",
"myrelease-py36-rhel7.yml",
),
)
def test_release_name_valid(valid):
Expand Down

0 comments on commit 81dd696

Please sign in to comment.