1{
2 stdenv,
3 buildPythonPackage,
4 fetchFromGitHub,
5 pythonOlder,
6 lib,
7 cmake,
8 setuptools,
9 typing-extensions,
10 pybind11,
11 pytestCheckHook,
12}:
13
14buildPythonPackage rec {
15 pname = "optree";
16 version = "0.11.0";
17 pyproject = true;
18
19 disabled = pythonOlder "3.7";
20
21 src = fetchFromGitHub {
22 owner = "metaopt";
23 repo = pname;
24 rev = "v${version}";
25 hash = "sha256-VnnnEoXkYJO+S7baH+JZvsW18Tk3TiY9+Cd230OlZWo=";
26 };
27
28 dontUseCmakeConfigure = true;
29
30 propagatedBuildInputs = [ typing-extensions ];
31 nativeBuildInputs = [
32 setuptools
33 pybind11
34 cmake
35 ];
36
37 nativeCheckInputs = [ pytestCheckHook ];
38 # prevent import failures from pytest
39 preCheck = ''
40 rm -r optree
41 '';
42 disabledTests = [
43 # Fails because the 'test_treespec' module can't be found
44 "test_treespec_pickle_missing_registration"
45 ];
46 pythonImportsCheck = [ "optree" ];
47
48 meta = with lib; {
49 homepage = "https://github.com/metaopt/optree";
50 changelog = "https://github.com/metaopt/optree/releases/tag/v${version}";
51 description = "Optimized PyTree Utilities";
52 maintainers = with maintainers; [ pandapip1 ];
53 license = licenses.asl20;
54 };
55}