From 7515cf5e001fc1ab8d9f82bf6fbd8ef9c2870dca Mon Sep 17 00:00:00 2001
From: Pierre Smeyers <pierre.smeyers@gmail.com>
Date: Tue, 8 Feb 2022 08:52:11 +0100
Subject: [PATCH] chore: support auto value for $PYTHON_BUILD_SYSTEM

---
 README.md                      |  2 +-
 kicker.json                    |  3 ++-
 templates/gitlab-ci-python.yml | 47 +++++++++++++++++-----------------
 3 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/README.md b/README.md
index 4a47516..02f8d9f 100644
--- a/README.md
+++ b/README.md
@@ -42,7 +42,7 @@ and/or `setup.py` and/or `requirements.txt`), but the build system might also be
 
 | Value            | Build System (scope)                                       |
 | ---------------- | ---------------------------------------------------------- |
-| _none_ (default) | The template tries to **auto-detect** the actual build system |
+| _none_ (default) or `auto` | The template tries to **auto-detect** the actual build system |
 | `setuptools`     | [Setuptools](https://setuptools.pypa.io/) (dependencies, build & packaging) |
 | `poetry`         | [Poetry](https://python-poetry.org/) (dependencies, build, test & packaging) |
 | `pipenv`         | [Pipenv](https://pipenv.pypa.io/) (dependencies only) |
diff --git a/kicker.json b/kicker.json
index 35d8ab8..9c5a058 100644
--- a/kicker.json
+++ b/kicker.json
@@ -18,7 +18,8 @@
       "name": "PYTHON_BUILD_SYSTEM",
       "description": "Python build-system to use to install dependencies, build and package the project",
       "type": "enum",
-      "values": ["", "setuptools", "poetry", "reqfile"],
+      "values": ["auto", "setuptools", "poetry", "pipenv", "reqfile"],
+      "default": "auto",
       "advanced": true
     },
     {
diff --git a/templates/gitlab-ci-python.yml b/templates/gitlab-ci-python.yml
index 9ac4503..4e08b3a 100644
--- a/templates/gitlab-ci-python.yml
+++ b/templates/gitlab-ci-python.yml
@@ -215,30 +215,29 @@ variables:
   }
 
   function guess_build_system() {
-    if [[ "$PYTHON_BUILD_SYSTEM" ]]
-    then
-      case "$PYTHON_BUILD_SYSTEM" in
-      poetry)
-        log_info "--- Build system explictly declared: Poetry"
-        return
-        ;;
-      setuptools)
-        log_info "--- Build system explictly declared: Setuptools"
-        return
-        ;;
-      pipenv)
-        log_info "--- Build system explictly declared: Pipenv"
-        return
-        ;;
-      reqfile)
-        log_info "--- Build system explictly declared: requirements file"
-        return
-        ;;
-      *)
-        log_warn "--- Unknown declared build system: \\e[33;1m${PYTHON_BUILD_SYSTEM}\\e[0m: please read template doc"
-        ;;
-      esac
-    fi
+    case "${PYTHON_BUILD_SYSTEM:-auto}" in
+    auto)
+      ;;
+    poetry)
+      log_info "--- Build system explictly declared: Poetry"
+      return
+      ;;
+    setuptools)
+      log_info "--- Build system explictly declared: Setuptools"
+      return
+      ;;
+    pipenv)
+      log_info "--- Build system explictly declared: Pipenv"
+      return
+      ;;
+    reqfile)
+      log_info "--- Build system explictly declared: requirements file"
+      return
+      ;;
+    *)
+      log_warn "--- Unknown declared build system: \\e[33;1m${PYTHON_BUILD_SYSTEM}\\e[0m: please read template doc"
+      ;;
+    esac
 
     if [[ -f "pyproject.toml" ]]
     then
-- 
GitLab