From d2be7431104d769a570baa42fa12a0aff2d5d6ee Mon Sep 17 00:00:00 2001 From: Neil Martinsen-Burrell Date: Tue, 21 Jul 2020 16:26:27 -0500 Subject: [PATCH 1/2] Use grep instead of ag SilverSearcher isnt available by default, so use grep instead. --- mac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mac b/mac index baa3c04..913a072 100755 --- a/mac +++ b/mac @@ -278,7 +278,7 @@ EOF # so we check for the latest version against Homebrew instead. latest_python_3="$(brew info python3 | grep -E -o "3\.\d+\.\d+" | head -1)" - if ! pyenv versions | ag "$latest_python_3" > /dev/null; then + if ! pyenv versions | grep "$latest_python_3" > /dev/null; then # Starting with macOS 10.14 (Mojave), the header files for system libraries # have been moved. Rather than hack the header paths based on OS version, # just install zlib with brew and build against that directly for now. From d06ef092409104208d98d1d144f7d7cd61814f43 Mon Sep 17 00:00:00 2001 From: Neil Martinsen-Burrell Date: Tue, 21 Jul 2020 16:49:19 -0500 Subject: [PATCH 2/2] Workaround for pyenv not having a version yet If brew gets a version of Python before the released version of pyenv, then pyenv installation will fail. This adds an environment variable LATEST_PYTHON_3 that can be used to override the version discovered from brew. --- mac | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mac b/mac index 913a072..a272277 100755 --- a/mac +++ b/mac @@ -277,6 +277,12 @@ EOF # pyenv currently doesn't have a convenience version to use, e.g., "latest", # so we check for the latest version against Homebrew instead. latest_python_3="$(brew info python3 | grep -E -o "3\.\d+\.\d+" | head -1)" + # in the event that pyenv doesn't have the latest version from homebrew, + # allow overriding with an environment variable + # shellcheck disable=SC2153 + if [ -n "$LATEST_PYTHON_3" ]; then + latest_python_3=${LATEST_PYTHON_3} + fi if ! pyenv versions | grep "$latest_python_3" > /dev/null; then # Starting with macOS 10.14 (Mojave), the header files for system libraries @@ -285,7 +291,7 @@ EOF brew install zlib export LDFLAGS="-L/usr/local/opt/zlib/lib" export CPPFLAGS="-I/usr/local/opt/zlib/include" - pyenv install "$latest_python_3" + pyenv install "$latest_python_3" || fancy_echo "pyenv install of $latest_python_3 failed. Try \"export LATEST_PYTHON_3=3.8.3\" or some other version" pyenv global "$latest_python_3" pyenv rehash fi