diff --git a/pkgs/development/interpreters/python/hooks/default.nix b/pkgs/development/interpreters/python/hooks/default.nix index 001e477b9185b2..d75895b819fd7d 100644 --- a/pkgs/development/interpreters/python/hooks/default.nix +++ b/pkgs/development/interpreters/python/hooks/default.nix @@ -71,6 +71,15 @@ in { }; } ./pip-install-hook.sh) {}; + pypaBuildHook = callPackage ({ makePythonHook, build, wheel }: + makePythonHook { + name = "pypa-build-hook.sh"; + propagatedBuildInputs = [ build wheel ]; + substitutions = { + inherit pythonInterpreter; + }; + } ./pypa-build-hook.sh) {}; + pytestCheckHook = callPackage ({ makePythonHook, pytest }: makePythonHook { name = "pytest-check-hook"; diff --git a/pkgs/development/interpreters/python/hooks/pypa-build-hook.sh b/pkgs/development/interpreters/python/hooks/pypa-build-hook.sh new file mode 100644 index 00000000000000..add5866ca37485 --- /dev/null +++ b/pkgs/development/interpreters/python/hooks/pypa-build-hook.sh @@ -0,0 +1,19 @@ +# Setup hook to use for pypa/build projects +echo "Sourcing pypa-build-hook" + +pypaBuildPhase() { + echo "Executing pypaBuildPhase" + runHook preBuild + + echo "Creating a wheel..." + @pythonInterpreter@ -m build --no-isolation --outdir dist/ $pypaBuildFlags + echo "Finished creating a wheel..." + + runHook postBuild + echo "Finished executing pypaBuildPhase" +} + +if [ -z "${dontUsePypaBuild-}" ] && [ -z "${buildPhase-}" ]; then + echo "Using pypaBuildPhase" + buildPhase=pypaBuildPhase +fi diff --git a/pkgs/development/interpreters/python/mk-python-derivation.nix b/pkgs/development/interpreters/python/mk-python-derivation.nix index 17b5667e8ee9c8..c601729a823796 100644 --- a/pkgs/development/interpreters/python/mk-python-derivation.nix +++ b/pkgs/development/interpreters/python/mk-python-derivation.nix @@ -14,6 +14,7 @@ , flitBuildHook , pipBuildHook , pipInstallHook +, pypaBuildHook , pythonCatchConflictsHook , pythonImportsCheckHook , pythonNamespacesHook diff --git a/pkgs/development/python-modules/scipy/default.nix b/pkgs/development/python-modules/scipy/default.nix index 1090e724a7fd3f..4df6816428681c 100644 --- a/pkgs/development/python-modules/scipy/default.nix +++ b/pkgs/development/python-modules/scipy/default.nix @@ -1,9 +1,12 @@ { lib , stdenv , fetchPypi +, pypaBuildHook , python , pythonOlder , buildPythonPackage +, blas +, lapack , cython , gfortran , meson-python @@ -19,6 +22,8 @@ , libxcrypt }: +assert blas.provider == numpy.blas; + buildPythonPackage rec { pname = "scipy"; version = "1.10.1"; @@ -36,10 +41,33 @@ buildPythonPackage rec { ./disable-datasets-tests.patch ]; - nativeBuildInputs = [ cython gfortran meson-python pythran pkg-config wheel ]; + # The pybind11 issue seems to have already been address by 2.10.3 + # https://github.com/pybind/pybind11/issues/4420 + # + # We should update pythran + # + # Numpy is pinned at patch versions, probably as a way to choose from a set + # of wheels published in pypi? + postPatch = '' + substituteInPlace pyproject.toml \ + --replace "pybind11==2.10.1" "pybind11>=2.10.3" \ + --replace '"pythran>=0.12.0,<0.13.0",' "" \ + --replace "numpy==" "numpy>=" + ''; + + nativeBuildInputs = [ + pypaBuildHook + cython + gfortran + meson-python + pythran + pkg-config + wheel + ]; buildInputs = [ - numpy.blas + blas + lapack pybind11 pooch ] ++ lib.optionals (pythonOlder "3.9") [ @@ -67,6 +95,15 @@ buildPythonPackage rec { # hardeningDisable = lib.optionals (stdenv.isAarch64 && stdenv.isDarwin) [ "stackprotector" ]; + dontUsePipBuild = true; + pypaBuildFlags = [ + # Skip sdist + "--wheel" + + "-Csetup-args=-Dblas=cblas" + "-Csetup-args=-Dlapack=lapacke" + ]; + checkPhase = '' runHook preCheck pushd "$out" @@ -82,8 +119,6 @@ buildPythonPackage rec { blas = numpy.blas; }; - setupPyBuildFlags = [ "--fcompiler='gnu95'" ]; - SCIPY_USE_G77_ABI_WRAPPER = 1; meta = with lib; {