Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions pkgs/development/python-modules/pybind11/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
, pytestCheckHook
, libxcrypt
, makeSetupHook
, darwin
}: let
setupHook = makeSetupHook {
name = "pybind11-setup-hook";
Expand All @@ -22,6 +23,19 @@
pythonSitePackages = "${python}/${python.sitePackages}";
};
} ./setup-hook.sh;

# clang 16 defaults to C++17, which results in the use of aligned allocations by pybind11.
# libc++ supports aligned allocations via `posix_memalign`, which is available since 10.6,
# but clang has a check hard-coded requiring 10.13 because that’s when Apple first shipped a
# support for C++17 aligned allocations on macOS.
# Tell clang we’re targeting 10.13 on x86_64-darwin while continuing to use the default SDK.
stdenv' = if stdenv.isDarwin && stdenv.isx86_64
then python.stdenv.override (oldStdenv: {
buildPlatform = oldStdenv.buildPlatform // { darwinMinVersion = "10.13"; };
targetPlatform = oldStdenv.targetPlatform // { darwinMinVersion = "10.13"; };
hostPlatform = oldStdenv.hostPlatform // { darwinMinVersion = "10.13"; };
})
else python.stdenv;
in buildPythonPackage rec {
pname = "pybind11";
version = "2.11.1";
Expand All @@ -41,6 +55,8 @@ in buildPythonPackage rec {
buildInputs = lib.optionals (pythonOlder "3.9") [ libxcrypt ];
propagatedBuildInputs = [ setupHook ];

stdenv = stdenv';

dontUseCmakeBuildDir = true;

# Don't build tests if not needed, read the doInstallCheck value at runtime
Expand Down