1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6 fetchpatch,
7 llvmPackages,
8 zlib,
9 cython_0,
10 oldest-supported-numpy,
11 setuptools,
12 wheel,
13 astunparse,
14 numpy,
15 packaging,
16 pyparsing,
17 scipy,
18 gsd,
19 networkx,
20 pandas,
21 pytest-xdist,
22 pytestCheckHook,
23 tables,
24 pythonAtLeast,
25}:
26
27buildPythonPackage rec {
28 pname = "mdtraj";
29 version = "1.10.0";
30 pyproject = true;
31
32 src = fetchFromGitHub {
33 owner = "mdtraj";
34 repo = "mdtraj";
35 rev = "refs/tags/${version}";
36 hash = "sha256-hNv/humEZOX4W7cOlJSAodk9pIi18//YJNSWNiEFiVg=";
37 };
38
39 patches = [
40 # disable intrinsics when SIMD is not available
41 # TODO: enable SIMD with python3.12
42 # https://github.com/mdtraj/mdtraj/pull/1884
43 (fetchpatch {
44 name = "fix-intrinsics-flag.patch";
45 url = "https://github.com/mdtraj/mdtraj/commit/d6041c645d51898e2a09030633210213eec7d4c5.patch";
46 hash = "sha256-kcnlHMoA/exJzV8iQltH+LWXrvSk7gsUV+yWK6xn0jg=";
47 })
48 ];
49
50 build-system = [
51 cython_0
52 oldest-supported-numpy
53 setuptools
54 wheel
55 ];
56
57 buildInputs = [ zlib ] ++ lib.optionals stdenv.cc.isClang [ llvmPackages.openmp ];
58
59 dependencies = [
60 astunparse
61 numpy
62 packaging
63 pyparsing
64 scipy
65 ];
66
67 env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-Wno-incompatible-function-pointer-types";
68
69 nativeCheckInputs = [
70 gsd
71 networkx
72 pandas
73 pytest-xdist
74 pytestCheckHook
75 tables
76 ];
77
78 preCheck = ''
79 cd tests
80 export PATH=$out/bin:$PATH
81 '';
82
83 disabledTests = [
84 # require network access
85 "test_pdb_from_url"
86 "test_1vii_url_and_gz"
87
88 # fail due to data race
89 "test_read_atomindices_1"
90 "test_read_atomindices_2"
91
92 # flaky test
93 "test_compare_rdf_t_master"
94 "test_distances_t"
95 "test_precentered_2"
96 ];
97
98 # these files import distutils
99 # remove once https://github.com/mdtraj/mdtraj/pull/1916 is merged
100 disabledTestPaths = lib.optionals (pythonAtLeast "3.12") [
101 "test_mol2.py"
102 "test_netcdf.py"
103 ];
104
105 pythonImportsCheck = [ "mdtraj" ];
106
107 meta = with lib; {
108 description = "Open library for the analysis of molecular dynamics trajectories";
109 homepage = "https://github.com/mdtraj/mdtraj";
110 changelog = "https://github.com/mdtraj/mdtraj/releases/tag/${lib.removePrefix "refs/tags/" src.rev}";
111 license = licenses.lgpl21Plus;
112 maintainers = with maintainers; [ natsukium ];
113 };
114}