1{
2 lib,
3 buildPythonPackage,
4 pythonOlder,
5 fetchFromGitHub,
6 hatch-vcs,
7 hatchling,
8 interface-meta,
9 narwhals,
10 numpy,
11 pandas,
12 scipy,
13 typing-extensions,
14 wrapt,
15 pyarrow,
16 polars,
17 sympy,
18 pytestCheckHook,
19}:
20
21buildPythonPackage rec {
22 pname = "formulaic";
23 version = "1.2.1";
24 pyproject = true;
25
26 disabled = pythonOlder "3.9";
27
28 src = fetchFromGitHub {
29 owner = "matthewwardrop";
30 repo = "formulaic";
31 tag = "v${version}";
32 hash = "sha256-mZt+cwk/AaUmmeCj7aLu1QEBqlPUVUqQbYdgETMj/vY=";
33 };
34
35 env.SETUPTOOLS_SCM_PRETEND_VERSION = version;
36
37 build-system = [
38 hatchling
39 hatch-vcs
40 ];
41
42 dependencies = [
43 narwhals
44 numpy
45 pandas
46 scipy
47 wrapt
48 typing-extensions
49 interface-meta
50 ];
51
52 optional-dependencies = {
53 arrow = [ pyarrow ];
54 polars = [ polars ];
55 calculus = [ sympy ];
56 };
57
58 nativeCheckInputs = [
59 pytestCheckHook
60 ]
61 ++ optional-dependencies.arrow
62 ++ optional-dependencies.calculus;
63
64 pythonImportsCheck = [ "formulaic" ];
65
66 meta = with lib; {
67 description = "High-performance implementation of Wilkinson formulas";
68 homepage = "https://matthewwardrop.github.io/formulaic/";
69 changelog = "https://github.com/matthewwardrop/formulaic/releases/tag/${src.tag}";
70 license = licenses.mit;
71 maintainers = with maintainers; [ swflint ];
72 };
73}