Skip to content

Commit

Permalink
Add base support for Ubuntu 24.04 and Rocky Linux 9 (#486)
Browse files Browse the repository at this point in the history
  • Loading branch information
samcmill committed May 17, 2024
1 parent ce582fa commit d893840
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 26 deletions.
11 changes: 1 addition & 10 deletions .github/workflows/python3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
include:
- os: macos-latest
python-version: '3.5'
- os: macos-latest
python-version: '3.6'
- os: windows-latest
python-version: '3.5'
- os: windows-latest
python-version: '3.6'
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v2
Expand Down
6 changes: 3 additions & 3 deletions docs/misc_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ __Arguments__


- __distro (string)__: Valid values are `centos7`, `centos8`, `rhel7`,
`rhel8`, `rockylinux8`, `ubuntu16`, `ubuntu18`, `ubuntu20`, and
`ubuntu22`. `ubuntu` is an alias for `ubuntu16`, `centos` is an
alias for `centos7`, and `rhel` is an alias for `rhel7`.
`rhel8`, `rockylinux8`, `rockylinux9`, `ubuntu16`, `ubuntu18`, `ubuntu20`,
`ubuntu22`, and `ubuntu24`. `ubuntu` is an alias for `ubuntu16`, `centos`
is an alias for `centos7`, and `rhel` is an alias for `rhel7`.


## set_singularity_version
Expand Down
10 changes: 5 additions & 5 deletions docs/primitives.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ is `docker` (Singularity specific).

- ___distro__: The underlying Linux distribution of the base image.
Valid values are `centos`, `centos7`, `centos8`, `redhat`, `rhel`,
`rhel7`, `rhel8`, `rockylinux8`, `ubuntu`, `ubuntu16`, `ubuntu18`,
`ubuntu20`, and `ubuntu22`. By default, the primitive attempts to
figure out the Linux distribution by inspecting the image
identifier, and falls back to `ubuntu` if unable to determine the
Linux distribution automatically.
`rhel7`, `rhel8`, `rockylinux8`, `rockylinux9`, `ubuntu`, `ubuntu16`,
`ubuntu18`, `ubuntu20`, `ubuntu22`, and `ubuntu24`. By default, the
primitive attempts to figure out the Linux distribution by inspecting
the image identifier, and falls back to `ubuntu` if unable to determine
the Linux distribution automatically.

- ___docker_env__: Boolean specifying whether to load the Docker base
image environment, i.e., source
Expand Down
12 changes: 9 additions & 3 deletions hpccm/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ def set_linux_distro(distro):
# Arguments
distro (string): Valid values are `centos7`, `centos8`, `rhel7`,
`rhel8`, `rockylinux8`, `ubuntu16`, `ubuntu18`, `ubuntu20`, and
`ubuntu22`. `ubuntu` is an alias for `ubuntu16`, `centos` is an
alias for `centos7`, and `rhel` is an alias for `rhel7`.
`rhel8`, `rockylinux8`, `rockylinux9`, `ubuntu16`, `ubuntu18`, `ubuntu20`,
`ubuntu22`, and `ubuntu24`. `ubuntu` is an alias for `ubuntu16`, `centos`
is an alias for `centos7`, and `rhel` is an alias for `rhel7`.
"""
this = sys.modules[__name__]
Expand All @@ -201,6 +201,9 @@ def set_linux_distro(distro):
elif distro == 'rockylinux8':
this.g_linux_distro = linux_distro.ROCKYLINUX
this.g_linux_version = Version('8.0')
elif distro == 'rockylinux9':
this.g_linux_distro = linux_distro.ROCKYLINUX
this.g_linux_version = Version('9.0')
elif distro == 'ubuntu':
this.g_linux_distro = linux_distro.UBUNTU
this.g_linux_version = Version('16.04')
Expand All @@ -216,6 +219,9 @@ def set_linux_distro(distro):
elif distro == 'ubuntu22':
this.g_linux_distro = linux_distro.UBUNTU
this.g_linux_version = Version('22.04')
elif distro == 'ubuntu24':
this.g_linux_distro = linux_distro.UBUNTU
this.g_linux_version = Version('24.04')
else:
logging.warning('Unable to determine the Linux distribution, defaulting to Ubuntu')
this.g_linux_distro = linux_distro.UBUNTU
Expand Down
16 changes: 11 additions & 5 deletions hpccm/primitives/baseimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ class baseimage(object):
_distro: The underlying Linux distribution of the base image.
Valid values are `centos`, `centos7`, `centos8`, `redhat`, `rhel`,
`rhel7`, `rhel8`, `rockylinux8`, `ubuntu`, `ubuntu16`, `ubuntu18`,
`ubuntu20`, and `ubuntu22`. By default, the primitive attempts to
figure out the Linux distribution by inspecting the image
identifier, and falls back to `ubuntu` if unable to determine the
Linux distribution automatically.
`rhel7`, `rhel8`, `rockylinux8`, `rockylinux9`, `ubuntu`, `ubuntu16`,
`ubuntu18`, `ubuntu20`, `ubuntu22`, and `ubuntu24`. By default, the
primitive attempts to figure out the Linux distribution by inspecting
the image identifier, and falls back to `ubuntu` if unable to determine
the Linux distribution automatically.
_docker_env: Boolean specifying whether to load the Docker base
image environment, i.e., source
Expand Down Expand Up @@ -135,12 +135,16 @@ def __init__(self, **kwargs):
hpccm.config.set_linux_distro('rhel8')
elif self.__distro == 'rockylinux8':
hpccm.config.set_linux_distro('rockylinux8')
elif self.__distro == 'rockylinux9':
hpccm.config.set_linux_distro('rockylinux9')
elif re.search(r'centos:?7', self.image):
hpccm.config.set_linux_distro('centos7')
elif re.search(r'centos:?8', self.image):
hpccm.config.set_linux_distro('centos8')
elif re.search(r'rockylinux:?8', self.image):
hpccm.config.set_linux_distro('rockylinux8')
elif re.search(r'rockylinux:?9', self.image):
hpccm.config.set_linux_distro('rockylinux9')
elif re.search(r'centos|rhel|redhat', self.image):
hpccm.config.set_linux_distro('centos')
elif re.search(r'ubi:?7', self.image):
Expand All @@ -155,6 +159,8 @@ def __init__(self, **kwargs):
hpccm.config.set_linux_distro('ubuntu20')
elif re.search(r'ubuntu:?22', self.image):
hpccm.config.set_linux_distro('ubuntu22')
elif re.search(r'ubuntu:?24', self.image):
hpccm.config.set_linux_distro('ubuntu24')
elif re.search(r'ubuntu', self.image):
hpccm.config.set_linux_distro('ubuntu')
else:
Expand Down
20 changes: 20 additions & 0 deletions test/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,21 @@ def test_set_linux_distro_ubuntu(self):
hpccm.linux_distro.UBUNTU)
self.assertEqual(hpccm.config.g_linux_version, Version('18.04'))

hpccm.config.set_linux_distro('ubuntu20')
self.assertEqual(hpccm.config.g_linux_distro,
hpccm.linux_distro.UBUNTU)
self.assertEqual(hpccm.config.g_linux_version, Version('20.04'))

hpccm.config.set_linux_distro('ubuntu22')
self.assertEqual(hpccm.config.g_linux_distro,
hpccm.linux_distro.UBUNTU)
self.assertEqual(hpccm.config.g_linux_version, Version('22.04'))

hpccm.config.set_linux_distro('ubuntu24')
self.assertEqual(hpccm.config.g_linux_distro,
hpccm.linux_distro.UBUNTU)
self.assertEqual(hpccm.config.g_linux_version, Version('24.04'))

@docker
def test_set_linux_distro_centos(self):
"""Set Linux distribution to CentOS"""
Expand Down Expand Up @@ -112,6 +127,11 @@ def test_set_linux_distro_rockylinux(self):
hpccm.linux_distro.ROCKYLINUX)
self.assertEqual(hpccm.config.g_linux_version, Version('8.0'))

hpccm.config.set_linux_distro('rockylinux9')
self.assertEqual(hpccm.config.g_linux_distro,
hpccm.linux_distro.ROCKYLINUX)
self.assertEqual(hpccm.config.g_linux_version, Version('9.0'))

@docker
def test_set_linux_distro_invalid(self):
"""Set Linux distribution to an invalid value"""
Expand Down

0 comments on commit d893840

Please sign in to comment.