1{
2 buildPythonPackage,
3 lib,
4 setuptools,
5 stdenv,
6 fetchFromGitHub,
7 installShellFiles,
8 git,
9 coreutils,
10 versioneer,
11 # core
12 platformdirs,
13 chardet,
14 iso8601,
15 humanize,
16 fasteners,
17 packaging,
18 patool,
19 tqdm,
20 annexremote,
21 looseversion,
22 git-annex,
23 # downloaders
24 boto3,
25 keyrings-alt,
26 keyring,
27 msgpack,
28 requests,
29 # publish
30 python-gitlab,
31 # misc
32 argcomplete,
33 pyperclip,
34 python-dateutil,
35 # duecredit
36 duecredit,
37 distro,
38 # win
39 colorama,
40 # python-version-dependent
41 pythonOlder,
42 importlib-metadata,
43 typing-extensions,
44 # tests
45 pytest-xdist,
46 pytestCheckHook,
47 p7zip,
48 curl,
49 httpretty,
50}:
51
52buildPythonPackage rec {
53 pname = "datalad";
54 version = "1.2.1";
55 pyproject = true;
56
57 src = fetchFromGitHub {
58 owner = "datalad";
59 repo = "datalad";
60 tag = version;
61 hash = "sha256-QcKhMiJNlETlxmRoPwKKGYK7zKbJ0pQpbRZDyJ+yrN0=";
62 };
63
64 postPatch = ''
65 substituteInPlace datalad/distribution/create_sibling.py \
66 --replace-fail "/bin/ls" "${coreutils}/bin/ls"
67 # Remove vendorized versioneer.py
68 rm versioneer.py
69 '';
70
71 nativeBuildInputs = [
72 installShellFiles
73 git
74 ];
75
76 build-system = [
77 setuptools
78 versioneer
79 ];
80
81 dependencies =
82 optional-dependencies.core ++ optional-dependencies.downloaders ++ optional-dependencies.publish;
83
84 optional-dependencies = {
85 core = [
86 platformdirs
87 chardet
88 distro
89 iso8601
90 humanize
91 fasteners
92 packaging
93 patool
94 tqdm
95 annexremote
96 looseversion
97 ]
98 ++ lib.optionals stdenv.hostPlatform.isWindows [ colorama ]
99 ++ lib.optionals (pythonOlder "3.10") [ importlib-metadata ]
100 ++ lib.optionals (pythonOlder "3.11") [ typing-extensions ];
101 downloaders = [
102 boto3
103 keyrings-alt
104 keyring
105 msgpack
106 requests
107 ];
108 downloaders-extra = [
109 # requests-ftp # not in nixpkgs yet
110 ];
111 publish = [ python-gitlab ];
112 misc = [
113 argcomplete
114 pyperclip
115 python-dateutil
116 ];
117 duecredit = [ duecredit ];
118 };
119
120 postInstall = ''
121 installShellCompletion --cmd datalad \
122 --bash <($out/bin/datalad shell-completion) \
123 --zsh <($out/bin/datalad shell-completion)
124 wrapProgram $out/bin/datalad --prefix PYTHONPATH : "$PYTHONPATH"
125 '';
126
127 preCheck = ''
128 export HOME=$TMPDIR
129 '';
130
131 # tests depend on apps in $PATH which only will get installed after the test
132 disabledTests = [
133 # No such file or directory: 'datalad'
134 "test_script_shims"
135 "test_cfg_override"
136 "test_completion"
137 "test_nested_pushclone_cycle_allplatforms"
138 "test_create_sub_gh3463"
139 "test_create_sub_dataset_dot_no_path"
140 "test_cfg_passthrough"
141 "test_addurls_stdin_input_command_line"
142 "test_run_datalad_help"
143 "test_status_custom_summary_no_repeats"
144 "test_quoting"
145
146 # No such file or directory: 'git-annex-remote-[...]"
147 "test_create"
148 "test_ensure_datalad_remote_maybe_enable"
149
150 # "git-annex: unable to use external special remote git-annex-remote-datalad"
151 "test_ria_postclonecfg"
152 "test_ria_postclone_noannex"
153 "test_ria_push"
154 "test_basic_scenario"
155 "test_annex_get_from_subdir"
156 "test_ensure_datalad_remote_init_and_enable_needed"
157 "test_ensure_datalad_remote_maybe_enable[False]"
158 "test_ensure_datalad_remote_maybe_enable[True]"
159 "test_create_simple"
160 "test_create_alias"
161 "test_storage_only"
162 "test_initremote"
163 "test_read_access"
164 "test_ephemeral"
165 "test_initremote_basic_fileurl"
166 "test_initremote_basic_httpurl"
167 "test_remote_layout"
168 "test_version_check"
169 "test_gitannex_local"
170 "test_push_url"
171 "test_url_keys"
172 "test_obtain_permission_root"
173 "test_source_candidate_subdataset"
174 "test_update_fetch_all"
175 "test_add_archive_dirs"
176 "test_add_archive_content"
177 "test_add_archive_content_strip_leading"
178 "test_add_archive_content_zip"
179 "test_add_archive_content_absolute_path"
180 "test_add_archive_use_archive_dir"
181 "test_add_archive_single_file"
182 "test_add_delete"
183 "test_add_archive_leading_dir"
184 "test_add_delete_after_and_drop"
185 "test_add_delete_after_and_drop_subdir"
186 "test_override_existing_under_git"
187 "test_copy_file_datalad_specialremote"
188 "test_download_url_archive"
189 "test_download_url_archive_from_subdir"
190 "test_download_url_archive_trailing_separator"
191 "test_download_url_need_datalad_remote"
192 "test_datalad_credential_helper - assert False"
193
194 # need internet access
195 "test_clone_crcns"
196 "test_clone_datasets_root"
197 "test_reckless"
198 "test_autoenabled_remote_msg"
199 "test_ria_http_storedataladorg"
200 "test_gin_cloning"
201 "test_nonuniform_adjusted_subdataset"
202 "test_install_datasets_root"
203 "test_install_simple_local"
204 "test_install_dataset_from_just_source"
205 "test_install_dataset_from_just_source_via_path"
206 "test_datasets_datalad_org"
207 "test_get_cached_dataset"
208 "test_cached_dataset"
209 "test_cached_url"
210 "test_anonymous_s3"
211 "test_protocols"
212 "test_get_versioned_url_anon"
213 "test_install_recursive_github"
214 "test_failed_install_multiple"
215
216 # pbcopy not found
217 "test_wtf"
218
219 # CommandError: 'git -c diff.ignoreSubmodules=none -c core.quotepath=false ls-files -z -m -d' failed with exitcode 128
220 "test_subsuperdataset_save"
221 ];
222
223 nativeCheckInputs = [
224 p7zip
225 pytest-xdist
226 pytestCheckHook
227 git-annex
228 curl
229 httpretty
230 ];
231
232 pytestFlags = [
233 # Deprecated in 3.13. Use exc_type_str instead.
234 "-Wignore::DeprecationWarning"
235 ];
236
237 pythonImportsCheck = [ "datalad" ];
238
239 meta = {
240 description = "Keep code, data, containers under control with git and git-annex";
241 homepage = "https://www.datalad.org";
242 license = lib.licenses.mit;
243 maintainers = with lib.maintainers; [ renesat ];
244 };
245}