From 41e3c1337ccbe3f645a5b7b5e4da41eca6401c8a Mon Sep 17 00:00:00 2001 From: "Gerard Castillo Lasheras (BI X)" Date: Fri, 16 Aug 2024 12:10:11 +0200 Subject: [PATCH] #1030 - Support for Python3.12, and maintenance of be-python-flask quickstarter and python Jenkins agent --- CHANGELOG.md | 1 + be-python-flask/Jenkinsfile.template | 4 ++-- be-python-flask/files/docker/Dockerfile | 2 +- be-python-flask/files/requirements.txt | 4 ++-- be-python-flask/files/tests_requirements.txt | 8 ++++---- .../jenkins-agents/python/docker/Dockerfile.ubi8 | 5 +++-- docs/modules/jenkins-agents/pages/python.adoc | 2 +- .../quickstarters/pages/be-python-flask.adoc | 16 ++++++++-------- 8 files changed, 22 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 121227873..6063cf7ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Update Rust Axum Quickstarter ([#1024](https://github.com/opendevstack/ods-quickstarters/pull/1024)) - Gitleaks docs fix and update ([#1028](https://github.com/opendevstack/ods-quickstarters/issues/1028)) - Enable OpenSSL vendored compilation for Rust Jenkins Agent ([#1026](https://github.com/opendevstack/ods-quickstarters/pull/1026)) +- Support for Python3.12, and maintenance of be-python-flask quickstarter and python Jenkins agent ([#1030](https://github.com/opendevstack/ods-quickstarters/pull/1030)) ### Added diff --git a/be-python-flask/Jenkinsfile.template b/be-python-flask/Jenkinsfile.template index 4fe1df37a..7cd51a5ff 100644 --- a/be-python-flask/Jenkinsfile.template +++ b/be-python-flask/Jenkinsfile.template @@ -29,7 +29,7 @@ def stageTestSuite(def context) { stage('Prepare Test Suite') { sh """ - python3.11 -m venv testsuite + python3.12 -m venv testsuite . ./testsuite/bin/activate pip install -r tests_requirements.txt pip check @@ -50,7 +50,7 @@ def stageTestSuite(def context) { def status = sh( script: """ . ./testsuite/bin/activate - PYTHONPATH=src python3.11 -m pytest --junitxml=tests.xml -o junit_family=xunit2 --cov-report term-missing --cov-report xml --cov=src -o testpaths=tests + PYTHONPATH=src python3.12 -m pytest --junitxml=tests.xml -o junit_family=xunit2 --cov-report term-missing --cov-report xml --cov=src -o testpaths=tests mv tests.xml ${testLocation} mv coverage.xml ${coverageLocation} mv .coverage ${coverageLocation} diff --git a/be-python-flask/files/docker/Dockerfile b/be-python-flask/files/docker/Dockerfile index 66a1b5e30..3ea80b68c 100644 --- a/be-python-flask/files/docker/Dockerfile +++ b/be-python-flask/files/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM registry.access.redhat.com/ubi9/python-311 +FROM registry.access.redhat.com/ubi9/python-312 ARG nexusHostWithBasicAuth ARG nexusHostWithoutScheme diff --git a/be-python-flask/files/requirements.txt b/be-python-flask/files/requirements.txt index 2cde62dfb..759914d9a 100644 --- a/be-python-flask/files/requirements.txt +++ b/be-python-flask/files/requirements.txt @@ -1,2 +1,2 @@ -gunicorn==21.2.0 -flask==3.0.0 +gunicorn==23.0.0 +flask==3.0.3 diff --git a/be-python-flask/files/tests_requirements.txt b/be-python-flask/files/tests_requirements.txt index c5252edcf..97598f743 100644 --- a/be-python-flask/files/tests_requirements.txt +++ b/be-python-flask/files/tests_requirements.txt @@ -1,6 +1,6 @@ -r ./requirements.txt -mypy==1.7.1 -flake8==6.1.0 -pytest==7.4.3 -pytest-cov==4.1.0 +mypy==1.11.1 +flake8==7.1.1 +pytest==8.3.2 +pytest-cov==5.0.0 diff --git a/common/jenkins-agents/python/docker/Dockerfile.ubi8 b/common/jenkins-agents/python/docker/Dockerfile.ubi8 index d2f2f0c19..bed9a16f7 100644 --- a/common/jenkins-agents/python/docker/Dockerfile.ubi8 +++ b/common/jenkins-agents/python/docker/Dockerfile.ubi8 @@ -13,10 +13,11 @@ ENV PYTHONUNBUFFERED=1 \ RUN yum module install -y python38:3.8/build && \ yum module install -y python39:3.9/build --allowerasing && \ yum install -y python3.11 python3.11-pip python3.11-devel python3.11-setuptools --allowerasing && \ + yum install -y python3.12 python3.12-pip python3.12-devel python3.12-setuptools --allowerasing && \ yum install -y autoconf automake gcc-c++ openssl-devel libffi-devel && \ yum -y clean all -RUN pipVersions=( pip3.8 pip3.9 pip3.11 ); \ +RUN pipVersions=( pip3.8 pip3.9 pip3.11 pip3.12 ); \ for pipV in "${pipVersions[@]}"; \ do \ if [ ! -z ${nexusHost} ] && [ ! -z ${nexusAuth} ]; \ @@ -26,7 +27,7 @@ RUN pipVersions=( pip3.8 pip3.9 pip3.11 ); \ fi; \ $pipV config set global.cert /etc/ssl/certs/ca-bundle.crt && \ $pipV install --upgrade pip --user && \ - $pipV install virtualenv==20.25.0 setuptools==69.0.2 Cython==3.0.6 pypandoc==1.12; \ + $pipV install virtualenv==20.26.3 setuptools==72.2.0 Cython==3.0.11 pypandoc==1.13; \ done; # Enables default user to access $HOME folder diff --git a/docs/modules/jenkins-agents/pages/python.adoc b/docs/modules/jenkins-agents/pages/python.adoc index 80587bc61..27287aaa6 100644 --- a/docs/modules/jenkins-agents/pages/python.adoc +++ b/docs/modules/jenkins-agents/pages/python.adoc @@ -6,7 +6,7 @@ This agent is used to build / execute Python code. The image is built in the global `ods` project and is named `jenkins-agent-python`. It can be referenced in a `Jenkinsfile` with `ods/jenkins-agent-python`. -It supports building on **Python** versions: **3.11, 3.9, 3.8 and 3.6**. +It supports building on **Python** versions: **3.12 (default), 3.11, 3.9, 3.8 and 3.6**. **NOTE**: Python 3.6 have reached EOL on 2021-12-23. See https://devguide.python.org/versions/[Python versions] for further information. diff --git a/docs/modules/quickstarters/pages/be-python-flask.adoc b/docs/modules/quickstarters/pages/be-python-flask.adoc index 75b25e7e3..0651760fc 100644 --- a/docs/modules/quickstarters/pages/be-python-flask.adoc +++ b/docs/modules/quickstarters/pages/be-python-flask.adoc @@ -35,7 +35,7 @@ It contains the basic setup for Docker, Jenkins, SonarQube and OpenShift. == Frameworks used -* https://docs.python.org/3.11[Python 3.11] +* https://docs.python.org/3.12[Python 3.12] * https://gunicorn.org/[gunicorn] * http://flask.pocoo.org/[flask] * https://docs.pytest.org/en/stable/[pytest] @@ -48,9 +48,9 @@ The project is production ready when deployed in OpenShift thanks to gunicorn. It is strongly recommended when you are developing a Python project to use separated environments. For this purpose usually one can use Python's -https://docs.python.org/3.11/library/venv.html[venv] core package (check how to use it in the next steps). +https://docs.python.org/3.12/library/venv.html[venv] core package (check how to use it in the next steps). -NOTE: since the version of Python is 3.11, ensure your system's python executable is also in version 3.11 +NOTE: since the version of Python is 3.12, ensure your system's python executable is also in version 3.12 [source,bash] ---- @@ -118,18 +118,18 @@ include::partials$secret-scanning-with-gitleaks.adoc This quickstarter uses https://github.com/opendevstack/ods-quickstarters/tree/master/common/jenkins-agents/python[Python] builder agent Jenkins builder agent. -**NOTE**: The ODS Jenkins Pytnon Agent supports Python versions 3.11, 3.9 and 3.8. See next chapter for further information. +**NOTE**: The ODS Jenkins Python Agent supports Python versions 3.12, 3.11, 3.9 and 3.8. See next chapter for further information. == Multiple Python versions support -Build and run environment defaults to python3.11, but older python3.8 and python3.6 versions are also supported. +Build and run environment defaults to python3.12, but python3.11, python3.9 and python3.8 versions are also supported. -If you need older versions support in your project, change: +If you need other versions support in your project, change: -* in the provided `Jenkinsfile`, the mentions of `python3.11` binary to, for example, `python3.9` binary, +* in the provided `Jenkinsfile`, the mentions of `python3.12` binary to, for example, `python3.9` binary, -* and switch the `FROM` statement in your `Dockerfile` to the python version required, for example, `registry.access.redhat.com/ubi8/python-38`. +* and switch the `FROM` statement in your `Dockerfile` to the python version required, for example, `registry.access.redhat.com/ubi8/python-39`. == Known limitations