1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 setuptools,
6 cython,
7 hypothesis,
8 numpy,
9 pytestCheckHook,
10 pythonOlder,
11 blis,
12 numpy_2,
13 gitUpdater,
14}:
15
16buildPythonPackage rec {
17 pname = "blis";
18 version = "1.0.2";
19 pyproject = true;
20
21 disabled = pythonOlder "3.9";
22
23 src = fetchFromGitHub {
24 owner = "explosion";
25 repo = "cython-blis";
26 rev = "refs/tags/release-v${version}";
27 hash = "sha256-J/EaJNmImcK4zScpbYPlQuoLyjoUkUgxUp6926P6rUQ=";
28 };
29
30 postPatch = ''
31 # The commit pinning numpy to version 2 doesn't have any functional changes:
32 # https://github.com/explosion/cython-blis/pull/108
33 # BLIS should thus work with numpy and numpy_2.
34 substituteInPlace pyproject.toml setup.py \
35 --replace-fail "numpy>=2.0.0,<3.0.0" numpy
36
37 # See https://github.com/numpy/numpy/issues/21079
38 # has no functional difference as the name is only used in log output
39 substituteInPlace blis/benchmark.py \
40 --replace-fail 'numpy.__config__.blas_ilp64_opt_info["libraries"]' '["dummy"]'
41 '';
42
43 preCheck = ''
44 # remove src module, so tests use the installed module instead
45 rm -rf ./blis
46 '';
47
48 build-system = [
49 setuptools
50 cython
51 numpy
52 ];
53
54 dependencies = [ numpy ];
55
56 nativeCheckInputs = [
57 hypothesis
58 pytestCheckHook
59 ];
60
61 pythonImportsCheck = [ "blis" ];
62
63 passthru = {
64 tests = {
65 numpy_2 = blis.overridePythonAttrs (old: {
66 numpy = numpy_2;
67 });
68 };
69 updateScript = gitUpdater {
70 rev-prefix = "release-v";
71 };
72 };
73
74 meta = with lib; {
75 changelog = "https://github.com/explosion/cython-blis/releases/tag/release-v${version}";
76 description = "BLAS-like linear algebra library";
77 homepage = "https://github.com/explosion/cython-blis";
78 license = licenses.bsd3;
79 maintainers = with maintainers; [ nickcao ];
80 };
81}