-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathmain.py
1367 lines (1187 loc) · 53.6 KB
/
main.py
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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import bisect
import copy
import fnmatch
import json
import os
import re
import sys
from collections import defaultdict
from os.path import dirname, isdir, isfile, join
from conda.models.version import VersionOrder
import requests
CHANNEL_NAME = "main"
CHANNEL_ALIAS = "https://repo.anaconda.com/pkgs"
SUBDIRS = (
"noarch",
"linux-32",
"linux-64",
"linux-aarch64",
"linux-armv6l",
"linux-armv7l",
"linux-ppc64le",
"linux-s390x",
"osx-64",
"osx-arm64",
"win-32",
"win-64",
)
REMOVALS = {
"noarch": (),
"linux-ppc64le": [
# This build contains incorrect libffi run depends; removing rather
# than patching to prevent solver from getting stuck in a bistable
# solution (since another build has the same set of requirements).
"cffi-1.14.6-py36h140841e_0.tar.bz2",
"cffi-1.14.6-py37h140841e_0.tar.bz2",
"cffi-1.14.6-py38h140841e_0.tar.bz2",
"cffi-1.14.6-py39h140841e_0.tar.bz2",
],
"osx-64": [
# qt 5.9.7 accidentially added .conda. to the dylibs names
"qt-5.9.7-h468cd18_0.tar.bz2",
# This build contains incorrect libffi run depends; removing rather
# than patching to prevent solver from getting stuck in a bistable
# solution (since another build has the same set of requirements).
"cffi-1.14.6-py36h9ed2024_0.tar.bz2",
"cffi-1.14.6-py37h9ed2024_0.tar.bz2",
"cffi-1.14.6-py38h9ed2024_0.tar.bz2",
"cffi-1.14.6-py39h9ed2024_0.tar.bz2",
],
"win-32": [
"nomkl-*",
# This release/build breaks matplotlib and possibly other things well
"freetype-2.11.0-h88da6cb_0.tar.bz2",
],
"win-64": [
"nomkl-*",
# numba 0.46 didn't actually support py38
"numba-0.46.0-py38hf9181ef_0.tar.bz2",
# This release/build breaks matplotlib and possibly other things well
"freetype-2.11.0-ha860e81_0.tar.bz2",
],
"linux-64": [
"numba-0.46.0-py38h962f231_0.tar.bz2",
# This build contains incorrect libffi run depends; removing rather
# than patching to prevent solver from getting stuck in a bistable
# solution (since another build has the same set of requirements).
"cffi-1.14.6-py36h7f8727e_0.tar.bz2",
"cffi-1.14.6-py37h7f8727e_0.tar.bz2",
"cffi-1.14.6-py38h7f8727e_0.tar.bz2",
"cffi-1.14.6-py39h7f8727e_0.tar.bz2",
],
"any": {
# early efforts on splitting numpy recipe did not pin numpy-base exactly.
# These led to bad builds (built against newest numpy)
"numpy-*1.11.3-*_6.tar.bz2",
"numpy-*1.14.3-*_2.tar.bz2",
# missing blas deps that make solver able to choose wrong things.
# numpy-base is pinned exactly, but this effectively defeated the
# variant being able to distinguish between openblas and mkl.
"numpy-1.14.5-py35h28100ab_0.tar.bz2",
# early vs2017 packages used wrong version numbers
"vs2017_win-*-15.5.2*",
"vs2017*h590f102_0*",
"vs2017*hb4ce483_0*",
# libtiff has incorrect build number and incorrect requirements
"libtiff-4.0.10-*_1001.tar.bz2",
# incorrect requirements leading to import failures
"libarchive-3.3.3-*_0",
# cph 1.5.0 replaces \r\n in files with \n on windows but does not
# truncate the file. This results in corrupt packages.
"conda-package-handling-1.5.0*",
# segfaults in 2019.5 that need work to understand. To be restored soon.
"mkl*-2019.5*",
"daal*-2019.5*",
"intel-openmp*-2019.5*",
# missing dependencies
"numpy-devel-1.14.3*",
# anaconda-client<1.10.0 is incompatible with python 3.10
"anaconda-client-1.9.0-py310*",
},
}
REVOKED = {
"linux-64": [
# build _0 were built against an invalid CuDNN library version
"tensorflow-base-1.9.0-gpu_py35h9f529ab_0.tar.bz2",
"tensorflow-base-1.9.0-gpu_py36h9f529ab_0.tar.bz2",
"tensorflow-base-1.9.0-gpu_py27h9f529ab_0.tar.bz2",
# compilers with wrong dependencies (missing impl)
"g*_linux-64-7.2.0-24.tar.bz2",
],
"linux-32": [
# build _0 were built against an invalid CuDNN library version
"tensorflow-base-1.9.0-gpu_py35h9f529ab_0.tar.bz2",
"tensorflow-base-1.9.0-gpu_py36h9f529ab_0.tar.bz2",
"tensorflow-base-1.9.0-gpu_py27h9f529ab_0.tar.bz2",
# compilers with wrong dependencies (missing impl)
"g*_linux-32-7.2.0-24.tar.bz2",
],
"linux-ppc64le": [],
"osx-64": [
# this build statically links libxml2-with-icu but doesn't statically
# link icu. xref: https://github.com/AnacondaRecipes/aggregate/issues/10
"xar-1.6.1-hd3d9906_0.tar.bz2",
# doesn't specify dependency on openssl, whereas it should
"libssh2 1.8.0 h1218725_2",
],
"win-32": [
"spyder-kernels-1.0.1-*_0",
],
"win-64": [
"spyder-kernels-1.0.1-*_0",
],
"any": [],
}
# This is a list of numpy-base packages for each subdir which multiple numpy
# packages depend on. Since multiple numpy packages depend on these the
# constrain entry added to them should be to the numpy version not the version
# and build as the later would make some numpy packages un-installable.
NP_BASE_LOOSE_PIN = {
"linux-64": [
"numpy-base-1.11.3-py27h2b20989_8.tar.bz2",
"numpy-base-1.11.3-py27hdbf6ddf_8.tar.bz2",
"numpy-base-1.11.3-py36h2b20989_8.tar.bz2",
"numpy-base-1.11.3-py36hdbf6ddf_8.tar.bz2",
"numpy-base-1.11.3-py37h2b20989_8.tar.bz2",
"numpy-base-1.11.3-py37hdbf6ddf_8.tar.bz2",
"numpy-base-1.15.1-py27h74e8950_0.tar.bz2",
"numpy-base-1.15.1-py27h81de0dd_0.tar.bz2",
"numpy-base-1.15.1-py35h74e8950_0.tar.bz2",
"numpy-base-1.15.1-py35h81de0dd_0.tar.bz2",
"numpy-base-1.15.1-py36h74e8950_0.tar.bz2",
"numpy-base-1.15.1-py36h81de0dd_0.tar.bz2",
"numpy-base-1.15.1-py37h74e8950_0.tar.bz2",
"numpy-base-1.15.1-py37h81de0dd_0.tar.bz2",
"numpy-base-1.9.3-py27h2b20989_7.tar.bz2",
"numpy-base-1.9.3-py27hdbf6ddf_7.tar.bz2",
"numpy-base-1.9.3-py35h2b20989_7.tar.bz2",
"numpy-base-1.9.3-py35hdbf6ddf_7.tar.bz2",
"numpy-base-1.9.3-py36h2b20989_7.tar.bz2",
"numpy-base-1.9.3-py36hdbf6ddf_7.tar.bz2",
"numpy-base-1.9.3-py37h2b20989_7.tar.bz2",
"numpy-base-1.9.3-py37hdbf6ddf_7.tar.bz2",
],
"osx-64": [
"numpy-base-1.11.3-py27h9797aa9_8.tar.bz2",
"numpy-base-1.11.3-py27ha9ae307_8.tar.bz2",
"numpy-base-1.11.3-py36h9797aa9_8.tar.bz2",
"numpy-base-1.11.3-py36ha9ae307_8.tar.bz2",
"numpy-base-1.11.3-py37h9797aa9_8.tar.bz2",
"numpy-base-1.11.3-py37ha9ae307_8.tar.bz2",
"numpy-base-1.15.1-py27h42e5f7b_0.tar.bz2",
"numpy-base-1.15.1-py27h8a80b8c_0.tar.bz2",
"numpy-base-1.15.1-py35h42e5f7b_0.tar.bz2",
"numpy-base-1.15.1-py35h8a80b8c_0.tar.bz2",
"numpy-base-1.15.1-py36h42e5f7b_0.tar.bz2",
"numpy-base-1.15.1-py36h8a80b8c_0.tar.bz2",
"numpy-base-1.15.1-py37h42e5f7b_0.tar.bz2",
"numpy-base-1.15.1-py37h8a80b8c_0.tar.bz2",
"numpy-base-1.9.3-py27h9797aa9_7.tar.bz2",
"numpy-base-1.9.3-py27ha9ae307_7.tar.bz2",
"numpy-base-1.9.3-py35h9797aa9_7.tar.bz2",
"numpy-base-1.9.3-py35ha9ae307_7.tar.bz2",
"numpy-base-1.9.3-py36h9797aa9_7.tar.bz2",
"numpy-base-1.9.3-py36ha9ae307_7.tar.bz2",
"numpy-base-1.9.3-py37h9797aa9_7.tar.bz2",
"numpy-base-1.9.3-py37ha9ae307_7.tar.bz2",
],
"win-64": [
"numpy-base-1.15.1-py27h2753ae9_0.tar.bz2",
"numpy-base-1.15.1-py35h8128ebf_0.tar.bz2",
"numpy-base-1.15.1-py36h8128ebf_0.tar.bz2",
"numpy-base-1.15.1-py37h8128ebf_0.tar.bz2",
],
"win-32": [
"numpy-base-1.15.1-py27h2753ae9_0.tar.bz2",
"numpy-base-1.15.1-py35h8128ebf_0.tar.bz2",
"numpy-base-1.15.1-py36h8128ebf_0.tar.bz2",
"numpy-base-1.15.1-py37h8128ebf_0.tar.bz2",
],
"linux-ppc64le": [
"numpy-base-1.11.3-py27h2b20989_8.tar.bz2",
"numpy-base-1.11.3-py36h2b20989_8.tar.bz2",
"numpy-base-1.15.1-py27h74e8950_0.tar.bz2",
"numpy-base-1.15.1-py35h74e8950_0.tar.bz2",
"numpy-base-1.15.1-py36h74e8950_0.tar.bz2",
"numpy-base-1.15.1-py37h74e8950_0.tar.bz2",
],
"noarch": [],
"linux-32": [],
"linux-aarch64": [],
"linux-armv6l": [],
"linux-armv7l": [],
"linux-s390x": [],
"osx-arm64": [],
}
BLAS_USING_PKGS = {
"numpy",
"numpy-base",
"scipy",
"numexpr",
"scikit-learn",
"libmxnet",
}
TFLOW_SUBS = {
# 1.8.0, eigen is the default variant
"_tflow_180_select ==1.0 gpu": "_tflow_select ==1.1.0 gpu",
"_tflow_180_select ==2.0 mkl": "_tflow_select ==1.2.0 mkl",
"_tflow_180_select ==3.0 eigen": "_tflow_select ==1.3.0 eigen",
# 1.9.0, mkl is the default variant
"_tflow_190_select ==0.0.1 gpu": "_tflow_select ==2.1.0 gpu",
"_tflow_190_select ==0.0.2 eigen": "_tflow_select ==2.2.0 eigen",
"_tflow_190_select ==0.0.3 mkl": "_tflow_select ==2.3.0 mkl",
# 1.10.0, mkl is the default variant
"_tflow_1100_select ==0.0.1 gpu": "_tflow_select ==2.1.0 gpu",
"_tflow_1100_select ==0.0.2 eigen": "_tflow_select ==2.2.0 eigen",
"_tflow_1100_select ==0.0.3 mkl": "_tflow_select ==2.3.0 mkl",
# 1.11.0+ needs no fixing
}
CUDATK_SUBS = {
"cudatoolkit >=9.0,<10.0a0": "cudatoolkit >=9.0,<9.1.0a0",
"cudatoolkit >=9.2,<10.0a0": "cudatoolkit >=9.2,<9.3.0a0",
"cudatoolkit >=10.0.130,<11.0a0": "cudatoolkit >=10.0.130,<10.1.0a0",
}
MKL_VERSION_2018_RE = re.compile(r">=2018(.\d){0,2}$")
MKL_VERSION_2018_EXTENDED_RC = re.compile(r">=2018(.\d){0,2}")
LINUX_RUNTIME_RE = re.compile(r"lib(\w+)-ng\s(?:>=)?([\d\.]+\d)(?:$|\.\*)")
LINUX_RUNTIME_DEPS = ("libgcc-ng", "libstdcxx-ng", "libgfortran-ng")
# Packages that do *not* need to have their libffi dependencies patched
LIBFFI_HOTFIX_EXCLUDES = [
"_anaconda_depends",
]
def _replace_vc_features_with_vc_pkg_deps(name, record, depends):
python_vc_deps = {
"2.6": "vc 9.*",
"2.7": "vc 9.*",
"3.3": "vc 10.*",
"3.4": "vc 10.*",
"3.5": "vc 14.*",
"3.6": "vc 14.*",
"3.7": "vc 14.*",
}
vs_runtime_deps = {
9: "vs2008_runtime",
10: "vs2010_runtime",
14: "vs2015_runtime",
}
if name == "python":
# remove the track_features key
if "track_features" in record:
record["track_features"] = ""
# add a vc dependency
if not any(d.startswith("vc") for d in depends):
depends.append(python_vc_deps[record["version"][:3]])
elif name == "vs2015_win-64":
# remove the track_features key
if "track_features" in record:
record["track_features"] = ""
elif record["name"] == "yasm":
# remove vc from the features key
vc_version = _extract_and_remove_vc_feature(record)
if vc_version:
record["features"] = record.get("features") or ""
# add a vs20XX_runtime dependency
if not any(d.startswith("vs2") for d in record["depends"]):
depends.append(vs_runtime_deps[vc_version])
elif name == "git":
# remove any vc dependency, as git does not depend on a specific one
depends[:] = [dep for dep in depends if not dep.startswith("vc ")]
elif "vc" in record.get("features", ""):
# remove vc from the features key
vc_version = _extract_and_remove_vc_feature(record)
if vc_version:
record["features"] = record.get("features") or ""
# add a vc dependency
if not any(d.startswith("vc") for d in depends):
depends.append("vc %d.*" % vc_version)
def _apply_namespace_overrides(fn, record, instructions):
record_name = record["name"]
namespace_in_name_set = {
"python-crfsuite",
"python-daemon",
"python-dateutil",
"python-editor",
"python-engineio",
"python-gflags",
"python-ldap",
"python-memcached",
"python-ntlm",
"python-rapidjson",
"python-slugify",
"python-snappy",
"python-socketio",
"python-sybase",
"python-utils",
}
namespace_overrides = {
"boost": "python",
"ninja": "global",
"numpy-devel": "python",
"texlive-core": "global",
"keras": "python",
"keras-gpu": "python",
"git": "global",
"python-javapackages-cos7-ppc64le": "global",
"anaconda": "python",
"conda-env": "python",
"tensorflow": "python",
"tensorflow-gpu": "python",
"xcb-proto": "global",
"mxnet": "python",
}
if record_name in namespace_in_name_set and not record.get("namespace_in_name"):
# set the namespace_in_name field
instructions["packages"][fn]["namespace_in_name"] = True
if namespace_overrides.get(record_name):
# explicitly set namespace
instructions["packages"][fn]["namespace"] = namespace_overrides[record_name]
def _get_record_depends(fn, record, instructions):
"""Return the depends information for a record, including any patching."""
record_depends = record.get("depends", [])
if fn in instructions["packages"]:
if "depends" in instructions["packages"][fn]:
# the package depends have already been patched
record_depends = instructions["packages"][fn]["depends"]
return record_depends
def _fix_linux_runtime_bounds(depends):
for i, dep in enumerate(depends):
if dep.split()[0] not in LINUX_RUNTIME_DEPS:
continue
match = LINUX_RUNTIME_RE.match(dep)
if not match:
continue
dep = "lib{}-ng >={}".format(match.group(1), match.group(2))
if match.group(1) == "gfortran":
# this is adding an upper bound
lower_bound = int(match.group(2)[0])
# ABI break at gfortran 8
if lower_bound < 8:
dep += ",<8.0a0"
depends[i] = dep
def _fix_nomkl_features(record, depends):
if record["features"] == "nomkl":
record["features"] = None
if not any(d.startswith("blas ") for d in depends):
depends[:] = depends + ["blas * openblas"]
elif "nomkl" in record["features"]:
# remove nomkl feature
record["features"].remove("nomkl")
if not any(d.startswith("blas ") for d in depends):
depends[:] = depends + ["blas * openblas"]
def _fix_numpy_base_constrains(record, index, instructions, subdir):
# numpy-base packages should have run constrains on the corresponding numpy package
base_pkgs = [d for d in record["depends"] if d.startswith("numpy-base")]
if not base_pkgs:
# no base package, no hotfixing needed
return
base_pkg = base_pkgs[0]
try:
name, ver, build_str = base_pkg.split()
except ValueError:
# base package pinning not to version + build, no modification needed
return
base_pkg_fn = "%s-%s-%s.tar.bz2" % (name, ver, build_str)
try:
if "constrains" in index[base_pkg_fn]:
return
except KeyError:
# package might be revoked
return
if base_pkg_fn in NP_BASE_LOOSE_PIN.get(subdir, []):
# base package is a requirement of multiple numpy packages,
# constrain to only the version
req = "%s %s" % (record["name"], record["version"])
else:
# base package is a requirement of a single numpy package,
# constrain to the exact build
req = "%s %s %s" % (record["name"], record["version"], record["build"])
instructions["packages"][base_pkg_fn]["constrains"] = [req]
def _fix_cudnn_depends(depends, subdir):
for dep in depends:
if dep.startswith("cudnn"):
original_cudnn_depend = dep
if dep.startswith("cudatoolkit"):
cudatoolkit_depend = dep
is_seven_star = original_cudnn_depend.startswith(
"cudnn 7*"
) or original_cudnn_depend.startswith("cudnn 7.*")
if subdir.startswith("win-"):
# all packages prior to 2019-01-24 built with cudnn 7.1.4
correct_cudnn_depends = "cudnn >=7.1.4,<8.0a0"
else:
if original_cudnn_depend.startswith("cudnn 7.0"):
correct_cudnn_depends = "cudnn >=7.0.0,<=8.0a0"
elif original_cudnn_depend.startswith("cudnn 7.1.*"):
correct_cudnn_depends = "cudnn >=7.1.0,<=8.0a0"
elif original_cudnn_depend.startswith("cudnn 7.2.*"):
correct_cudnn_depends = "cudnn >=7.2.0,<=8.0a0"
# these packages express a dependeny of 7* or 7.* which is correct for
# the cudnn package versions available in defaults but are be rewritten
# to be more precise.
# Prior to 2019-01-24 all packages were build against:
# cudatoolkit 8.0 : cudnn 7.0.5
# cudatoolkit 9.0 : cudnn 7.1.2
# cudatoolkit 9.2 : cudnn 7.2.1
elif is_seven_star and cudatoolkit_depend.startswith("cudatoolkit 8.0"):
correct_cudnn_depends = "cudnn >=7.0.5,<=8.0a0"
elif is_seven_star and cudatoolkit_depend.startswith("cudatoolkit 9.0"):
correct_cudnn_depends = "cudnn >=7.1.2,<=8.0a0"
elif is_seven_star and cudatoolkit_depend.startswith("cudatoolkit 9.2"):
correct_cudnn_depends = "cudnn >=7.2.1,<=8.0a0"
elif original_cudnn_depend == "cudnn 7.3.*":
correct_cudnn_depends = "cudnn >=7.3.0,<=8.0a0"
else:
raise Exception("unknown cudnn depedency")
idx = depends.index(original_cudnn_depend)
depends[idx] = correct_cudnn_depends
def _patch_repodata(repodata, subdir):
index = repodata["packages"]
instructions = {
"patch_instructions_version": 1,
"packages": defaultdict(dict),
"revoke": [],
"remove": [],
}
if subdir == "noarch":
instructions["external_dependencies"] = {
"util-linux": "global:util-linux", # libdap4, pynio
"meld3": "python:meld3", # supervisor
"msys2-conda-epoch": "global:msys2-conda-epoch", # anaconda
}
for fn, record in index.items():
if is_revoked(fn, subdir):
instructions["revoke"].append(fn)
if is_removed(fn, subdir):
instructions["remove"].append(fn)
_apply_namespace_overrides(fn, record, instructions)
patch_record(fn, record, subdir, instructions, index)
instructions["remove"].sort()
instructions["revoke"].sort()
return instructions
def is_revoked(fn, subdir):
for rev in REVOKED.get(subdir, []):
if fnmatch.fnmatch(fn, rev):
return True
for rev in REVOKED.get("any", []):
if fnmatch.fnmatch(fn, rev):
return True
return False
def is_removed(fn, subdir):
for rev in REMOVALS.get(subdir, []):
if fnmatch.fnmatch(fn, rev):
return True
for rev in REMOVALS.get("any", []):
if fnmatch.fnmatch(fn, rev):
return True
return False
def patch_record(fn, record, subdir, instructions, index):
# create a copy of the record, patch in-place and add keys that change
# to the patch instructions
original_record = copy.deepcopy(record)
patch_record_in_place(fn, record, subdir)
keys_to_check = [
"constrains",
"depends",
"features",
"namespace",
"license_family",
"subdir",
"track_features",
]
for key in keys_to_check:
if record.get(key) != original_record.get(key):
instructions["packages"][fn][key] = record.get(key)
# One-off patches that do not fit in with others
if record["name"] == "numpy":
_fix_numpy_base_constrains(record, index, instructions, subdir)
# set a specific timestamp for numba-0.36.1
if fn.startswith("numba-0.36.1") and record.get("timestamp") != 1512604800000:
instructions["packages"][fn]["timestamp"] = 1512604800000
# set the build_number of the blas-1.0-openblas.tar.bz2 package
# to 7 to match the package in free
# https://github.com/conda/conda/issues/8302
if subdir == "linux-ppc64le" and fn == "blas-1.0-openblas.tar.bz2":
instructions["packages"][fn]["build_number"] = 7
def patch_record_in_place(fn, record, subdir):
"""Patch record in place"""
name = record["name"]
version = record["version"]
build = record["build"]
build_number = record["build_number"]
depends = record["depends"]
constrains = record.get("constrains", [])
##########
# subdir #
##########
if "subdir" not in record:
record["subdir"] = subdir
#############
# namespace #
#############
if name == "conda-env" and not any(d.startswith("python") for d in depends):
record["namespace"] = "python"
################
# CUDA related #
################
# add run constrains on __cuda virtual package to cudatoolkit package
# see https://github.com/conda/conda/issues/9115
if name == "cudatoolkit" and "constrains" not in record:
major, minor = version.split(".")[:2]
req = f"__cuda >={major}.{minor}"
record["constrains"] = [req]
if any(dep.startswith("cudnn 7") for dep in depends):
_fix_cudnn_depends(depends, subdir)
# cudatoolkit should be pinning to major.minor not just major
if name in ("cupy", "nccl"):
for i, dep in enumerate(depends):
depends[i] = CUDATK_SUBS[dep] if dep in CUDATK_SUBS else dep
# depends in package is set as cudatoolkit 9.*, should be 9.0.*
if fn == "cupti-9.0.176-0.tar.bz2":
replace_dep(depends, "cudatoolkit 9.*", "cudatoolkit 9.0.*")
#######
# MKL #
#######
if name == "numpy-base" and any(_.startswith("mkl >=2018") for _ in depends):
depends.append("tbb4py")
for i, dep in enumerate(depends):
if (
dep.split()[0] == "mkl"
and len(dep.split()) > 1
and MKL_VERSION_2018_RE.match(dep.split()[1])
):
depends[i] = MKL_VERSION_2018_EXTENDED_RC.sub(
"%s,<2019.0a0" % (dep.split()[1]), dep
)
# intel-openmp 2020.* seems to be incompatible with older versions of mkl
# issues have only been reported on macOS and Windows but
# add the constrains on all platforms to be safe
if name == "intel-openmp" and version.startswith("2020"):
minor_version = version.split(".")[1]
record["constrains"] = [f"mkl >=2020.{minor_version}"]
# mkl 2020.x is compatible with 2019.x
# so mkl >=2019.x,<2020.0a0 becomes mkl >=2019.x,<2021.0a0
# except on osx-64, older macOS release have problems...
for i, dep in enumerate(depends):
if dep.startswith("mkl >=2019") and dep.endswith(",<2020.0a0"):
if subdir != "osx-64":
expanded_dep = dep.replace(",<2020.0a0", ",<2021.0a0")
depends[i] = expanded_dep
# some of these got hard-coded to overly restrictive values
if name in ("scikit-learn", "pytorch"):
for i, dep in enumerate(depends):
if dep.startswith("mkl 2018") and not any(
_.startswith("mkl >") for _ in depends
):
depends[i] = "mkl >=2018.0.3,<2019.0a0"
if "mkl 2018.*" in depends:
depends.pop(depends.index("mkl 2018.*"))
########
# BLAS #
########
if "features" in record:
_fix_nomkl_features(record, depends)
if name in ("mkl_random", "mkl_fft"):
if not any(re.match(r"blas\s.*\smkl", dep) for dep in record["depends"]):
depends.append("blas * mkl")
if name in ("openblas", "openblas-devel"):
for i, dep in enumerate(depends):
if dep.split()[0] == "nomkl":
depends[i] = "nomkl 3.0 0"
if name == "openblas-devel" and not any(d.startswith("blas ") for d in depends):
depends.append("blas * openblas")
if name == "mkl-devel" and not any(d.startswith("blas") for d in depends):
depends.append("blas * mkl")
# add in blas mkl metapkg for mutex behavior on packages that have just mkl deps
if name in BLAS_USING_PKGS and not any(dep.split()[0] == "blas" for dep in depends):
if any(dep.split()[0] == "mkl" for dep in depends):
depends.append("blas * mkl")
elif any(dep.split()[0] in ("openblas", "libopenblas") for dep in depends):
depends.append("blas * openblas")
#########
# numpy #
#########
# Correct packages mistakenly built against 1.21.5 on linux-aarch64
# Replaces the dependency bound with 1.21.2. These packages should
# actually have been built against an even earlier version of numpy.
# This is the safest correction we can make for now
if subdir == "linux-aarch64":
for i, dep in enumerate(depends):
if dep.startswith("numpy >=1.21.5,"):
depends[i] = depends[i].replace(">=1.21.5,", ">=1.21.2,")
break
###########
# pytorch #
###########
# pytorch was built with nccl 1.x
if name == "pytorch":
replace_dep(depends, "nccl", "nccl <2")
if name == "torchvision" and version == "0.3.0":
replace_dep(depends, "pytorch >=1.1.0", "pytorch 1.1.*")
if "pytorch >=1.1.0" in depends:
# torchvision pytorch depends needs to be fixed to 1.1
pytorch_dep = depends.index("pytorch >=1.1.0")
depends[pytorch_dep] = "pytorch 1.1.*"
if name == "torchvision" and version == "0.4.0":
if "cuda" in record["build"]:
depends.append("_pytorch_select 0.2")
else:
depends.append("_pytorch_select 0.1")
#########
# scipy #
#########
if name == "scipy":
# Our original build of scipy-1.7.3 (build number 0) did not comply with the
# upstream's min and max numpy pinnings.
# See: https://github.com/scipy/scipy/blob/v1.7.3/setup.py#L551-L552
if version == "1.7.3" and build_number == 0:
if subdir != 'osx-arm64' and not build.startswith("py310"):
replace_dep(depends, "numpy >=1.16.6,<2.0a0", "numpy >=1.16.6,<1.23.0")
if subdir == 'osx-arm64' and not build.startswith("py310"):
replace_dep(depends, "numpy >=1.19.5,<2.0a0", "numpy >=1.19.5,<1.23.0")
if build.startswith("py310"):
replace_dep(depends, "numpy >=1.21.2,<2.0a0", "numpy >=1.21.2,<1.23.0")
# scipy needs at least nympy 1.19.5
# https://github.com/scipy/scipy/blob/v1.10.0/pyproject.toml#L78
elif version == "1.10.0" and build_number == 0:
if build[:4] in ["py37", "py38", "py39"]:
replace_dep(depends, "numpy >=1.19,<1.27.0", "numpy >=1.19.5,<1.27.0")
######################
# scipy dependencies #
######################
# scipy 1.8 and 1.9 introduce breaking API changes impacting these packages
if name == "theano":
if version in ["1.0.4", "1.0.5"]:
replace_dep(depends, "scipy >=0.14", "scipy >=0.14,<1.8")
elif version in ["0.9.0", "1.0.1", "1.0.2", "1.0.3"]:
replace_dep(depends, "scipy >=0.14.0", "scipy >=0.14,<1.8")
if name == "theano-pymc":
replace_dep(depends, "scipy >=0.14", "scipy >=0.14,<1.8")
if name == "pyamg" and version in ["3.3.2", "4.0.0", "4.1.0"]:
replace_dep(depends, "scipy >=0.12.0", "scipy >=0.12.0,<1.8")
##############
# tensorflow #
##############
tflow_pkg = name in [
"tensorflow",
"tensorflow-gpu",
"tensorflow-eigen",
"tensorflow-mkl",
]
if tflow_pkg and version in ["1.8.0", "1.9.0", "1.10.0"]:
for i, dep in enumerate(depends):
depends[i] = TFLOW_SUBS[dep] if dep in TFLOW_SUBS else dep
if name == "keras":
version_parts = version.split(".")
if int(version_parts[0]) <= 2 and int(version_parts[1]) < 3:
for i, dep in enumerate(depends):
if dep.startswith("tensorflow"):
depends[i] = "tensorflow <2.0"
# tensorboard 2.0.0 build 0 should have a requirement on setuptools >=41.0.0
# see: https://github.com/AnacondaRecipes/tensorflow_recipes/issues/20
if name == "tensorboard" and version == "2.0.0" and build_number == 0:
depends.append("setuptools >=41.0.0")
if name.startswith("tensorflow-base") and version == "2.4.1":
replace_dep(depends, "gast", "gast 0.3.3")
# Relax the scipy pin slightly on linux-64 for tensorflow-base 2.8.2
# to match linux-aarch64, to facilitate intel/arm version alignment.
if name.startswith("tensorflow-base") and version == "2.8.2" and subdir == 'linux-64':
for i, dep in enumerate(depends):
if dep == "scipy >=1.7.3":
depends[i] = "scipy >=1.7.1"
break
##############
# versioneer #
##############
if name == "versioneer" and record["license_family"].upper() == "NONE":
record["license_family"] = "PUBLIC-DOMAIN"
##############
# constrains #
##############
# setuptools should not appear in both depends and constrains
# https://github.com/conda/conda/issues/9337
if name == "conda" and "setuptools >=31.0.1" in constrains:
constrains[:] = [req for req in constrains if not req.startswith("setuptools")]
# basemap is incompatible with proj/proj4 >=6
# https://github.com/ContinuumIO/anaconda-issues/issues/11590
if name == "basemap":
record["constrains"] = ["proj4 <6", "proj <6"]
# 'cryptography' + pyopenssl incompatibility 28 Feb 2023 #
if name == "cryptography" and VersionOrder(version) >= VersionOrder("39.0.1"):
# or pyopenssl should have a max cryptography version set
record["constrains"] = ["pyopenssl >=23.0.0"]
############
# features #
############
if subdir.startswith("win-"):
_replace_vc_features_with_vc_pkg_deps(name, record, depends)
##################
# track_features #
##################
# reset dependencies for nomkl to the blas metapkg and remove any
# track_features (these are attached to the metapkg instead)
if name == "nomkl" and not subdir.startswith("win-"):
record["depends"] = ["blas * openblas"]
if "track_features" in record:
record["track_features"] = ""
if record.get("track_features"):
for feat in record["track_features"].split():
if feat.startswith(("rb2", "openjdk")):
xtractd = record["track_features"] = _extract_track_feature(
record, feat
)
record["track_features"] = xtractd
#############################################
# anaconda, conda, conda-build, constructor #
#############################################
if (
name == "anaconda"
and version == "custom"
and not any(d.startswith("_anaconda_depends") for d in depends)
):
depends.append("_anaconda_depends")
if name == "anaconda" and version in ["5.3.0", "5.3.1"]:
mkl_version = [
i for i in depends if i.split()[0] == "mkl" and "2019" in i.split()[1]
]
if len(mkl_version) == 1:
depends.remove(mkl_version[0])
depends.append("mkl 2018.0.3 1")
elif len(mkl_version) > 1:
raise Exception("Found multiple mkl entries, expected only 1.")
if name == "conda-build" and version.startswith("3.18"):
for i, dep in enumerate(depends):
parts = dep.split()
if parts[0] == "conda" and "4.3" in parts[1]:
depends[i] = "conda >=4.5"
# CPH 1.5 has a statically linked libarchive and doesn't depend on python-libarchive-c
# we were implicitly depending on it, and it goes missing.
if "python-libarchive-c" not in depends:
depends.append("python-libarchive-c")
if name == "conda-build":
for i, dep in enumerate(depends):
dep_name, *other = dep.split()
# Jinja 3.0.0 introduced behavior changes that broke certain
# conda-build templating functionality.
if dep_name == "jinja2":
depends[i] = "jinja2 !=3.0.0"
# Deprecation removed in conda 4.13 break older conda-builds
if VersionOrder(version) <= VersionOrder("3.21.8") and dep_name == "conda":
depends[i] = "{} {}<4.13.0".format(
dep_name, other[0] + "," if other else ""
)
if name == "constructor":
if int(version[0]) < 3:
replace_dep(depends, "conda", "conda <4.6.0a0")
# conda 23.1 broke constructor
# https://github.com/conda/constructor/pull/627
if record.get("timestamp", 0) <= 1674637311000:
replace_dep(depends, "conda >=4.6", "conda >=4.6,<23.1.0a0")
# libarchive 3.3.2 and 3.3.3 build 0 are missing zstd support.
# De-prioritize these packages with a track_feature (via _low_priority)
# so they are not installed unless explicitly requested
if name == "libarchive" and (
version == "3.3.2" or (version == "3.3.3" and build_number == 0)
):
depends.append("_low_priority")
if name == 'anaconda-navigator':
if re.match(r'1\.|2\.[0-2]\.', version): # < 2.3.0
replace_dep(depends, ['pyqt >=5.6,<6.0a0', 'pyqt >=5.6', 'pyqt'], 'pyqt >=5.6,<5.15')
if re.match(r'1\.|2\.[0-3]\.', version): # < 2.4.0
replace_dep(depends, 'conda', 'conda <22.11.0', append=True)
########################
# run_exports mis-pins #
########################
# openssl uses funnny version numbers, 1.1.1, 1.1.1a, 1.1.1b, etc
# openssl >=1.1.1,<1.1.2.0a0 -> >=1.1.1a,<1.1.2a
replace_dep(depends, "openssl >=1.1.1,<1.1.2.0a0", "openssl >=1.1.1a,<1.1.2a")
# kealib 1.4.8 changed sonames, add new upper bound to existing packages
replace_dep(depends, "kealib >=1.4.7,<1.5.0a0", "kealib >=1.4.7,<1.4.8.0a0")
# Other broad replacements
for i, dep in enumerate(depends):
# glib is compatible up to the major version
if dep.startswith("glib >="):
depends[i] = dep.split(",")[0] + ",<3.0a0"
# zstd has been more or less ABI compatible in the 1.4.x releases.
# `ZSTD_getSequences` is the only symbol reported as being removed
# between 1.4.0 and 1.5.0, but as far as we can tell, none of our
# (linux-64) packages actually use it.
if dep.startswith("zstd >=1.4."):
depends[i] = dep.split(",")[0] + ",<1.5.0a0"
# libffi broke ABI compatibility in 3.3
if name not in LIBFFI_HOTFIX_EXCLUDES and (
"libffi >=3.2.1,<4.0a0" in depends or "libffi" in depends
):
if "libffi >=3.2.1,<4.0a0" in depends:
libffi_idx = depends.index("libffi >=3.2.1,<4.0a0")
else:
libffi_idx = depends.index("libffi")
depends[libffi_idx] = "libffi >=3.2.1,<3.3a0"
replace_dep(depends, "libnetcdf >=4.6.1,<5.0a0", "libnetcdf >=4.6.1,<4.7.0a0")
# ZeroMQ DLL includes patch number in DLL name, which limits the upper bound
if subdir.startswith("win-"):
replace_dep(depends, "zeromq >=4.3.1,<4.4.0a0", "zeromq >=4.3.1,<4.3.2.0a0")
##########################
# single package depends #
##########################
# https://github.com/ContinuumIO/anaconda-issues/issues/11315
if subdir.startswith("win") and name == "jupyterlab" and "pywin32" not in depends:
depends.append("pywin32")
# pyqt needs an upper limit of sip, build 2 has this already
if name == "pyqt" and version == "5.9.2":
replace_dep(depends, "sip >=4.19.4", "sip >=4.19.4,<=4.19.8")
# three pyqt packages were built against sip 4.19.13
# first filename is linux-64, second is win-64 and win-32
if fn in ["pyqt-5.9.2-py38h05f1152_4.tar.bz2", "pyqt-5.9.2-py38ha925a31_4.tar.bz2"]:
sip_index = [dep.startswith("sip") for dep in depends].index(True)
depends[sip_index] = "sip >=4.19.13,<=4.19.14"
if fn == "dask-2.7.0-py_0.tar.bz2":
for i, dep in enumerate(depends):
if dep.startswith("python "):
depends[i] = "python >=3.6"
if fn == "dask-core-2.7.0-py_0.tar.bz2":
depends[:] = ["python >=3.6"]
if name == "dask-core" and version == "2021.3.1" and build_number == 0:
depends[:] = [
"python >=3.7",
"cloudpickle >=1.1.1",
"fsspec >=0.6.0",
"partd >=0.3.10",
"pyyaml",
"toolz >=0.8.2",
]
if name == "dask" and version == "2021.3.1" and build_number == 0:
depends[:] = ["python >=3.7", "numpy >=1.16"] + [
d
for d in depends
if d.split(" ")[0]
not in ("python", "cloudpickle", "fsspec", "numpy", "partd", "toolz")
]
depends.sort()
# sparkmagic <=0.12.7 has issues with ipykernel >4.10
# see: https://github.com/AnacondaRecipes/sparkmagic-feedstock/pull/3
if name == "sparkmagic" and version in ["0.12.1", "0.12.5", "0.12.6", "0.12.7"]:
replace_dep(depends, "ipykernel >=4.2.2", "ipykernel >=4.2.2,<4.10.0")
# notebook <5.7.6 will not work with tornado 6, see:
# https://github.com/jupyter/notebook/issues/4439
if name == "notebook":
replace_dep(depends, "tornado >=4", "tornado >=4,<6")
# spyder 4.0.0 and 4.0.1 should include a lower bound on psutil of 5.2
# and should pin parso to 0.5.2.
# https://github.com/conda-forge/spyder-feedstock/pull/73
# https://github.com/conda-forge/spyder-feedstock/pull/74
if name == "spyder" and version in ["4.0.0", "4.0.1"]:
add_parso_dep = True
for idx, dep in enumerate(depends):
if dep.startswith("parso"):
add_parso_dep = False
if dep.startswith("psutil"):
depends[idx] = "psutil >=5.2"
# spyder-kernels needs to be pinned to <=1.9.0, see:
# https://github.com/conda-forge/spyder-feedstock/pull/76
if dep.startswith("spyder-kernels"):
depends[idx] = "spyder-kernels >=1.8.1,<1.9.0"
if add_parso_dep:
depends.append("parso 0.5.2.*")
# spyder 4.2.4 should have an upper bound on qdarkstyle and requires a newer qtconsole.