mirror of
https://github.com/pyenv/pyenv.git
synced 2024-11-21 20:47:00 -05:00
Append Homebrew custom prefix to search path (#1957)
This is needed to find other Python deps (e.g. libintl) in Homebrew if it has nonstandard prefix (e.g. in Apple M1) * Re-allow to search Homebrew for zlib everywhere
This commit is contained in:
parent
c0d8b9cfe8
commit
4b82f575c7
3 changed files with 59 additions and 21 deletions
|
@ -773,10 +773,13 @@ build_package_standard_build() {
|
||||||
local PACKAGE_CFLAGS="${package_var_name}_CFLAGS"
|
local PACKAGE_CFLAGS="${package_var_name}_CFLAGS"
|
||||||
|
|
||||||
if [ "$package_var_name" = "PYTHON" ]; then
|
if [ "$package_var_name" = "PYTHON" ]; then
|
||||||
|
use_homebrew || true
|
||||||
use_tcltk || true
|
use_tcltk || true
|
||||||
use_homebrew_readline || use_freebsd_pkg || true
|
use_homebrew_readline || use_freebsd_pkg || true
|
||||||
if is_mac -ge 1014; then
|
if is_mac -ge 1014; then
|
||||||
use_xcode_sdk_zlib || use_homebrew_zlib || true
|
use_xcode_sdk_zlib || use_homebrew_zlib || true
|
||||||
|
else
|
||||||
|
use_homebrew_zlib || true
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -1325,6 +1328,19 @@ configured_with_package_dir() {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
use_homebrew() {
|
||||||
|
# unless Homebrew is at the default /usr/local, need to add its paths to
|
||||||
|
# compiler search to be able to use non-keg-only deps from there
|
||||||
|
if command -v brew &>/dev/null; then
|
||||||
|
local brew_prefix="$(brew --prefix 2>/dev/null || true)"
|
||||||
|
# /usr/local/lib:/usr/lib is the default library search path
|
||||||
|
if [[ -n $brew_prefix && $brew_prefix != "/usr" && $brew_prefix != "/usr/local" ]]; then
|
||||||
|
export CPPFLAGS="${CPPFLAGS:+${CPPFLAGS% } }-I${brew_prefix}/include"
|
||||||
|
export LDFLAGS="${LDFLAGS:+${LDFLAGS% } }-L${brew_prefix}/lib"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
needs_yaml() {
|
needs_yaml() {
|
||||||
! configured_with_package_dir "python" "yaml.h" &&
|
! configured_with_package_dir "python" "yaml.h" &&
|
||||||
! use_homebrew_yaml
|
! use_homebrew_yaml
|
||||||
|
|
|
@ -62,10 +62,7 @@ assert_build_log() {
|
||||||
cached_tarball "yaml-0.1.6"
|
cached_tarball "yaml-0.1.6"
|
||||||
cached_tarball "Python-3.6.2"
|
cached_tarball "Python-3.6.2"
|
||||||
|
|
||||||
# pyenv/pyenv#1026
|
for i in {1..4}; do stub uname '-s : echo Linux'; done
|
||||||
stub uname false false
|
|
||||||
|
|
||||||
stub uname '-s : echo Linux' '-s : echo Linux'
|
|
||||||
stub brew false
|
stub brew false
|
||||||
stub_make_install
|
stub_make_install
|
||||||
stub_make_install
|
stub_make_install
|
||||||
|
@ -92,10 +89,7 @@ OUT
|
||||||
cached_tarball "yaml-0.1.6"
|
cached_tarball "yaml-0.1.6"
|
||||||
cached_tarball "Python-3.6.2"
|
cached_tarball "Python-3.6.2"
|
||||||
|
|
||||||
# pyenv/pyenv#1026
|
for i in {1..4}; do stub uname '-s : echo Linux'; done
|
||||||
stub uname false false
|
|
||||||
|
|
||||||
stub uname '-s : echo Linux' '-s : echo Linux'
|
|
||||||
stub brew false
|
stub brew false
|
||||||
stub_make_install
|
stub_make_install
|
||||||
stub_make_install
|
stub_make_install
|
||||||
|
@ -154,6 +148,34 @@ make install
|
||||||
OUT
|
OUT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "homebrew with uncommon prefix is added to search path" {
|
||||||
|
cached_tarball "Python-3.6.2"
|
||||||
|
|
||||||
|
BREW_PREFIX="$TMP/homebrew-prefix"
|
||||||
|
mkdir -p "$BREW_PREFIX"
|
||||||
|
|
||||||
|
for i in {1..4}; do stub uname '-s : echo Darwin'; done
|
||||||
|
for i in {1..2}; do stub sw_vers '-productVersion : echo 1010'; done
|
||||||
|
stub brew "--prefix : echo '$BREW_PREFIX'" false
|
||||||
|
stub_make_install
|
||||||
|
|
||||||
|
run_inline_definition <<DEF
|
||||||
|
install_package "Python-3.6.2" "http://python.org/ftp/python/3.6.2/Python-3.6.2.tar.gz"
|
||||||
|
DEF
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
unstub sw_vers
|
||||||
|
unstub uname
|
||||||
|
unstub make
|
||||||
|
|
||||||
|
assert_build_log <<OUT
|
||||||
|
Python-3.6.2: CPPFLAGS="-I${TMP}/install/include -I$BREW_PREFIX/include" LDFLAGS="-L${TMP}/install/lib -L$BREW_PREFIX/lib"
|
||||||
|
Python-3.6.2: --prefix=$INSTALL_ROOT --libdir=$INSTALL_ROOT/lib
|
||||||
|
make -j 2
|
||||||
|
make install
|
||||||
|
OUT
|
||||||
|
}
|
||||||
|
|
||||||
@test "yaml is linked from Homebrew" {
|
@test "yaml is linked from Homebrew" {
|
||||||
cached_tarball "Python-3.6.2"
|
cached_tarball "Python-3.6.2"
|
||||||
|
|
||||||
|
@ -162,7 +184,8 @@ OUT
|
||||||
|
|
||||||
for i in {1..4}; do stub uname '-s : echo Darwin'; done
|
for i in {1..4}; do stub uname '-s : echo Darwin'; done
|
||||||
for i in {1..2}; do stub sw_vers '-productVersion : echo 1010'; done
|
for i in {1..2}; do stub sw_vers '-productVersion : echo 1010'; done
|
||||||
stub brew "--prefix libyaml : echo '$brew_libdir'" false false
|
stub brew "--prefix libyaml : echo '$brew_libdir'"
|
||||||
|
for i in {1..4}; do stub brew false; done
|
||||||
stub_make_install
|
stub_make_install
|
||||||
|
|
||||||
install_fixture definitions/needs-yaml
|
install_fixture definitions/needs-yaml
|
||||||
|
@ -186,11 +209,10 @@ OUT
|
||||||
|
|
||||||
readline_libdir="$TMP/homebrew-readline"
|
readline_libdir="$TMP/homebrew-readline"
|
||||||
mkdir -p "$readline_libdir"
|
mkdir -p "$readline_libdir"
|
||||||
|
stub uname false
|
||||||
# pyenv/pyenv#1026
|
for i in {1..2}; do stub brew false; done
|
||||||
stub uname false false
|
stub brew "--prefix readline : echo '$readline_libdir'"
|
||||||
|
stub brew false
|
||||||
stub brew false "--prefix readline : echo '$readline_libdir'"
|
|
||||||
stub_make_install
|
stub_make_install
|
||||||
|
|
||||||
run_inline_definition <<DEF
|
run_inline_definition <<DEF
|
||||||
|
@ -220,7 +242,7 @@ OUT
|
||||||
# pyenv/pyenv#1026
|
# pyenv/pyenv#1026
|
||||||
stub uname false false
|
stub uname false false
|
||||||
|
|
||||||
stub brew false
|
for i in {1..3}; do stub brew false; done
|
||||||
stub_make_install
|
stub_make_install
|
||||||
|
|
||||||
export PYTHON_CONFIGURE_OPTS="CPPFLAGS=-I$readline_libdir/include LDFLAGS=-L$readline_libdir/lib"
|
export PYTHON_CONFIGURE_OPTS="CPPFLAGS=-I$readline_libdir/include LDFLAGS=-L$readline_libdir/lib"
|
||||||
|
@ -248,9 +270,9 @@ OUT
|
||||||
echo "TCL_VERSION='$tcl_tk_version'" >>"$tcl_tk_libdir/lib/tclConfig.sh"
|
echo "TCL_VERSION='$tcl_tk_version'" >>"$tcl_tk_libdir/lib/tclConfig.sh"
|
||||||
|
|
||||||
stub uname false
|
stub uname false
|
||||||
|
|
||||||
for i in {1..2}; do stub brew "--prefix tcl-tk : echo '$tcl_tk_libdir'"; done
|
|
||||||
stub brew false
|
stub brew false
|
||||||
|
for i in {1..2}; do stub brew "--prefix tcl-tk : echo '$tcl_tk_libdir'"; done
|
||||||
|
for i in {1..2}; do stub brew false; done
|
||||||
stub_make_install
|
stub_make_install
|
||||||
|
|
||||||
run_inline_definition <<DEF
|
run_inline_definition <<DEF
|
||||||
|
@ -279,7 +301,7 @@ OUT
|
||||||
# pyenv/pyenv#1026
|
# pyenv/pyenv#1026
|
||||||
stub uname false false
|
stub uname false false
|
||||||
|
|
||||||
stub brew false false
|
for i in {1..4}; do stub brew false; done
|
||||||
stub_make_install
|
stub_make_install
|
||||||
|
|
||||||
export PYTHON_CONFIGURE_OPTS="--with-tcltk-libs='-L${TMP}/custom-tcl-tk/lib -ltcl$tcl_tk_version -ltk$tcl_tk_version'"
|
export PYTHON_CONFIGURE_OPTS="--with-tcltk-libs='-L${TMP}/custom-tcl-tk/lib -ltcl$tcl_tk_version -ltk$tcl_tk_version'"
|
||||||
|
|
|
@ -314,7 +314,7 @@ EOS
|
||||||
@test "enable custom unicode configuration" {
|
@test "enable custom unicode configuration" {
|
||||||
cached_tarball "Python-3.6.2"
|
cached_tarball "Python-3.6.2"
|
||||||
|
|
||||||
for i in {1..2}; do stub brew '* : false'; done
|
for i in {1..4}; do stub brew false; done
|
||||||
for i in {1..3}; do stub uname '-s : echo Linux'; done
|
for i in {1..3}; do stub uname '-s : echo Linux'; done
|
||||||
stub "$MAKE" \
|
stub "$MAKE" \
|
||||||
" : echo \"$MAKE \$@\" >> build.log" \
|
" : echo \"$MAKE \$@\" >> build.log" \
|
||||||
|
|
Loading…
Reference in a new issue