Skip to content

Commit

Permalink
#1030 - Support for Python3.12, and maintenance of be-python-flask qu…
Browse files Browse the repository at this point in the history
…ickstarter and python Jenkins agent
  • Loading branch information
gerardcl committed Aug 16, 2024
1 parent 5f78681 commit 41e3c13
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions be-python-flask/Jenkinsfile.template
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion be-python-flask/files/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM registry.access.redhat.com/ubi9/python-311
FROM registry.access.redhat.com/ubi9/python-312

ARG nexusHostWithBasicAuth
ARG nexusHostWithoutScheme
Expand Down
4 changes: 2 additions & 2 deletions be-python-flask/files/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
gunicorn==21.2.0
flask==3.0.0
gunicorn==23.0.0
flask==3.0.3
8 changes: 4 additions & 4 deletions be-python-flask/files/tests_requirements.txt
Original file line number Diff line number Diff line change
@@ -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
5 changes: 3 additions & 2 deletions common/jenkins-agents/python/docker/Dockerfile.ubi8
Original file line number Diff line number Diff line change
Expand Up @@ -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} ]; \
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/jenkins-agents/pages/python.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
16 changes: 8 additions & 8 deletions docs/modules/quickstarters/pages/be-python-flask.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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]
----
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 41e3c13

Please sign in to comment.