Ask questionsUnable to build Python on macOS Big Sur with Xcode 12 beta

I installed macOS Big Sur beta 1, Xcode 12.0 beta (12A6159) on an old Mac to see what breaks. I'm able to install PyEnv via Homebrew, but I'm not able to build any Python version.

Apple clang version 12.0.0

% pyenv install 3.8.3
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.8.3.tar.xz...
Installing Python-3.8.3...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk

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

Inspect or clean up the working tree at /var/folders/sl/5j1zvmtj0gb8qpgkklkf38dh0000gr/T/python-build.20200626170507.14625
Results logged to /var/folders/sl/5j1zvmtj0gb8qpgkklkf38dh0000gr/T/python-build.20200626170507.14625.log

Last 10 log lines:
./Modules/posixmodule.c:9141:12: note: forward declaration of 'struct sf_hdtr'
    struct sf_hdtr sf;
./Modules/posixmodule.c:9221:15: error: implicit declaration of function 'sendfile' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        ret = sendfile(in, out, offset, &sbytes, &sf, flags);
2 errors generated.
make: *** [Modules/posixmodule.o] Error 1
make: *** Waiting for unfinished jobs....
1 warning generated.


Note that MacOSX.sdk is symlinked to MacOSX10.16.sdk. Pointing the symlink to MacOSX10.15.sdk doesn't help.

I didn't try switching to Xcode 11 yet, though that will probably help, if it's indeed a clang problem.

Downloading and installing Python 3.8.3 from the website works fine (python3 executable).


Answer questions aaron-trout

Thanks @htp! I managed to get this working for installing Python 3.5 using this script:


set -ex

export CFLAGS="-I$(brew --prefix openssl)/include -I$(brew --prefix readline)/include -I$(xcrun --show-sdk-path)/usr/include"
export LDFLAGS="-L$(brew --prefix openssl)/lib -L$(brew --prefix readline)/lib -L$(xcrun --show-sdk-path)/usr/lib -L/usr/local/opt/zlib/lib"
export CPPFLAGS="-I/usr/local/opt/zlib/include"
export PKG_CONFIG_PATH="/usr/local/opt/zlib/lib/pkgconfig"

pyenv install --patch 3.5.9 < <(curl -sSL

I also did brew reinstall -s make cmake as someone else suggested earlier, not sure if that helped or not!

Github User Rank List