Skip to content

Commit cc97b83

Browse files
committed
Use host sysconfig for PYO3 cross lib dir
Adjust cross-build sysconfig handling for pyo3 on Apple platforms. Add a host_sysconfig attribute to CrossVEnv and set PYO3_CROSS_LIB_DIR to the host_sysconfig.parent (the directory containing _sysconfigdata__*.py), falling back to <prefix>/lib when host_sysconfig is unavailable. Also comment out the recipe-level _PYTHON_SYSCONFIGDATA_NAME script_env entry. These changes address newer Apple support layouts that place sysconfig data outside the venv prefix/lib.
1 parent e0e6c96 commit cc97b83

3 files changed

Lines changed: 14 additions & 5 deletions

File tree

recipes/pydantic-core/meta.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ package:
22
name: pydantic-core
33
version: 2.33.2
44

5-
build:
6-
script_env:
7-
_PYTHON_SYSCONFIGDATA_NAME: '{sysconfigdata_name}'
5+
# build:
6+
# script_env:
7+
# _PYTHON_SYSCONFIGDATA_NAME: '{sysconfigdata_name}'

src/forge/build.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,14 @@ def compile_env(self, **kwargs) -> dict[str, str]:
378378
"PYO3_CROSS_PYTHON_VERSION": self.cross_venv.sysconfig_data[
379379
"py_version_short"
380380
],
381-
"PYO3_CROSS_LIB_DIR": "{}/lib".format(
382-
self.cross_venv.sysconfig_data["prefix"]
381+
# pyo3 expects a directory containing _sysconfigdata__*.py.
382+
# Newer Apple support layouts place this outside prefix/lib.
383+
"PYO3_CROSS_LIB_DIR": str(
384+
(
385+
self.cross_venv.host_sysconfig.parent
386+
if self.cross_venv.host_sysconfig is not None
387+
else Path(self.cross_venv.sysconfig_data["prefix"]) / "lib"
388+
)
383389
),
384390
}
385391
env.update(kwargs)

src/forge/cross.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ def __init__(self, sdk, sdk_version, arch):
105105
self._scheme_paths = None
106106
self._install_root = None
107107
self._sdk_root = None
108+
self.host_sysconfig = None
108109

109110
def __str__(self):
110111
return self.venv_name
@@ -315,6 +316,8 @@ def create(
315316
)
316317
self.sysconfigdata_name = host_sysconfig.stem
317318

319+
self.host_sysconfig = host_sysconfig
320+
318321
if self.host_os != "iOS" and not host_sysconfig.is_file():
319322
raise RuntimeError(f"Can't find host sysconfig {host_sysconfig}")
320323

0 commit comments

Comments
 (0)