about summary refs log tree commit diff
path: root/pkgs/development/python-modules/freud/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/python-modules/freud/default.nix')
-rw-r--r--pkgs/development/python-modules/freud/default.nix93
1 files changed, 53 insertions, 40 deletions
diff --git a/pkgs/development/python-modules/freud/default.nix b/pkgs/development/python-modules/freud/default.nix
index e5b7767343676..a681bd1f14b13 100644
--- a/pkgs/development/python-modules/freud/default.nix
+++ b/pkgs/development/python-modules/freud/default.nix
@@ -1,34 +1,46 @@
-{ lib
-, stdenv
-, buildPythonPackage
-, fetchFromGitHub
-, cmake
-, cython
-, oldest-supported-numpy
-, scikit-build
-, setuptools
-, tbb
-, numpy
-, rowan
-, scipy
-, pytest
-, gsd
-, matplotlib
-, sympy
+{
+  lib,
+  stdenv,
+  buildPythonPackage,
+  fetchFromGitHub,
+  fetchpatch,
+  cmake,
+  cython,
+  oldest-supported-numpy,
+  scikit-build,
+  setuptools,
+  tbb,
+  numpy,
+  rowan,
+  scipy,
+  pytestCheckHook,
+  python,
+  gsd,
+  matplotlib,
+  sympy,
 }:
 
 buildPythonPackage rec {
   pname = "freud";
-  version = "3.0.0";
+  version = "3.1.0";
   pyproject = true;
 
   src = fetchFromGitHub {
     owner = "glotzerlab";
     repo = "freud";
-    rev = "v${version}";
-    hash = "sha256-aKh2Gub1vU/wzvWkCl8yzlIswp8CtR975USiCr6ijUI=";
+    rev = "refs/tags/v${version}";
+    hash = "sha256-jlscEHQ1q4oqxE06NhVWCOlPRcjDcJVrvy4h6iYrkz0=";
     fetchSubmodules = true;
   };
+
+  patches = [
+    # https://github.com/glotzerlab/freud/issues/1269
+    (fetchpatch {
+      url = "https://github.com/glotzerlab/freud/commit/8f636e3815737945e45da5b9996b5f69df07c9a5.patch";
+      hash = "sha256-PLorRrYj16oBWHYzXDq62kECzVTtyr+1Z20DJqTkXxg=";
+    })
+  ];
+
   # Because we prefer to not `leaveDotGit`, we need to fool upstream into
   # thinking we left the .git files in the submodules, so cmake won't think we
   # didn't initialize them. Upstream doesn't support using the system wide
@@ -39,6 +51,13 @@ buildPythonPackage rec {
     touch extern/{voro++,fsph,Eigen}/.git
   '';
 
+  # Scipy still depends on numpy 1, and so we'd get 'package duplicates in
+  # closure' error if we'd use numpy_2
+  postPatch = ''
+    substituteInPlace pyproject.toml \
+      --replace-fail 'numpy>=2.0.0rc1' 'numpy' \
+  '';
+
   nativeBuildInputs = [
     cmake
     cython
@@ -47,9 +66,7 @@ buildPythonPackage rec {
     setuptools
   ];
   dontUseCmakeConfigure = true;
-  buildInputs = [
-    tbb
-  ];
+  buildInputs = [ tbb ];
 
   propagatedBuildInputs = [
     numpy
@@ -58,33 +75,29 @@ buildPythonPackage rec {
   ];
 
   nativeCheckInputs = [
-    # Encountering circular ImportError issues with pytestCheckHook, see also:
-    # https://github.com/NixOS/nixpkgs/issues/255262
-    pytest
+    pytestCheckHook
     gsd
     matplotlib
     sympy
   ];
-  checkPhase = ''
-    runHook preCheck
-
-    pytest
-
-    runHook postCheck
+  disabledTests = lib.optionals stdenv.isAarch64 [
+    # https://github.com/glotzerlab/freud/issues/961
+    "test_docstring"
+  ];
+  # On top of cd $out due to https://github.com/NixOS/nixpkgs/issues/255262 ,
+  # we need to also copy the tests because otherwise pytest won't find them.
+  preCheck = ''
+    cp -R tests $out/${python.sitePackages}/freud/tests
+    cd $out
   '';
-  # Some tests fail on aarch64. If we could have used pytestCheckHook, we would
-  # have disabled only the tests that fail with the disabledTests attribute.
-  # But that is not possible unfortunately. See upstream report for the
-  # failure: https://github.com/glotzerlab/freud/issues/961
-  doCheck = !stdenv.isAarch64;
 
   pythonImportsCheck = [ "freud" ];
 
-  meta = with lib; {
+  meta = {
     description = "Powerful, efficient particle trajectory analysis in scientific Python";
     homepage = "https://github.com/glotzerlab/freud";
     changelog = "https://github.com/glotzerlab/freud/blob/${src.rev}/ChangeLog.md";
-    license = licenses.bsd3;
-    maintainers = with maintainers; [ doronbehar ];
+    license = lib.licenses.bsd3;
+    maintainers = with lib.maintainers; [ doronbehar ];
   };
 }