From 171b318f476dfdda2d6db375a80b48be4aa25357 Mon Sep 17 00:00:00 2001 From: macayu17 Date: Wed, 22 Jul 2026 17:28:57 +0530 Subject: [PATCH] pyenv-binary: refuse `build` on macOS before compiling `generate-installer` refuses a macOS archive, so the last step of the pipeline cannot succeed there. Left to fail on its own it does so only after a full source build has been spent, so check the platform up front, like the entry name guards above it. --- plugins/pyenv-binary/libexec/pyenv-binary-build | 11 ++++++++++- plugins/pyenv-binary/test/build.bats | 6 ++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/plugins/pyenv-binary/libexec/pyenv-binary-build b/plugins/pyenv-binary/libexec/pyenv-binary-build index 216e9198..3a0606d0 100755 --- a/plugins/pyenv-binary/libexec/pyenv-binary-build +++ b/plugins/pyenv-binary/libexec/pyenv-binary-build @@ -73,11 +73,20 @@ latest ) ;; esac +os="$(uname -s)" + +# `generate-installer' refuses a macOS archive, so the last step here cannot +# succeed on one. Give up before the build rather than after it. +if [ "$os" = "Darwin" ]; then + echo "pyenv-binary: macOS archives are not supported yet" >&2 + exit 1 +fi + # `pyenv install' puts a `:' build under versions/. pyenv-install "$spec" pyenv-binary-save "$entry" # Name the metadata and the archive the way `save' just named them. -platform="$(uname -s | tr '[:upper:]' '[:lower:]')-$(uname -m)" +platform="$(printf '%s' "$os" | tr '[:upper:]' '[:lower:]')-$(uname -m)" pyenv-binary-generate-installer "${entry}-${platform}.meta" \ --archive-url "${archive_url%/}/${entry}-${platform}.tar.gz" -o "$entry" diff --git a/plugins/pyenv-binary/test/build.bats b/plugins/pyenv-binary/test/build.bats index 5fe9df94..aa216da7 100644 --- a/plugins/pyenv-binary/test/build.bats +++ b/plugins/pyenv-binary/test/build.bats @@ -55,6 +55,12 @@ stub_build_environment() { assert_failure "pyenv-binary: \`latest' cannot be used as an entry name" } +@test "refuses to build on macOS before compiling anything" { + create_stub uname 'case "$1" in -s) echo Darwin;; -m) echo arm64;; esac' + run pyenv-binary-build 3.12.7:3.12.7-test --archive-url http://x/b + assert_failure "pyenv-binary: macOS archives are not supported yet" +} + @test "builds under the entry name and writes the archive and definition" { stub_build_environment cd "${BATS_TEST_TMPDIR}"