summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/datalad/default.nix
blob: 864870560936efe506d30ae1811640321d291da3 (plain)
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
{
  buildPythonPackage,
  lib,
  setuptools,
  stdenv,
  fetchFromGitHub,
  pythonAtLeast,
  installShellFiles,
  git,
  versioneer,
  # core
  platformdirs,
  chardet,
  iso8601,
  humanize,
  fasteners,
  packaging,
  patool,
  tqdm,
  annexremote,
  looseversion,
  git-annex,
  # downloaders
  boto3,
  keyrings-alt,
  keyring,
  msgpack,
  requests,
  # publish
  python-gitlab,
  # misc
  argcomplete,
  pyperclip,
  python-dateutil,
  # duecredit
  duecredit,
  distro,
  # win
  colorama,
  # python-version-dependent
  pythonOlder,
  typing-extensions,
  # tests
  pytest-xdist,
  pytestCheckHook,
  p7zip,
  curl,
  httpretty,
}:

buildPythonPackage rec {
  pname = "datalad";
  version = "1.2.3";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "datalad";
    repo = "datalad";
    tag = version;
    hash = "sha256-C3e9k4RDFfDMaimZ/7TtAJNzdlfVrKoTHVl0zKL9EjI=";
  };

  postPatch = ''
    # Remove vendorized versioneer.py
    rm versioneer.py
  '';

  nativeBuildInputs = [
    installShellFiles
    git
  ];

  build-system = [
    setuptools
    versioneer
  ];

  dependencies =
    optional-dependencies.core ++ optional-dependencies.downloaders ++ optional-dependencies.publish;

  optional-dependencies = {
    core = [
      platformdirs
      chardet
      distro
      iso8601
      humanize
      fasteners
      packaging
      patool
      tqdm
      annexremote
      looseversion
    ]
    ++ lib.optionals stdenv.hostPlatform.isWindows [ colorama ]
    ++ lib.optionals (pythonOlder "3.11") [ typing-extensions ];
    downloaders = [
      boto3
      keyrings-alt
      keyring
      msgpack
      requests
    ];
    downloaders-extra = [
      # requests-ftp # not in nixpkgs yet
    ];
    publish = [ python-gitlab ];
    misc = [
      argcomplete
      pyperclip
      python-dateutil
    ];
    duecredit = [ duecredit ];
  };

  postInstall = ''
    installShellCompletion --cmd datalad \
      --bash <($out/bin/datalad shell-completion) \
      --zsh  <($out/bin/datalad shell-completion)
    wrapProgram $out/bin/datalad \
      --prefix PATH : "${git-annex}/bin" \
      --prefix PYTHONPATH : "$PYTHONPATH"
  '';

  preCheck = ''
    export HOME=$TMPDIR
  '';

  # tests depend on apps in $PATH which only will get installed after the test
  disabledTests = [
    # No such file or directory: 'datalad'
    "test_script_shims"
    "test_cfg_override"
    "test_completion"
    "test_nested_pushclone_cycle_allplatforms"
    "test_create_sub_gh3463"
    "test_create_sub_dataset_dot_no_path"
    "test_cfg_passthrough"
    "test_addurls_stdin_input_command_line"
    "test_run_datalad_help"
    "test_status_custom_summary_no_repeats"
    "test_quoting"

    #  No such file or directory: 'git-annex-remote-[...]"
    "test_create"
    "test_ensure_datalad_remote_maybe_enable"

    # "git-annex: unable to use external special remote git-annex-remote-datalad"
    "test_ria_postclonecfg"
    "test_ria_postclone_noannex"
    "test_ria_push"
    "test_basic_scenario"
    "test_annex_get_from_subdir"
    "test_ensure_datalad_remote_init_and_enable_needed"
    "test_ensure_datalad_remote_maybe_enable[False]"
    "test_ensure_datalad_remote_maybe_enable[True]"
    "test_create_simple"
    "test_create_alias"
    "test_storage_only"
    "test_initremote"
    "test_read_access"
    "test_ephemeral"
    "test_initremote_basic_fileurl"
    "test_initremote_basic_httpurl"
    "test_remote_layout"
    "test_version_check"
    "test_gitannex_local"
    "test_push_url"
    "test_url_keys"
    "test_obtain_permission_root"
    "test_source_candidate_subdataset"
    "test_update_fetch_all"
    "test_add_archive_dirs"
    "test_add_archive_content"
    "test_add_archive_content_strip_leading"
    "test_add_archive_content_zip"
    "test_add_archive_content_absolute_path"
    "test_add_archive_use_archive_dir"
    "test_add_archive_single_file"
    "test_add_delete"
    "test_add_archive_leading_dir"
    "test_add_delete_after_and_drop"
    "test_add_delete_after_and_drop_subdir"
    "test_override_existing_under_git"
    "test_copy_file_datalad_specialremote"
    "test_download_url_archive"
    "test_download_url_archive_from_subdir"
    "test_download_url_archive_trailing_separator"
    "test_download_url_need_datalad_remote"
    "test_datalad_credential_helper - assert False"

    # need internet access
    "test_clone_crcns"
    "test_clone_datasets_root"
    "test_reckless"
    "test_autoenabled_remote_msg"
    "test_ria_http_storedataladorg"
    "test_gin_cloning"
    "test_nonuniform_adjusted_subdataset"
    "test_install_datasets_root"
    "test_install_simple_local"
    "test_install_dataset_from_just_source"
    "test_install_dataset_from_just_source_via_path"
    "test_datasets_datalad_org"
    "test_get_cached_dataset"
    "test_cached_dataset"
    "test_cached_url"
    "test_anonymous_s3"
    "test_protocols"
    "test_get_versioned_url_anon"
    "test_install_recursive_github"
    "test_failed_install_multiple"

    # pbcopy not found
    "test_wtf"

    # CommandError: 'git -c diff.ignoreSubmodules=none -c core.quotepath=false ls-files -z -m -d' failed with exitcode 128
    "test_subsuperdataset_save"
  ]
  ++ lib.optionals (pythonAtLeast "3.14") [
    # For all: https://github.com/datalad/datalad/issues/7781
    # AssertionError: `assert 1 == 0` (refcount error)
    "test_GitRepo_flyweight"
    "test_Dataset_flyweight"
    "test_AnnexRepo_flyweight"
    # TypeError: cannot pickle '_thread.lock' object
    "test_popen_invocation"
    # datalad.runner.exception.CommandError: '/python3.14 -i -u -q -']' timed out after 0.5 seconds
    "test_asyncio_loop_noninterference1"
  ];

  nativeCheckInputs = [
    p7zip
    pytest-xdist
    pytestCheckHook
    git-annex
    curl
    httpretty
  ];

  pytestFlags = [
    # Deprecated in 3.13. Use exc_type_str instead.
    "-Wignore::DeprecationWarning"
  ];

  pythonImportsCheck = [ "datalad" ];

  meta = {
    description = "Keep code, data, containers under control with git and git-annex";
    homepage = "https://www.datalad.org";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [
      renesat
      malik
    ];
  };
}