Skip to content

Commit

Permalink
Merge pull request #102 from h-vetinari/sdk
Browse files Browse the repository at this point in the history
pick upstream patch to fix macos sdk detection
  • Loading branch information
ocefpaf committed Nov 12, 2021
2 parents a287219 + 1f17747 commit e55f645
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 12 deletions.
5 changes: 3 additions & 2 deletions recipe/meta.yaml
Expand Up @@ -9,8 +9,9 @@ source:
sha256: b8e2f83c56e141920c39464b852de3719dfbfb6e3c99a2d8da0edf4fb33176ed
patches:
- patches/0001-Build-without-USE_WIN32_FILEIO.patch
# Revert python-pillow/Pillow#5624 as it causes build to pick up wrong MacOS SDK
- patches/0002-Revert-Prefer-command-line-tools-SDK-on-macOS.patch
# Backport python-pillow/Pillow#5828 (2 patches), can be dropped for v>=9.0
- patches/0002-Only-prefer-command-line-tools-SDK-on-macOS-over-the.patch
- patches/0003-Moved-macOS-SDK-logic-into-a-separate-method.patch

build:
number: 0
Expand Down
2 changes: 1 addition & 1 deletion recipe/patches/0001-Build-without-USE_WIN32_FILEIO.patch
@@ -1,7 +1,7 @@
From 889ee00643d8f4d744663aea5f7dda3fe868e829 Mon Sep 17 00:00:00 2001
From: Ryan May <rmay@ucar.edu>
Date: Wed, 5 May 2021 12:42:10 -0600
Subject: [PATCH 1/2] Build without USE_WIN32_FILEIO
Subject: [PATCH 1/3] Build without USE_WIN32_FILEIO

This keeps things consistent with current conda-forge builds of tiff
(and poppler).
Expand Down
@@ -1,18 +1,18 @@
From 87a655f186d8ce4858636ff201ee7f3bcd2bffed Mon Sep 17 00:00:00 2001
From: "H. Vetinari" <h.vetinari@gmx.com>
Date: Wed, 10 Nov 2021 11:50:55 +1100
Subject: [PATCH 2/2] Revert "Prefer command line tools SDK on macOS"
From c60bdf31dade079f53c217edd92230566e700db4 Mon Sep 17 00:00:00 2001
From: Andrew Murray <radarhere@users.noreply.github.com>
Date: Thu, 11 Nov 2021 20:47:46 +1100
Subject: [PATCH 2/3] Only prefer command line tools SDK on macOS over the
default

This reverts commit e7270eb5a1dfa99b54dcb74d870aab0a1fe73d56.
---
setup.py | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
setup.py | 28 ++++++++++++++++++----------
1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/setup.py b/setup.py
index 10c1b585..57451122 100755
index 10c1b585..341cb331 100755
--- a/setup.py
+++ b/setup.py
@@ -533,16 +533,14 @@ class pil_build_ext(build_ext):
@@ -533,16 +533,24 @@ class pil_build_ext(build_ext):
_add_directory(include_dirs, "/usr/X11/include")

# SDK install path
Expand All @@ -34,6 +34,16 @@ index 10c1b585..57451122 100755
+ )
+ except Exception:
+ sdk_path = None
+ if (
+ not sdk_path
+ or sdk_path == "/Applications/Xcode.app/Contents/Developer"
+ "/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
+ ):
+ commandlinetools_sdk_path = (
+ "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"
+ )
+ if os.path.exists(commandlinetools_sdk_path):
+ sdk_path = commandlinetools_sdk_path
if sdk_path:
_add_directory(library_dirs, os.path.join(sdk_path, "usr", "lib"))
_add_directory(include_dirs, os.path.join(sdk_path, "usr", "include"))
Expand Down
@@ -0,0 +1,71 @@
From d9afb11be92a317de829f82aa175d3cdc572ec8e Mon Sep 17 00:00:00 2001
From: Andrew Murray <radarhere@users.noreply.github.com>
Date: Thu, 11 Nov 2021 20:51:13 +1100
Subject: [PATCH 3/3] Moved macOS SDK logic into a separate method

---
setup.py | 41 ++++++++++++++++++++++-------------------
1 file changed, 22 insertions(+), 19 deletions(-)

diff --git a/setup.py b/setup.py
index 341cb331..7655c209 100755
--- a/setup.py
+++ b/setup.py
@@ -405,6 +405,27 @@ class pil_build_ext(build_ext):
self.extensions.remove(extension)
break

+ def get_macos_sdk_path(self):
+ try:
+ sdk_path = (
+ subprocess.check_output(["xcrun", "--show-sdk-path"])
+ .strip()
+ .decode("latin1")
+ )
+ except Exception:
+ sdk_path = None
+ if (
+ not sdk_path
+ or sdk_path == "/Applications/Xcode.app/Contents/Developer"
+ "/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
+ ):
+ commandlinetools_sdk_path = (
+ "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"
+ )
+ if os.path.exists(commandlinetools_sdk_path):
+ sdk_path = commandlinetools_sdk_path
+ return sdk_path
+
def build_extensions(self):

library_dirs = []
@@ -532,25 +553,7 @@ class pil_build_ext(build_ext):
_add_directory(library_dirs, "/usr/X11/lib")
_add_directory(include_dirs, "/usr/X11/include")

- # SDK install path
- try:
- sdk_path = (
- subprocess.check_output(["xcrun", "--show-sdk-path"])
- .strip()
- .decode("latin1")
- )
- except Exception:
- sdk_path = None
- if (
- not sdk_path
- or sdk_path == "/Applications/Xcode.app/Contents/Developer"
- "/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
- ):
- commandlinetools_sdk_path = (
- "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"
- )
- if os.path.exists(commandlinetools_sdk_path):
- sdk_path = commandlinetools_sdk_path
+ sdk_path = self.get_macos_sdk_path()
if sdk_path:
_add_directory(library_dirs, os.path.join(sdk_path, "usr", "lib"))
_add_directory(include_dirs, os.path.join(sdk_path, "usr", "include"))
--
2.32.0.windows.2

0 comments on commit e55f645

Please sign in to comment.