From 8529386293108b41b88c9e3a62dcd0b12ba9b8f0 Mon Sep 17 00:00:00 2001 From: Alexandre Vicenzi Date: Tue, 28 May 2024 15:39:36 +0200 Subject: [PATCH] Add Python image README --- src/bci_build/package/python.py | 2 +- src/bci_build/package/python/README.md.j2 | 57 +++++++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 src/bci_build/package/python/README.md.j2 diff --git a/src/bci_build/package/python.py b/src/bci_build/package/python.py index 9c749c676..0744a4d7b 100644 --- a/src/bci_build/package/python.py +++ b/src/bci_build/package/python.py @@ -48,7 +48,7 @@ def _get_python_kwargs(py3_ver: _PYTHON_VERSIONS, os_version: OsVersion): kwargs = { "name": "python", - "pretty_name": f"Python {py3_ver} development", + "pretty_name": f"Python {py3_ver} Development", "version": py3_ver, "additional_versions": ["3"], "env": { diff --git a/src/bci_build/package/python/README.md.j2 b/src/bci_build/package/python/README.md.j2 new file mode 100644 index 000000000..28f082955 --- /dev/null +++ b/src/bci_build/package/python/README.md.j2 @@ -0,0 +1,57 @@ +# {{ image.pretty_name }} Container Image + +{% include 'badges.j2' %} + +## Description + +[Python](https://www.python.org/) is an interpreted, interactive, object-oriented, open-source programming language. It incorporates modules, exceptions, dynamic typing, high-level dynamic data types, and classes. It provides interfaces to many system calls, libraries, and various window systems, and it is extensible in C or C++. It is also usable as an extension language for applications that require programmable interfaces. + +## Usage + +To deploy an application, install dependencies, copy the sources, and configure the application's main script: + +```Dockerfile +FROM {{ image.pretty_reference }} + +WORKDIR /app + +COPY requirements.txt ./ +RUN pip install --no-cache-dir -r requirements.txt + +COPY . . + +CMD [ "python", "./main-script.py" ] +``` + +Build and run the container image: + +```ShellSession +$ podman build -t my-python-app . +$ podman run -it --rm my-python-app +``` + +To run a single script inside a container, use the following command: + +```ShellSession +$ podman run --rm -v "$PWD":/app:Z -w /app {{ image.pretty_reference }} python3 script.py +``` + +## Additional tools + +The following tools are included in the image: + +{% set has_pipx = image.is_opensuse or (image.os_version.is_sle15 and image.version == '3.11') -%} +{% set has_wheel = image.is_opensuse or (image.os_version.is_sle15 and image.version == '3.6') -%} + +- python{{ image.version }}-devel +- python{{ image.version }}-pip +{% if has_pipx -%} +- python{{ image.version }}-pipx +{% endif -%} +{% if has_wheel -%} +- python{{ image.version }}-wheel +{% endif -%} +- curl +- git-core + +{% include 'licensing_and_eula.j2' %}