Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xcode: command line tools only version detection prevents pip install #496

Closed
StevenACoffman opened this issue Sep 28, 2022 · 2 comments
Closed
Labels
enhancement New feature or request

Comments

@StevenACoffman
Copy link

When installing this library with only the XCode command line tools installed (xcode-select --install), setup.py fails without the full XCode installed, but the error is confusing and doesn't explain the cause.

In https://github.com/ronaldoussoren/pyobjc/blob/master/pyobjc-framework-AddressBook/pyobjc_setup.py#L473 (and all the similar places) when you are most likely on a system with the Xcode command line tools installed (without the full XCode) the following command is executed and the output is then parsed for the version number:

/usr/bin/xcrun -sdk macosx --show-sdk-path

This output will then fail to yield a parseable numeric version value:

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk

However, this is the correctly parseable output with a full XCode installed:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk

When only the command line tools are installed, you can still find the numeric XCode version this way:

pkgutil --pkg-info=com.apple.pkg.CLTools_Executables

Which will output:

package-id: com.apple.pkg.CLTools_Executables
version: 13.4.0.0.1.1651278267
volume: /
location: /
install-time: 1654038856
groups: com.apple.FindSystemFiles.pkg-group

You can also run xcode-select -p: which will output on a machine that only has the X Code command line tools:

/Library/Developer/CommandLineTools

but on a machine that has the full XCode will output:

/Applications/Xcode.app/Contents/Developer

**# Xcode version output output bash
This is a hacky way to look up the version in bash:

if pkgutil --pkgs=com.apple.pkg.Xcode >/dev/null; then
    echo Xcode: $(pkgutil --pkg-info=com.apple.pkg.Xcode | awk '/version:/ {print $2}')
else
    echo Xcode: not installed
fi

# Command Line Tools for Xcode
if pkgutil --pkgs=com.apple.pkg.CLTools_Executables >/dev/null; then
    echo CommandLineTools: $(pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | awk '/version:/ {print $2}')
else
    echo CommandLineTools: not installed
fi
@StevenACoffman StevenACoffman added the enhancement New feature or request label Sep 28, 2022
@ronaldoussoren
Copy link
Owner

The code you reference primarily looks for SDKSettings.plist in the SDK to determine the SDK version, extracting the SDK version from the filesystem path is a fallback for older systems.

That code is not looking for the Xcode version, but for the SDK version (e.g. which OS version is this SDK for).

I guess I'll have to spin up a VM where I can install the command-line tools to check what's going on here.

@StevenACoffman
Copy link
Author

I encountered the problem when I was trying to install pyobjc's very old version 5.3 on Python 2.7 on a new M1 laptop to run a legacy program, and the latest version of the pyobjc_setup.py code has changed, so this may not be an issue anymore. I hacked up a local fork to hard code the version number and was able to install that way.

if this is not an issue for modern versions of pyobjc pyobjc_setup.py, then feel free to close and ignore this, but I thought I would mention it in case it is helpful to you or others.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants