diff --git a/plugins/pyenv-binary/README.md b/plugins/pyenv-binary/README.md index 5e3ba20a..817e9a6f 100644 --- a/plugins/pyenv-binary/README.md +++ b/plugins/pyenv-binary/README.md @@ -16,7 +16,7 @@ and dependency metadata exist to catch that. ## Commands -### `pyenv binary package [:] --archive-base-url ` +### `pyenv binary package [-v|--verbose] [:] --archive-base-url ` Installs `` from source under a separate name, packages that install with `save`, then emits a python-build definition for it with @@ -24,6 +24,8 @@ with `save`, then emits a python-build definition for it with current platform, platform version and architecture. An explicit entry keeps the existing custom-build workflow. +Pass `-v` to show build progress from `pyenv install`. + ```sh pyenv binary package 3.12.7 \ --archive-base-url https://example.com/binaries diff --git a/plugins/pyenv-binary/libexec/pyenv-binary-package b/plugins/pyenv-binary/libexec/pyenv-binary-package index 88a0283f..4c6592bc 100755 --- a/plugins/pyenv-binary/libexec/pyenv-binary-package +++ b/plugins/pyenv-binary/libexec/pyenv-binary-package @@ -2,7 +2,7 @@ # # Summary: Create an installable binary package from a Python version # -# Usage: pyenv binary package [:] --archive-base-url +# Usage: pyenv binary package [-v|--verbose] [:] --archive-base-url # # Installs from source under a separate entry name, saves it as a # binary package, then emits a python-build definition for that package. @@ -13,6 +13,7 @@ # The optional name to build under and install the # binary as. If omitted, a name is generated from the # current platform, platform version and architecture. +# -v,--verbose Show build progress from `pyenv install'. # --archive-base-url # Where the archive will be hosted; the definition # downloads it from /.tar.gz. @@ -23,23 +24,29 @@ set -e # Provide pyenv completions if [ "$1" = "--complete" ]; then echo --archive-base-url + echo --verbose exec pyenv-install --list --bare fi spec="" archive_base_url="" +verbose="" while [ $# -gt 0 ]; do case "$1" in --archive-base-url ) - [ $# -ge 2 ] || { echo "pyenv-binary: --archive-base-url needs a value" >&2; exit 1; } - archive_base_url="$2"; shift 2 ;; + [ $# -lt 2 ] && { echo "pyenv-binary: --archive-base-url needs a value" >&2; exit 1; } + archive_base_url="$2"; shift ;; + -v|--verbose) + verbose=1 ;; -* ) echo "pyenv-binary: unknown option \`$1'" >&2; exit 1 ;; * ) [ -z "$spec" ] || { echo "pyenv-binary: unexpected argument \`$1'" >&2; exit 1; } - spec="$1"; shift ;; + spec="$1" + ;; esac + shift done if [ -z "$spec" ] || [ -z "$archive_base_url" ]; then @@ -78,7 +85,7 @@ if [ "$os" = "Darwin" ]; then fi # `pyenv install' puts a `:' build under versions/. -pyenv-install "$spec" +pyenv-install ${verbose:+--verbose} "$spec" pyenv-binary-save "$entry" "$PWD" --name "$entry" pyenv-binary-generate-installer "${entry}.meta" \ diff --git a/plugins/pyenv-binary/test/package.bats b/plugins/pyenv-binary/test/package.bats index 6262a8c3..b3f2f6dc 100644 --- a/plugins/pyenv-binary/test/package.bats +++ b/plugins/pyenv-binary/test/package.bats @@ -6,12 +6,24 @@ load test_helper # the platform tools report a fixed Linux target so the real `save' and # `generate-installer' behave the same on any test host. stub_build_environment() { - create_stub pyenv-install 'mkdir -p "${PYENV_ROOT}/versions/${1##*:}/bin"' - create_stub pyenv-latest '[ "$1" = "-f" ] && [ "$2" = "-k" ] && shift 2 && echo "$*"' + create_stub pyenv-install 'echo "${0##*/} $*"; mkdir -p "${PYENV_ROOT}/versions/${1##*:}/bin"' + create_stub pyenv-latest 'while (($#)); do case "$1" in -f|-k);; *)break;; esac; shift; done; echo "$*"' create_stub uname 'case "$1" in -s) echo Linux;; -m) echo x86_64;; esac' create_stub getconf 'echo "glibc 2.17"' } +@test "-v|--verbose runs pyenv install verbosely" { + stub_build_environment + create_stub pyenv-binary-save true + create_stub pyenv-binary-generate-installer true + + for opt in "" -v --verbose; do + run pyenv-binary-package $opt 3.12.7:3.12.7-test \ + --archive-base-url http://example.com/binaries + assert_success "pyenv-install ${opt:+--verbose }3.12.7:3.12.7-test" + done +} + @test "completion lists the option and definitions provided by another plugin" { mkdir -p "${PYENV_ROOT}/plugins/example/share/python-build" touch "${PYENV_ROOT}/plugins/example/share/python-build/3.12.7-example" @@ -20,6 +32,7 @@ stub_build_environment() { run pyenv-binary-package --complete assert_success assert_line "--archive-base-url" + assert_line "--verbose" assert_line "3.12.7-example" refute_line "Available versions:" } @@ -92,7 +105,6 @@ stub_build_environment() { @test "strips a trailing slash from the archive base url" { stub_build_environment - cd "${BATS_TEST_TMPDIR}" run pyenv-binary-package 3.12.7:3.12.7-test \ --archive-base-url http://example.com/binaries/