Commit 88ee027b authored by Gaëtan Montury's avatar Gaëtan Montury
Browse files

fix(refactor): simplify management of multiple build systems by using case...

fix(refactor): simplify management of multiple build systems by using case statements for improved readability and maintainability
parent 43cdd442
Loading
Loading
Loading
Loading
+28 −37
Original line number Diff line number Diff line
@@ -786,21 +786,15 @@ variables:
  }

  function _run() {
    if [[ "$PYTHON_BUILD_SYSTEM" =~ ^poetry ]]
    then
      maybe_install_build_system
      poetry run "$@"
    elif [[ "$PYTHON_BUILD_SYSTEM" =~ ^uv ]]
    then
      maybe_install_build_system
      uv run "$@"
    elif [[ "$PYTHON_BUILD_SYSTEM" =~ ^hatch ]]
    then
    case "$PYTHON_BUILD_SYSTEM" in
      poetry*|uv*|hatch*)
        maybe_install_build_system
        $PYTHON_BUILD_SYSTEM_CMD run "$@"
    else
        ;;
      *)
        "$@"
    fi
        ;;
    esac
  }

  function _python() {
@@ -825,30 +819,27 @@ variables:
  function py_package() {
    _start_time=$(get_current_ts_ms)

    # clean reports for this job but there not impact on other jobs
    # clean reports for this job but no impact on other jobs
    rm -fr "$PYTHON_PROJECT_DIR/reports"

    if [[ "$PYTHON_BUILD_SYSTEM" =~ ^poetry ]]
    then
    case "$PYTHON_BUILD_SYSTEM" in
      poetry*|uv*)
        maybe_install_build_system
      log_info "--- build packages (poetry)..."
      poetry build ${TRACE+--verbose}
    elif [[ "$PYTHON_BUILD_SYSTEM" =~ ^uv ]]
    then
        log_info "--- build packages ($PYTHON_BUILD_SYSTEM_CMD)..."
        $PYTHON_BUILD_SYSTEM_CMD build ${TRACE+--verbose}
        ;;
      hatch*)
        maybe_install_build_system
      log_info "--- build packages (uv)..."
      uv build ${TRACE+--verbose}
    elif [[ "$PYTHON_BUILD_SYSTEM" =~ ^hatch ]]
    then
        log_info "--- build packages (hatch)..."
      maybe_install_build_system
        $PYTHON_BUILD_SYSTEM_CMD build
    else
        ;;
      *)
        log_info "--- build packages ..."
        # shellcheck disable=SC2086
        pip install ${PIP_OPTS} build
        python -m build
    fi
        ;;
    esac

    log_elapsed_time "py_package" "$_start_time"
  }