Skip to content

Commit 3344ccc

Browse files
freakboy3742seiko2plus
authored andcommitted
Add numpy specific extensions for iOS builds.
Sayed: Fix BLAS/LAPACK 3.14 subprocess encoding; guard ios_ver for mypy < 3.13
1 parent e1c7a6f commit 3344ccc

2 files changed

Lines changed: 24 additions & 5 deletions

File tree

docs/markdown/Dependencies.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -472,10 +472,11 @@ TODO
472472

473473
Supports the BLAS and LAPACK components of macOS Accelerate, also referred to
474474
as the vecLib framework. ILP64 support is only available on macOS 13.3 and up.
475-
From macOS 13.3, Accelerate ships with two different builds of 32-bit (LP64)
476-
BLAS and LAPACK. Meson will default to the newer of those builds, by defining
477-
`ACCELERATE_NEW_LAPACK`, unless `MACOS_DEPLOYMENT_TARGET` is set to a version
478-
lower than 13.3.
475+
From macOS 13.3 and iOS 16.4, Accelerate ships with two different builds of
476+
32-bit (LP64) BLAS and LAPACK. Meson will default to the newer of those builds,
477+
by defining `ACCELERATE_NEW_LAPACK`, unless `MACOS_DEPLOYMENT_TARGET` is set to
478+
a version lower than 13.3, or `IPHONEOS_DEPLOYMENT_TARGET` is set to a version
479+
lower than 16.4.
479480

480481
```meson
481482
accelerate_dep = dependency('accelerate',

mesonbuild/dependencies/blas_lapack.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,10 @@ def __init__(self, name: str, environment: 'Environment', kwargs: 'DependencyObj
773773
self.parse_modules(kwargs)
774774

775775
for_machine = MachineChoice.BUILD if kwargs.get('native', False) else MachineChoice.HOST
776-
if environment.machines[for_machine].is_darwin() and self.check_macOS_recent_enough():
776+
if (
777+
(environment.machines[for_machine].system == 'darwin' and self.check_macOS_recent_enough())
778+
or (environment.machines[for_machine].system == 'ios' and self.check_iOS_recent_enough())
779+
):
777780
self.detect(kwargs)
778781

779782
def check_macOS_recent_enough(self) -> bool:
@@ -787,6 +790,21 @@ def check_macOS_recent_enough(self) -> bool:
787790
sdk_version = subprocess.run(cmd, capture_output=True, check=True, encoding='utf-8').stdout.strip()
788791
return mesonlib.version_compare(sdk_version, '>=13.3')
789792

793+
def check_iOS_recent_enough(self) -> bool:
794+
if sys.version_info < (3, 13):
795+
# platform.ios_ver() is only available since Python 3.13
796+
return False
797+
ios_version = platform.ios_ver().system
798+
deploy_target = os.environ.get('IPHONEOS_DEPLOYMENT_TARGET', ios_version)
799+
if not mesonlib.version_compare(deploy_target, '>=16.4'):
800+
return False
801+
802+
# We also need the SDK to be >=16.4
803+
sdk = "iphonesimulator" if platform.ios_ver().is_simulator else "iphoneos"
804+
cmd = ['xcrun', '-sdk', sdk, '--show-sdk-version']
805+
sdk_version = subprocess.run(cmd, capture_output=True, check=True, encoding='utf-8').stdout.strip()
806+
return mesonlib.version_compare(sdk_version, '>=16.4')
807+
790808
def detect(self, kwargs: 'DependencyObjectKWs') -> None:
791809
from .framework import ExtraFrameworkDependency
792810
dep = ExtraFrameworkDependency('Accelerate', self.env, kwargs)

0 commit comments

Comments
 (0)