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}:
25
26buildPythonPackage rec {
27 pname = "mdtraj";
28 version = "1.9.9";
29 pyproject = true;
30
31 src = fetchFromGitHub {
32 owner = "mdtraj";
33 repo = "mdtraj";
34 rev = "refs/tags/${version}";
35 hash = "sha256-2Jg6DyVJlRBLD/6hMtcsrAdxKF5RkpUuhAQm/lqVGeE=";
36 };
37
38 patches = [
39 (fetchpatch {
40 name = "gsd_3-compatibility.patch";
41 url = "https://github.com/mdtraj/mdtraj/commit/81209d00817ab07cfc4668bf5ec88088d16904c0.patch";
42 hash = "sha256-ttNmij7csxF0Z5wPPwhGumRX055W2IgFjRAe6nI6GNY=";
43 })
44 # remove pkg_resources usage
45 # https://github.com/mdtraj/mdtraj/pull/1837
46 (fetchpatch {
47 name = "fix-runtime-error.patch";
48 url = "https://github.com/mdtraj/mdtraj/commit/02d44d4db7039fceb199c85b4f993244804f470d.patch";
49 hash = "sha256-nhbi3iOrDSM87DyIp1KVt383Vvb6aYOgkjuYzviqiq8=";
50 })
51 # remove distutils usage
52 # https://github.com/mdtraj/mdtraj/pull/1834
53 (fetchpatch {
54 name = "python312-compatibility.patch";
55 url = "https://github.com/mdtraj/mdtraj/commit/95d79747deef42c976ca362a57806b61933409f3.patch";
56 hash = "sha256-Cq7/d745q6ZgAyWGM4ULnSsWezsbnu1CjSz5eqYSb+g=";
57 })
58 # disable intrinsics when SIMD is not available
59 # TODO: enable SIMD with python3.12
60 # https://github.com/mdtraj/mdtraj/pull/1884
61 (fetchpatch {
62 name = "fix-intrinsics-flag.patch";
63 url = "https://github.com/mdtraj/mdtraj/commit/d6041c645d51898e2a09030633210213eec7d4c5.patch";
64 hash = "sha256-kcnlHMoA/exJzV8iQltH+LWXrvSk7gsUV+yWK6xn0jg=";
65 })
66 ];
67
68 build-system = [
69 cython_0
70 oldest-supported-numpy
71 setuptools
72 wheel
73 ];
74
75 buildInputs = [ zlib ] ++ lib.optionals stdenv.cc.isClang [ llvmPackages.openmp ];
76
77 dependencies = [
78 astunparse
79 numpy
80 packaging
81 pyparsing
82 scipy
83 ];
84
85 env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-Wno-incompatible-function-pointer-types";
86
87 nativeCheckInputs = [
88 gsd
89 networkx
90 pandas
91 pytest-xdist
92 pytestCheckHook
93 tables
94 ];
95
96 preCheck = ''
97 cd tests
98 export PATH=$out/bin:$PATH
99 '';
100
101 disabledTests = [
102 # require network access
103 "test_pdb_from_url"
104 "test_1vii_url_and_gz"
105
106 # fail due to data race
107 "test_read_atomindices_1"
108 "test_read_atomindices_2"
109
110 # flaky test
111 "test_compare_rdf_t_master"
112 "test_distances_t"
113 "test_precentered_2"
114 ];
115
116 pythonImportsCheck = [ "mdtraj" ];
117
118 meta = with lib; {
119 description = "An open library for the analysis of molecular dynamics trajectories";
120 homepage = "https://github.com/mdtraj/mdtraj";
121 changelog = "https://github.com/mdtraj/mdtraj/releases/tag/${src.rev}";
122 license = licenses.lgpl21Plus;
123 maintainers = with maintainers; [ natsukium ];
124 };
125}