diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 11159b6..b1c643c 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -11,9 +11,8 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, macos-13, windows-latest] - python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] - + os: [ubuntu-latest, macos-latest, windows-latest] + python-version: ['3.11', '3.12', '3.13'] steps: - uses: actions/checkout@v6 with: diff --git a/Dockerfile b/Dockerfile index 10b05fa..7819a6f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ -ARG CUDA_VERSION="11.7.1" +ARG CUDA_VERSION="13.2.1" -FROM nvidia/cuda:${CUDA_VERSION}-devel-ubuntu22.04 +FROM nvidia/cuda:${CUDA_VERSION}-devel-ubuntu24.04 SHELL ["/bin/bash", "-c"] @@ -12,8 +12,8 @@ RUN set -Eeuxo pipefail && \ apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \ tzdata && \ - echo "${TIMEZONE}" > /etc/timezone && \ - cp "/usr/share/zoneinfo/${TIMEZONE}" /etc/localtime && \ + echo "${TIMEZONE}" > "/etc/timezone" && \ + ln -nfs "/usr/share/zoneinfo/${TIMEZONE}" "/etc/localtime" && \ apt-get -qy autoremove && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* @@ -25,10 +25,12 @@ ARG GROUP_ID=1000 ARG AUX_GROUP_IDS="" RUN set -Eeuxo pipefail && \ - (addgroup --gid "${GROUP_ID}" user || echo "group ${GROUP_ID} already exists, so not adding it") && \ - adduser --disabled-password --gecos "User" --uid "${USER_ID}" --gid "${GROUP_ID}" user && \ + if id "${USER_ID}" >/dev/null 2>&1; then deluser $(id -un "${USER_ID}"); fi && \ + if getent group "${GROUP_ID}" >/dev/null 2>&1; then delgroup $(getent group "${GROUP_ID}" | cut -d: -f1); fi && \ + addgroup --gid "${GROUP_ID}" "user" && \ + adduser --disabled-password --gecos "User" --uid "${USER_ID}" --gid "${GROUP_ID}" "user" && \ echo ${AUX_GROUP_IDS} | xargs -n1 echo | xargs -I% addgroup --gid % group% && \ - echo ${AUX_GROUP_IDS} | xargs -n1 echo | xargs -I% usermod --append --groups group% user + echo ${AUX_GROUP_IDS} | xargs -n1 echo | xargs -I% usermod --append --groups group% "user" # install dependencies @@ -58,11 +60,17 @@ WORKDIR /home/user/system-query COPY --chown=${USER_ID}:${GROUP_ID} requirements*.txt ./ +USER user + RUN set -Eeuxo pipefail && \ + python3 -m venv --prompt "$(basename ${PWD})" /home/user/venv && \ + source /home/user/venv/bin/activate && \ pip3 install --no-cache-dir -r requirements_ci.txt # add user to sudoers +USER root + RUN set -Eeuxo pipefail && \ usermod --append --groups sudo user && \ echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers diff --git a/Jenkinsfile b/Jenkinsfile index 1562f8a..eef8411 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -30,6 +30,7 @@ pipeline { steps { sh """#!/usr/bin/env bash set -Eeux + source /home/user/venv/bin/activate python3 -m pylint ${PYTHON_MODULES} |& tee pylint.log echo "\${PIPESTATUS[0]}" | tee pylint_status.log python3 -m mypy ${PYTHON_MODULES} |& tee mypy.log @@ -48,6 +49,7 @@ pipeline { steps { sh '''#!/usr/bin/env bash set -Eeuxo pipefail + source /home/user/venv/bin/activate python3 -m coverage run --branch --source . -m unittest -v pip3 install --no-cache-dir -r requirements_all.txt python3 -m coverage run --append --branch --source . -m unittest -v @@ -60,6 +62,7 @@ pipeline { steps { sh '''#!/usr/bin/env bash set -Eeux + source /home/user/venv/bin/activate python3 -m coverage report --show-missing |& tee coverage.log echo "${PIPESTATUS[0]}" | tee coverage_status.log ''' @@ -80,6 +83,7 @@ pipeline { steps { sh '''#!/usr/bin/env bash set -Eeuxo pipefail + source /home/user/venv/bin/activate python3 -m codecov --token ${CODECOV_TOKEN} ''' } @@ -93,7 +97,7 @@ pipeline { } } environment { - VERSION = sh(script: 'python3 -m version_query --predict .', returnStdout: true).trim() + VERSION = sh(script: 'source /home/user/venv/bin/activate && python3 -m version_query --predict .', returnStdout: true).trim() PYPI_AUTH = credentials('mbdev-pypi-auth') TWINE_USERNAME = "${PYPI_AUTH_USR}" TWINE_PASSWORD = "${PYPI_AUTH_PSW}" @@ -114,7 +118,7 @@ pipeline { buildingTag() } environment { - VERSION = sh(script: 'python3 -m version_query .', returnStdout: true).trim() + VERSION = sh(script: 'source /home/user/venv/bin/activate && python3 -m version_query .', returnStdout: true).trim() } steps { script { diff --git a/README.rst b/README.rst index 03df200..b973c12 100644 --- a/README.rst +++ b/README.rst @@ -337,7 +337,7 @@ Please use ``-h`` to see usage information: Requirements ============ -Python version 3.9 or later. +Python version 3.11 or later. Python libraries as specified in ``_. Recommended (but optional) packages are listed in ``_. diff --git a/setup.py b/setup.py index 511ec99..631ad82 100644 --- a/setup.py +++ b/setup.py @@ -20,8 +20,6 @@ class Package(boilerplates.setup.Package): 'Operating System :: MacOS', 'Operating System :: Microsoft :: Windows', 'Operating System :: POSIX :: Linux', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', 'Programming Language :: Python :: 3.12', 'Programming Language :: Python :: 3.13', diff --git a/system_query/available_features.py b/system_query/available_features.py index 8e53531..090251d 100644 --- a/system_query/available_features.py +++ b/system_query/available_features.py @@ -28,7 +28,7 @@ psutil = None # type: ignore _LOG.info("unable to import package psutil", exc_info=True) -CPU_CLOCK = psutil is not None +CPU_CLOCK = psutil is not None and hasattr(psutil, 'cpu_freq') CPU_CORES = psutil is not None _GPU_FAILED = False diff --git a/system_query/cpu_info.py b/system_query/cpu_info.py index 79b63f1..424ba51 100644 --- a/system_query/cpu_info.py +++ b/system_query/cpu_info.py @@ -53,6 +53,9 @@ def _get_cache_size(level: int, cpuinfo_data: dict) -> t.Optional[int]: value = ureg(raw_value) if isinstance(value, int): return value * 1024 + assert isinstance(value, pint.Quantity), (type(value), value) + if value.units == ureg('1').units: + return value.magnitude * 1024 _LOG.debug('L%i cache size parsed by pint: "%s" -> %s', level, raw_value, value) value = value.to('bytes') return int(value.magnitude) diff --git a/test/__init__.py b/test/__init__.py index 7bce5d2..3aad969 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -8,7 +8,7 @@ class TestsLogging(Logging): """Test logging configuration.""" - level_package = logging.DEBUG + level_global = logging.DEBUG TestsLogging.configure()