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