profile
viewpoint

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...
-> https://www.python.org/ftp/python/3.8.3/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.

pyenv_install.log

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).

pyenv/pyenv

Answer questions aaron-trout

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

#!/bin/bash

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 https://github.com/python/cpython/commit/8ea6353.patch)

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

useful!
source:https://uonfu.com/
Github User Rank List