1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6
7 # build-system
8 setuptools,
9 cython,
10 numpy,
11
12 # tests
13 hypothesis,
14 pytestCheckHook,
15
16 # passthru
17 blis,
18 numpy_1,
19 gitUpdater,
20}:
21
22buildPythonPackage rec {
23 pname = "blis";
24 version = "1.3.0";
25 pyproject = true;
26
27 src = fetchFromGitHub {
28 owner = "explosion";
29 repo = "cython-blis";
30 tag = "release-v${version}";
31 hash = "sha256-mSIfFjnLhPLqSNLHMS5gTeAmqmNfXpcbyH7ejv4YgQU=";
32 };
33
34 build-system = [
35 setuptools
36 cython
37 numpy
38 ];
39
40 env =
41 # Fallback to generic architectures when necessary:
42 # https://github.com/explosion/cython-blis?tab=readme-ov-file#building-blis-for-alternative-architectures
43 lib.optionalAttrs
44 (
45 # error: [Errno 2] No such file or directory: '/build/source/blis/_src/make/linux-cortexa57.jsonl'
46 (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64)
47
48 # clang: error: unknown argument '-mavx512pf'; did you mean '-mavx512f'?
49 # Patching blis/_src/config/knl/make_defs.mk to remove the said flag does not work
50 || (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64)
51 )
52 {
53 BLIS_ARCH = "generic";
54 };
55
56 dependencies = [ numpy ];
57
58 pythonImportsCheck = [ "blis" ];
59
60 nativeCheckInputs = [
61 hypothesis
62 pytestCheckHook
63 ];
64
65 # remove src module, so tests use the installed module instead
66 preCheck = ''
67 rm -rf ./blis
68 '';
69
70 disabledTestPaths = [
71 # ImportError: cannot import name 'NO_CONJUGATE' from 'blis.cy'
72 "tests/test_dotv.py"
73 ];
74
75 passthru = {
76 tests = {
77 numpy_1 = blis.overridePythonAttrs (old: {
78 numpy = numpy_1;
79 });
80 };
81 updateScript = gitUpdater {
82 rev-prefix = "release-v";
83 };
84 };
85
86 meta = {
87 changelog = "https://github.com/explosion/cython-blis/releases/tag/release-v${version}";
88 description = "BLAS-like linear algebra library";
89 homepage = "https://github.com/explosion/cython-blis";
90 license = lib.licenses.bsd3;
91 maintainers = with lib.maintainers; [ nickcao ];
92 };
93}