Disable platform guessing instead of adding dependencies-prefix

This commit is contained in:
Andrew Murray 2024-11-12 22:41:57 +11:00
parent 681a03b1c3
commit 378df7a5b2
2 changed files with 42 additions and 55 deletions

View File

@ -95,8 +95,8 @@ before-all = ".github/workflows/wheels-dependencies.sh"
build-verbosity = 1 build-verbosity = 1
config-settings = "raqm=enable raqm=vendor fribidi=vendor imagequant=disable" config-settings = "raqm=enable raqm=vendor fribidi=vendor imagequant=disable"
# Add an explicit dependencies prefix for macOS. # Disable platform guessing on macOS
macos.config-settings = "raqm=enable raqm=vendor fribidi=vendor imagequant=disable dependencies-prefix=./build/deps/darwin" macos.config-settings = "raqm=enable raqm=vendor fribidi=vendor imagequant=disable platform-guessing=disable"
test-command = "cd {project} && .github/workflows/wheels-test.sh" test-command = "cd {project} && .github/workflows/wheels-test.sh"
test-extras = "tests" test-extras = "tests"

View File

@ -344,11 +344,6 @@ class pil_build_ext(build_ext):
for x in ("raqm", "fribidi") for x in ("raqm", "fribidi")
] ]
+ [ + [
(
"dependencies-prefix",
None,
"The prefix where build dependencies are located.",
),
("disable-platform-guessing", None, "Disable platform guessing on Linux"), ("disable-platform-guessing", None, "Disable platform guessing on Linux"),
("debug", None, "Debug logging"), ("debug", None, "Debug logging"),
] ]
@ -360,7 +355,6 @@ class pil_build_ext(build_ext):
return True if value in configuration.get(option, []) else None return True if value in configuration.get(option, []) else None
def initialize_options(self) -> None: def initialize_options(self) -> None:
self.dependencies_prefix = configuration.get("dependencies-prefix", [])
self.disable_platform_guessing = self.check_configuration( self.disable_platform_guessing = self.check_configuration(
"platform-guessing", "disable" "platform-guessing", "disable"
) )
@ -570,54 +564,47 @@ class pil_build_ext(build_ext):
) )
elif sys.platform == "darwin": elif sys.platform == "darwin":
if self.dependencies_prefix: # attempt to make sure we pick freetype2 over other versions
# Use the explicitly provided prefixes for dependencies. _add_directory(include_dirs, "/sw/include/freetype2")
for prefix in self.dependencies_prefix: _add_directory(include_dirs, "/sw/lib/freetype2/include")
_add_directory(library_dirs, os.path.join(prefix, "lib")) # fink installation directories
_add_directory(include_dirs, os.path.join(prefix, "include")) _add_directory(library_dirs, "/sw/lib")
_add_directory(include_dirs, "/sw/include")
# darwin ports installation directories
_add_directory(library_dirs, "/opt/local/lib")
_add_directory(include_dirs, "/opt/local/include")
# if Homebrew is installed, use its lib and include directories
try:
prefix = (
subprocess.check_output(["brew", "--prefix"])
.strip()
.decode("latin1")
)
except Exception:
# Homebrew not installed
prefix = None
ft_prefix = None
if prefix:
# add Homebrew's include and lib directories
_add_directory(library_dirs, os.path.join(prefix, "lib"))
_add_directory(include_dirs, os.path.join(prefix, "include"))
_add_directory(
include_dirs, os.path.join(prefix, "opt", "zlib", "include")
)
ft_prefix = os.path.join(prefix, "opt", "freetype")
if ft_prefix and os.path.isdir(ft_prefix):
# freetype might not be linked into Homebrew's prefix
_add_directory(library_dirs, os.path.join(ft_prefix, "lib"))
_add_directory(include_dirs, os.path.join(ft_prefix, "include"))
else: else:
# Guess the dependency locations based on homebrew/fink/macports # fall back to freetype from XQuartz if
# attempt to make sure we pick freetype2 over other versions # Homebrew's freetype is missing
_add_directory(include_dirs, "/sw/include/freetype2") _add_directory(library_dirs, "/usr/X11/lib")
_add_directory(include_dirs, "/sw/lib/freetype2/include") _add_directory(include_dirs, "/usr/X11/include")
# fink installation directories
_add_directory(library_dirs, "/sw/lib")
_add_directory(include_dirs, "/sw/include")
# darwin ports installation directories
_add_directory(library_dirs, "/opt/local/lib")
_add_directory(include_dirs, "/opt/local/include")
# if Homebrew is installed, use its lib and include directories
try:
prefix = (
subprocess.check_output(["brew", "--prefix"])
.strip()
.decode("latin1")
)
except Exception:
# Homebrew not installed
prefix = None
ft_prefix = None
if prefix:
# add Homebrew's include and lib directories
_add_directory(library_dirs, os.path.join(prefix, "lib"))
_add_directory(include_dirs, os.path.join(prefix, "include"))
_add_directory(
include_dirs, os.path.join(prefix, "opt", "zlib", "include")
)
ft_prefix = os.path.join(prefix, "opt", "freetype")
if ft_prefix and os.path.isdir(ft_prefix):
# freetype might not be linked into Homebrew's prefix
_add_directory(library_dirs, os.path.join(ft_prefix, "lib"))
_add_directory(include_dirs, os.path.join(ft_prefix, "include"))
else:
# fall back to freetype from XQuartz if
# Homebrew's freetype is missing
_add_directory(library_dirs, "/usr/X11/lib")
_add_directory(include_dirs, "/usr/X11/include")
# Add the macOS SDK path. # Add the macOS SDK path.
sdk_path = self.get_macos_sdk_path() sdk_path = self.get_macos_sdk_path()