Skip to content

Commit

Permalink
Fix pyobjc-core XCode version check.
Browse files Browse the repository at this point in the history
  • Loading branch information
cpatulea committed Jan 13, 2024
1 parent b540014 commit 1e79313
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
46 changes: 46 additions & 0 deletions patches/pyobjc-core-xcode-version-check.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
commit 58ab8df6a0548fb070080f39ded837658823312f
Author: Catalin Patulea <[email protected]>
Date: Sat Jan 13 10:15:52 2024 +0200

Fix XCode version check with only CommandLineTools.

https://github.com/ronaldoussoren/pyobjc/issues/569#issuecomment-1880015695

diff --git a/pyobjc-core/setup.py b/pyobjc-core/setup.py
index ecd3934..cde5621 100644
--- a/pyobjc-core/setup.py
+++ b/pyobjc-core/setup.py
@@ -594,15 +594,24 @@ class oc_build_ext(build_ext.build_ext):
CFLAGS.append("-DNO_OBJC2_RUNTIME")
EXT_CFLAGS.append("-DNO_OBJC2_RUNTIME")

- lines = subprocess.check_output(
- ["xcodebuild", "-version"], text=True
- ).splitlines()
- if lines[0].startswith("Xcode"):
- xcode_vers = int(lines[0].split()[-1].split(".")[0])
- if xcode_vers >= 15:
- for var in (OBJC_LDFLAGS,):
- print("Use old linker with Xcode 15 or later")
- var.append("-Wl,-ld_classic")
+ xcode_vers = None
+ try:
+ lines = subprocess.check_output(
+ ["xcodebuild", "-version"], text=True
+ ).splitlines()
+ if lines[0].startswith("Xcode"):
+ xcode_vers = int(lines[0].split()[-1].split(".")[0])
+ except subprocess.CalledProcessError:
+ lines = subprocess.check_output(
+ ["pkgutil", "--pkg-info=com.apple.pkg.CLTools_Executables"],
+ text=True).splitlines()
+ version, = [l.split()[1] for l in lines
+ if l.startswith('version: ')]
+ xcode_vers = int(version.split(".")[0])
+ if xcode_vers >= 15:
+ for var in (OBJC_LDFLAGS,):
+ print("Use old linker with Xcode 15 or later")
+ var.append("-Wl,-ld_classic")

def run(self):
verify_platform()
1 change: 1 addition & 0 deletions xpra-python3.modules
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,7 @@
hash="sha256:3dd0a7b3acd7e0b8ffd3f5331b29a3aaebe79a03323e61efeece38627a6020b3"
version="10.0">
<patch file="pyobjc-unused-parameter.patch" strip="1"/>
<patch file="pyobjc-core-xcode-version-check.patch" strip="2"/>
</branch>
<dependencies>
<dep package="python3"/>
Expand Down

0 comments on commit 1e79313

Please sign in to comment.