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