about summary refs log tree commit diff
path: root/pkgs/development/python-modules/mdtraj/default.nix
blob: e4a2dc8587e8c80b50d50406f2385757e6220d01 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
{
  lib,
  stdenv,
  buildPythonPackage,
  fetchFromGitHub,
  fetchpatch,
  llvmPackages,
  zlib,
  cython_0,
  oldest-supported-numpy,
  setuptools,
  wheel,
  astunparse,
  numpy,
  packaging,
  pyparsing,
  scipy,
  gsd,
  networkx,
  pandas,
  pytest-xdist,
  pytestCheckHook,
  tables,
  pythonAtLeast,
}:

buildPythonPackage rec {
  pname = "mdtraj";
  version = "1.10.0";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "mdtraj";
    repo = "mdtraj";
    rev = "refs/tags/${version}";
    hash = "sha256-hNv/humEZOX4W7cOlJSAodk9pIi18//YJNSWNiEFiVg=";
  };

  patches = [
    # disable intrinsics when SIMD is not available
    # TODO: enable SIMD with python3.12
    # https://github.com/mdtraj/mdtraj/pull/1884
    (fetchpatch {
      name = "fix-intrinsics-flag.patch";
      url = "https://github.com/mdtraj/mdtraj/commit/d6041c645d51898e2a09030633210213eec7d4c5.patch";
      hash = "sha256-kcnlHMoA/exJzV8iQltH+LWXrvSk7gsUV+yWK6xn0jg=";
    })
  ];

  build-system = [
    cython_0
    oldest-supported-numpy
    setuptools
    wheel
  ];

  buildInputs = [ zlib ] ++ lib.optionals stdenv.cc.isClang [ llvmPackages.openmp ];

  dependencies = [
    astunparse
    numpy
    packaging
    pyparsing
    scipy
  ];

  env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-Wno-incompatible-function-pointer-types";

  nativeCheckInputs = [
    gsd
    networkx
    pandas
    pytest-xdist
    pytestCheckHook
    tables
  ];

  preCheck = ''
    cd tests
    export PATH=$out/bin:$PATH
  '';

  disabledTests = [
    # require network access
    "test_pdb_from_url"
    "test_1vii_url_and_gz"

    # fail due to data race
    "test_read_atomindices_1"
    "test_read_atomindices_2"

    # flaky test
    "test_compare_rdf_t_master"
    "test_distances_t"
    "test_precentered_2"
  ];

  # these files import distutils
  # remove once https://github.com/mdtraj/mdtraj/pull/1916 is merged
  disabledTestPaths = lib.optionals (pythonAtLeast "3.12") [
    "test_mol2.py"
    "test_netcdf.py"
  ];

  pythonImportsCheck = [ "mdtraj" ];

  meta = with lib; {
    description = "Open library for the analysis of molecular dynamics trajectories";
    homepage = "https://github.com/mdtraj/mdtraj";
    changelog = "https://github.com/mdtraj/mdtraj/releases/tag/${lib.removePrefix "refs/tags/" src.rev}";
    license = licenses.lgpl21Plus;
    maintainers = with maintainers; [ natsukium ];
  };
}