From ef35af3b1a20da6ffd65d4cd5859e83dad19728c Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Sun, 16 Mar 2025 14:36:07 -0400 Subject: [PATCH] python311: fix _ctypes build on darwin In Python 3.12+, the -DUSING_APPLE_OS_LIBFFI=1 macro is always set: https://github.com/python/cpython/commit/25590eb5dee5176f3ac60916b19450f8198e7ffc Fixes #390348 Signed-off-by: Ihar Hrachyshka --- pkgs/development/interpreters/python/cpython/default.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/development/interpreters/python/cpython/default.nix b/pkgs/development/interpreters/python/cpython/default.nix index 8a052a55b7da..6199c5d44ca1 100644 --- a/pkgs/development/interpreters/python/cpython/default.nix +++ b/pkgs/development/interpreters/python/cpython/default.nix @@ -434,6 +434,9 @@ in with passthru; stdenv.mkDerivation (finalAttrs: { for path in /usr /sw /opt /pkg; do substituteInPlace ./setup.py --replace-warn $path /no-such-path done + '' + optionalString (stdenv.hostPlatform.isDarwin && pythonOlder "3.12") '' + # Fix _ctypes module compilation + export NIX_CFLAGS_COMPILE+=" -DUSING_APPLE_OS_LIBFFI=1" '' + optionalString stdenv.hostPlatform.isDarwin '' # Override the auto-detection in setup.py, which assumes a universal build export PYTHON_DECIMAL_WITH_MACHINE=${if stdenv.hostPlatform.isAarch64 then "uint128" else "x64"}