From a3c666e177532e4043b9b2149e6538c25040b027 Mon Sep 17 00:00:00 2001 From: native-api Date: Thu, 24 Sep 2026 00:12:25 +0300 Subject: [PATCH] install-prerequisites: add an option for optional dependencies (#3560) --- .../bin/pyenv-install-prerequisites | 29 +++++++++++++---- .../test/install-prerequisites.bats | 32 ++++++++++++++----- 2 files changed, 47 insertions(+), 14 deletions(-) diff --git a/plugins/python-build/bin/pyenv-install-prerequisites b/plugins/python-build/bin/pyenv-install-prerequisites index c56bbd98..53d25ad4 100755 --- a/plugins/python-build/bin/pyenv-install-prerequisites +++ b/plugins/python-build/bin/pyenv-install-prerequisites @@ -2,13 +2,16 @@ # # Summary: Install Python build prerequisites on Debian-based systems # -# Usage: pyenv install-prerequisites +# Usage: pyenv install-prerequisites [-a|--all] +# +# -a/--all Also install optional dependencies (for rarely used modules) # set -e [ -n "$PYENV_DEBUG" ] && set -x # Provide pyenv completions if [ "$1" = "--complete" ]; then + echo --all exit fi @@ -17,11 +20,22 @@ usage() { [ -z "$1" ] || exit "$1" } -if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then - usage 0 -fi +all= -[ "$#" -eq 0 ] || usage 1 >&2 +while (($#)); do + case "$1" in + -h|--help) + usage 0 + ;; + -a|--all) + all=1 + ;; + *) + usage 1 >&2 + ;; + esac + shift +done if ! command -v apt-get >/dev/null; then echo "pyenv: installing build prerequisites is not supported on this system" >&2 @@ -33,6 +47,9 @@ prerequisites=( libsqlite3-dev curl git llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev libzstd-dev ) +optional=( + libgdbm-dev +) if [ "$(id -u)" -eq 0 ]; then apt_get=(apt-get) @@ -44,4 +61,4 @@ else fi "${apt_get[@]}" update -q -"${apt_get[@]}" install -yq "${prerequisites[@]}" +"${apt_get[@]}" install -yq "${prerequisites[@]}" ${all:+"${optional[@]}"} diff --git a/plugins/python-build/test/install-prerequisites.bats b/plugins/python-build/test/install-prerequisites.bats index 2630c238..8cbe2205 100644 --- a/plugins/python-build/test/install-prerequisites.bats +++ b/plugins/python-build/test/install-prerequisites.bats @@ -4,18 +4,21 @@ load test_helper _setup() { prerequisites="make build-essential libssl-dev zlib1g-dev libbz2-dev \ -libreadline-dev libsqlite3-dev curl git llvm libncurses5-dev \ -libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev \ -liblzma-dev libzstd-dev" + libreadline-dev libsqlite3-dev curl git llvm libncurses5-dev \ + libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev \ + liblzma-dev libzstd-dev" + + optional="libgdbm-dev" } -@test "completion does not install packages" { +@test "completions" { stub apt-get - PATH="${BATS_TEST_DIRNAME}/../../../libexec:$PATH" \ - run pyenv completions install-prerequisites + run pyenv-install-prerequisites --complete - assert_success "--help" + assert_success <