pyenv / pyenv

Simple Python version management
MIT License
38.88k stars 3.03k forks source link

Cannot install Python 3.10.12 under CLT for XCode 16, but can install under CLT for XCode 15 #3068

Open combacsa opened 2 weeks ago

combacsa commented 2 weeks ago

Prerequisite

Description

With Command Line Tools for XCode 15.3 I have no problem with installing python using pyenv, but with Command Line Tools for XCode 16 I'm facing strange problem. That XCode 16 release was just 3 days ago.

➜  ~ clang --version
Apple clang version 16.0.0 (clang-1600.0.26.3)
Target: arm64-apple-darwin23.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
➜  ~ ls
Applications (Parallels) Library                  Pictures
Desktop                  Movies                   Public
Documents                Music                    work
Downloads                Parallels
➜  ~ env SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk \
  MACOSX_DEPLOYMENT_TARGET=13.3 \
  PYTHON_CONFIGURE_OPTS="--enable-framework" \
  pyenv install 3.10.12
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.10.12.tar.xz...
-> https://www.python.org/ftp/python/3.10.12/Python-3.10.12.tar.xz
Installing Python-3.10.12...
python-build: use readline from homebrew

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

Inspect or clean up the working tree at /var/folders/tv/dppw7cs50hx9j9t0t9wvrts80004x3/T/python-build.20240920210953.40316
Results logged to /var/folders/tv/dppw7cs50hx9j9t0t9wvrts80004x3/T/python-build.20240920210953.40316.log

Last 10 log lines:
checking for python3... python3
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... "darwin"
checking for gcc... clang
checking whether the C compiler works... no
configure: error: in `/var/folders/tv/dppw7cs50hx9j9t0t9wvrts80004x3/T/python-build.20240920210953.40316/Python-3.10.12':
configure: error: C compiler cannot create executables
See `config.log' for more details
make: *** No targets specified and no makefile found.  Stop.

I installed older Command Line Tools for XCode 15.3 then it just went very well.

➜  ~ clang --version
Apple clang version 15.0.0 (clang-1500.3.9.4)
Target: arm64-apple-darwin23.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
➜  ~ env SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk \
  MACOSX_DEPLOYMENT_TARGET=13.3 \
  PYTHON_CONFIGURE_OPTS="--enable-framework" \
  pyenv install 3.10.12
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.10.12.tar.xz...
-> https://www.python.org/ftp/python/3.10.12/Python-3.10.12.tar.xz
Installing Python-3.10.12...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
Installed Python-3.10.12 to /Users/khbyun/.pyenv/versions/3.10.12

It may seems to be a duplicate of #2983 but just re-installing CLT for XCode 16 didn't help.

native-api commented 1 week ago

It may seems to be a duplicate of #2983 but just re-installing CLT for XCode 16 didn't help.

The error ld: library 'System' not found unambiguously means that your toolchain is broken.

Check if you have any compiler-affecting envvars (I don't see any in config.log but just in case).

Look though other posts in #2983. In particular, see if you have selected the right one with xcode-select and if there are any other bits on the system that shadow Apple's tools (see "common build problems" on the wiki for known offenders). Try removing everything compiler-related and doing a clean install of the Command-Line Tools.

combacsa commented 1 week ago

It may seems to be a duplicate of https://github.com/pyenv/pyenv/issues/2983 but just re-installing CLT for XCode 16 didn't help.

The error ld: library 'System' not found unambiguously means that your toolchain is broken. Try removing everything compiler-related and doing a clean install of the Command-Line Tools.

Doing a clean install of the Command-Line Tools for XCode 15.3 perfectly work, while a clean install of the Command-Line Tools for XCode 16 do not work. (It's newly purchased M3 Mac Pro and hadn't installed any Command-Line Tools for XCode before.)

Yet I hadn't try with other versions of Python, because I specifically need 3.10.12. Maybe I should try installing different versions?

native-api commented 1 week ago

Others have also reported problems with XCode 16.

We add it to compiler flags to use ZLib from there. Maybe that breaks XCode 16 due to structural changes.

Try applying this change:

--- a/plugins/python-build/bin/python-build
+++ b/plugins/python-build/bin/python-build
@@ -818,7 +818,7 @@ build_package_standard_build() {
     use_homebrew_readline || use_freebsd_pkg || true
     use_homebrew_ncurses || true
     if is_mac -ge 1014; then
-      use_xcode_sdk_zlib || use_homebrew_zlib || true
+      use_homebrew_zlib || true
     else
       use_homebrew_zlib || true
     fi