Pyenv: Installing legacy Python versions should be supported even after homebrew upgraded to [email protected]

Created on 5 Apr 2020  路  3Comments  路  Source: pyenv/pyenv

When installing a legacy Python version on Mac with Homebrew, pyenv will query for openssl and readline from homebrew, preferring those versions. Recently [email protected] has been removed from homebrew (https://brew.sh/2019/11/27/homebrew-2.2.0/), making it tricky to install these legacy versions.

Although I managed to find a workaround (https://github.com/earlchew/nobrew), alternative approaches are likely preferred:

  • Legacy Python versions that do not support [email protected] should no longer use homebrew. This would allow pyenv install 2.7.11 to work out of the box.
  • Add support for say, --no-brew, so that users can avoid using homebrew when building legacy versions.

It's worth noting that these two ideas are not mutually exclusive.

$ ~/Homebrew/bin/pyenv install 2.7.11
python-build: use openssl from homebrew
python-build: use readline from homebrew
Downloading Python-2.7.11.tar.xz...
-> https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tar.xz
Installing Python-2.7.11...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?

Please consult to the Wiki page to fix the problem.
https://github.com/pyenv/pyenv/wiki/Common-build-problems


BUILD FAILED (OS X 10.14.6 using python-build 20180424)
clang -fno-strict-aliasing -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/private/var/folders/zr/6rd5zj494x3042yl29yms8w5z0v1mq/T/python-build.20200405090510.52990/Python-2.7.11/Mac/Include -I. -IInclude -I./Include -I/Users/earlchew/Homebrew/opt/readline/include -I/Users/earlchew/Homebrew/opt/[email protected]/include -I/private/var/folders/zr/6rd5zj494x3042yl29yms8w5z0v1mq/T/python-build.20200405090510.52990/Python-2.7.11/Include -I/private/var/folders/zr/6rd5zj494x3042yl29yms8w5z0v1mq/T/python-build.20200405090510.52990/Python-2.7.11 -c /private/var/folders/zr/6rd5zj494x3042yl29yms8w5z0v1mq/T/python-build.20200405090510.52990/Python-2.7.11/Modules/_ssl.c -o build/temp.macosx-10.14-x86_64-2.7/private/var/folders/zr/6rd5zj494x3042yl29yms8w5z0v1mq/T/python-build.20200405090510.52990/Python-2.7.11/Modules/_ssl.o
/private/var/folders/zr/6rd5zj494x3042yl29yms8w5z0v1mq/T/python-build.20200405090510.52990/Python-2.7.11/Modules/_ssl.c:684:35: error: incomplete definition of type 'struct X509_name_entry_st'
            if (rdn_level != entry->set) {
                             ~~~~~^

Most helpful comment

Alternatively, you can install [email protected] formula (via rbenv) then explicitly tell pyenv to use that https://github.com/borgbackup/borg/pull/5135/files

It appears the issue is pyenv is assuming openssl is 1.0 and [email protected] is 1.1 when they point to the same version (due to homebrew upgrades)

Either way I think it's a bug python-build tries to use the wrong version of openssl to build python (it should either explicitly use [email protected] or check which version of openssl its checks resolved to)

All 3 comments

Thanks for the workaround @earlchew .

I didn't understand all the shell code in nobrew because I don't understand shell scripts. So instead I just temporarily hid brew with mv:

$ mv /usr/local/bin/brew /usr/local/bin/brew.bak
$ CFLAGS=-DOPENSSL_NO_SSL3 pyenv install 3.4.10
$ mv /usr/local/bin/brew.bak /usr/local/bin/brew

CFLAGS=-DOPENSSL_NO_SSL3 was needed to get ensurepip to not have this error:

BUILD FAILED (OS X 10.14.6 using python-build 20180424)

Inspect or clean up the working tree at /var/folders/kq/02p9h16n7zv_z7bhzmg6y_pm0000gn/T/python-build.20200408101652.78488
Results logged to /var/folders/kq/02p9h16n7zv_z7bhzmg6y_pm0000gn/T/python-build.20200408101652.78488.log

Last 10 log lines:
(cd /Users/chainz/.pyenv/versions/3.4.10/share/man/man1; ln -s python3.4.1 python3.1)
if test "xupgrade" != "xno"  ; then \
        case upgrade in \
            upgrade) ensurepip="--upgrade" ;; \
            install|*) ensurepip="" ;; \
        esac; \
         ./python.exe -E -m ensurepip \
            $ensurepip --root=/ ; \
    fi
Ignoring ensurepip failure: pip 9.0.1 requires SSL/TLS

Alternatively, you can install [email protected] formula (via rbenv) then explicitly tell pyenv to use that https://github.com/borgbackup/borg/pull/5135/files

It appears the issue is pyenv is assuming openssl is 1.0 and [email protected] is 1.1 when they point to the same version (due to homebrew upgrades)

Either way I think it's a bug python-build tries to use the wrong version of openssl to build python (it should either explicitly use [email protected] or check which version of openssl its checks resolved to)

Thanks ! I was able to install my Python versions with your help.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bbulkow picture bbulkow  路  3Comments

demba picture demba  路  3Comments

bersbersbers picture bersbersbers  路  3Comments

tarkatronic picture tarkatronic  路  3Comments

bryant1410 picture bryant1410  路  3Comments