Compare commits

...

3 Commits

Author SHA1 Message Date
native-api
f9d17bfc06
Rename PYTHON_BUILD_TCLTK_FORMULA to PYTHON_BUILD_HOMEBREW_TCLTK_FORMULA; deprecate the old name (#3580)
* Update tcl/tk note
2026-10-03 18:51:15 +03:00
Ivan Pozdeev
67cfc116b9 -redundant check
invalid-format checksums will be rejected during comparison anyway
2026-10-03 17:37:36 +03:00
Ivan Pozdeev
f217e6c6cf Fix "broken pipe" in pyenv-binary-install 2026-10-03 17:15:05 +03:00
5 changed files with 44 additions and 27 deletions

View File

@ -100,16 +100,12 @@ if [ -z "$entry" ]; then
echo "pyenv-binary: no binary available for $requested on $os/$arch" >&2
exit 1
fi
definitions="$(pyenv-install --list --bare)" || definitions=""
if printf '%s\n' "$definitions" | grep -qxF -- "$entry"; then
definitions="$(pyenv-install --list --bare)"
if grep -qxF -- "$entry" <<<"$definitions"; then
pyenv-install "$entry:$version"
exit
fi
if ! [[ "$expected_sha" =~ ^[0-9a-fA-F]{64}$ ]]; then
echo "pyenv-binary: invalid checksum for $entry" >&2
exit 1
fi
expected_sha="$(printf '%s' "$expected_sha" | tr '[:upper:]' '[:lower:]')"
curl -fsSL -o "$tmpdir/$entry" "$base_url/$entry"
@ -123,7 +119,7 @@ else
echo "pyenv-binary: need sha256sum, shasum or openssl to verify $entry" >&2
exit 1
fi
if [ "$actual_sha" != "$expected_sha" ]; then
if [[ $expected_sha != "$actual_sha" ]]; then
echo "pyenv-binary: checksum mismatch for $entry" >&2
exit 1
fi

View File

@ -102,20 +102,6 @@ STUB
[ ! -e "$BATS_TEST_TMPDIR/downloaded" ]
}
@test "rejects an invalid published checksum when definition lookup fails" {
create_stub lsb_release 'case "$1" in -si) echo Ubuntu;; -sr) echo 24.04;; esac'
use_manifest
printf '3.14.7\t3.14.7-ubuntu-24.04-x86_64\tLinux\tx86_64\t%s\tinvalid\n' \
"$(host_distro)" >> "$BATS_TEST_TMPDIR/plugin/share/pyenv-binary/versions/3.14"
create_stub uname 'case "$1" in -s) echo Linux;; -m) echo x86_64;; esac'
create_stub pyenv-install 'exit 1'
create_stub curl 'touch "$BATS_TEST_TMPDIR/downloaded"; exit 1'
run pyenv-binary-install 3.14.7
assert_failure "pyenv-binary: invalid checksum for 3.14.7-ubuntu-24.04-x86_64"
[ ! -e "$BATS_TEST_TMPDIR/downloaded" ]
}
@test "installs a matching published binary with an uppercase checksum" {
create_stub lsb_release 'case "$1" in -si) echo Ubuntu;; -sr) echo 24.04;; esac'
use_manifest

View File

@ -186,7 +186,7 @@ You can set certain environment variables to control the build process.
* `PYTHON_BUILD_USE_HOMEBREW`, if set, will search for libraries installed by Homebrew when it normally wouldn't.
* `PYTHON_BUILD_HOMEBREW_OPENSSL_FORMULA`, override the Homebrew OpenSSL formula to use.
* `PYTHON_BUILD_MACPORTS_OPENSSL_FORMULA`, override the MacPorts OpenSSL formula to use. The default is `openssl3 openssl`.
* `PYTHON_BUILD_TCLTK_FORMULA`, override the Homebrew Tcl/Tk formula to use.
* `PYTHON_BUILD_HOMEBREW_TCLTK_FORMULA`, override the Homebrew Tcl/Tk formula to use.
* `PYTHON_BUILD_SKIP_MACPORTS`, if set, will not search for libraries installed by MacPorts when it normally would.
* `PYTHON_BUILD_USE_MACPORTS`, if set, will search for libraries installed by MacPorts when it normally wouldn't.
* `PYTHON_BUILD_ROOT` overrides the default location from where build definitions

View File

@ -2006,9 +2006,14 @@ use_homebrew_tcltk() {
can_use_homebrew || return 1
local tcltk_formula
# Since https://github.com/Homebrew/homebrew-core/commit/f10e88617b41555193c22fdcba6109fe82155ee2 (10.11.2024),
# tcl-tk is 9.0. It's supported in CPython since 3.14.0a1 (gh-124111) but is not officially supported as of 3.14.0
# so we prefer 8
for tcltk_formula in ${PYTHON_BUILD_TCLTK_FORMULA:-tcl-tk@8 tcl-tk}; do
# tcl-tk is 9.0. It's supported in CPython since 3.14.0a1 (gh-124111) but is not officially supported as of 3.14.0,
# as of 3.15.0rc3, there are still test failures.
# So we prefer 8.
if [[ -n $PYTHON_BUILD_TCLTK_FORMULA ]]; then
export PYTHON_BUILD_HOMEBREW_TCLTK_FORMULA="${PYTHON_BUILD_HOMEBREW_TCLTK_FORMULA:-$PYTHON_BUILD_TCLTK_FORMULA}"
echo "warning: the PYTHON_BUILD_TCLTK_FORMULA envvar has been renamed to PYTHON_BUILD_HOMEBREW_TCLTK_FORMULA" >&2
fi
for tcltk_formula in ${PYTHON_BUILD_HOMEBREW_TCLTK_FORMULA:-tcl-tk@8 tcl-tk}; do
local tcltk_prefix="$(brew --prefix "${tcltk_formula}" 2>/dev/null || true)"
if [ -d "$tcltk_prefix" ]; then
echo "python-build: use ${tcltk_formula} from homebrew"

View File

@ -1066,8 +1066,10 @@ make install
OUT
}
@test "tcl-tk is linked from Homebrew with PYTHON_BUILD_TCLTK_FORMULA" {
test_tcltk_var() {
local var="${1:?}"
cached_tarball "Python-3.6.2"
stub_tcltk "${tcl_tk_libdir:=$BATS_TEST_TMPDIR/homebrew-tcl-tk}"
stub uname '-s : echo Darwin'
@ -1080,7 +1082,7 @@ OUT
stub_make_install
run_inline_definition <<DEF
PYTHON_BUILD_TCLTK_FORMULA=tcl-tk-custom
$var=tcl-tk-custom
install_package "Python-3.6.2" "http://python.org/ftp/python/3.6.2/Python-3.6.2.tar.gz"
DEF
assert_success
@ -1098,6 +1100,34 @@ make install
OUT
}
@test "tcl-tk is linked from Homebrew with PYTHON_BUILD_HOMEBREW_TCLTK_FORMULA" {
test_tcltk_var PYTHON_BUILD_HOMEBREW_TCLTK_FORMULA
}
@test "tcl-tk is linked from Homebrew with PYTHON_BUILD_TCLTK_FORMULA" {
test_tcltk_var PYTHON_BUILD_HOMEBREW_TCLTK_FORMULA
}
@test "PYTHON_BUILD_TCLTK_FORMULA produces a deprecation warning" {
cached_tarball "Python-3.6.2"
stub uname '-s : echo Darwin'
stub sw_vers '-productVersion : echo 1010'
stub brew '--prefix openssl : false'
stub brew "--prefix tcl-tk-custom : echo '$tcl_tk_libdir'"
for i in {1..4}; do stub brew false; done
stub_make_install
run_inline_definition <<DEF
PYTHON_BUILD_TCLTK_FORMULA=tcl-tk-whatever
install_package "Python-3.6.2" "http://python.org/ftp/python/3.6.2/Python-3.6.2.tar.gz"
DEF
assert_success
assert_line "warning: the PYTHON_BUILD_TCLTK_FORMULA envvar has been renamed to PYTHON_BUILD_HOMEBREW_TCLTK_FORMULA"
}
@test "tcl-tk is linked from Homebrew via pkg-config and override vars" {
cached_tarball "Python-3.6.2" - TCLTK_CFLAGS TCLTK_LIBS
stub_tcltk "${tcl_tk_libdir:=$BATS_TEST_TMPDIR/homebrew-tcl-tk}"