forked from conda/conda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_resolve.py
1832 lines (1730 loc) · 75.2 KB
/
test_resolve.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
from __future__ import absolute_import, print_function
from datetime import datetime
from os.path import isdir, join
from pprint import pprint
import unittest
import pytest
from conda.base.context import context, reset_context
from conda.common.compat import iteritems, itervalues
from conda.common.io import env_var
from conda.exceptions import UnsatisfiableError
from conda.gateways.disk.read import read_python_record
from conda.models.channel import Channel
from conda.models.enums import PackageType
from conda.models.records import PackageRecord
from conda.resolve import MatchSpec, Resolve, ResolvePackageNotFound
from .helpers import TEST_DATA_DIR, get_index_r_1, get_index_r_4, raises
index, r, = get_index_r_1()
f_mkl = set(['mkl'])
class TestSolve(unittest.TestCase):
def assert_have_mkl(self, precs, names):
for prec in precs:
if prec.name in names:
assert 'mkl' in prec.features
# def test_explicit0(self):
# self.assertEqual(r.explicit([]), [])
#
# def test_explicit1(self):
# self.assertEqual(r.explicit(['pycosat 0.6.0 py27_0']), None)
# self.assertEqual(r.explicit(['zlib']), None)
# self.assertEqual(r.explicit(['zlib 1.2.7']), None)
# # because zlib has no dependencies it is also explicit
# exp_result = r.explicit([MatchSpec('zlib 1.2.7 0', channel='defaults')])
# self.assertEqual(exp_result, [Dist('channel-1::zlib-1.2.7-0.tar.bz2')])
#
# def test_explicit2(self):
# self.assertEqual(r.explicit(['pycosat 0.6.0 py27_0',
# 'zlib 1.2.7 0']),
# [Dist('channel-1::pycosat-0.6.0-py27_0.tar.bz2'),
# Dist('channel-1::zlib-1.2.7-0.tar.bz2')])
# self.assertEqual(r.explicit(['pycosat 0.6.0 py27_0',
# 'zlib 1.2.7']), None)
#
# def test_explicitNone(self):
# self.assertEqual(r.explicit(['pycosat 0.6.0 notarealbuildstring']), None)
def test_empty(self):
self.assertEqual(r.install([]), [])
# def test_anaconda_14(self):
# specs = ['anaconda 1.4.0 np17py33_0']
# res = r.explicit(specs)
# self.assertEqual(len(res), 51)
# assert r.install(specs) == res
# specs.append('python 3.3*')
# self.assertEqual(r.explicit(specs), None)
# self.assertEqual(r.install(specs), res)
def test_iopro_nomkl(self):
installed = r.install(['iopro 1.4*', 'python 2.7*', 'numpy 1.7*'], returnall=True)
installed = [rec.dist_str() for rec in installed]
assert installed == [
'channel-1::iopro-1.4.3-np17py27_p0',
'channel-1::numpy-1.7.1-py27_0',
'channel-1::openssl-1.0.1c-0',
'channel-1::python-2.7.5-0',
'channel-1::readline-6.2-0',
'channel-1::sqlite-3.7.13-0',
'channel-1::system-5.8-1',
'channel-1::tk-8.5.13-0',
'channel-1::unixodbc-2.3.1-0',
'channel-1::zlib-1.2.7-0',
]
def test_iopro_mkl(self):
installed = r.install(['iopro 1.4*', 'python 2.7*', 'numpy 1.7*', MatchSpec(track_features='mkl')], returnall=True)
installed = [prec.dist_str() for prec in installed]
assert installed == [
'channel-1::iopro-1.4.3-np17py27_p0',
'channel-1::mkl-rt-11.0-p0',
'channel-1::numpy-1.7.1-py27_p0',
'channel-1::openssl-1.0.1c-0',
'channel-1::python-2.7.5-0',
'channel-1::readline-6.2-0',
'channel-1::sqlite-3.7.13-0',
'channel-1::system-5.8-1',
'channel-1::tk-8.5.13-0',
'channel-1::unixodbc-2.3.1-0',
'channel-1::zlib-1.2.7-0',
]
def test_mkl(self):
a = r.install(['mkl 11*', MatchSpec(track_features='mkl')])
b = r.install(['mkl'])
assert a == b
def test_accelerate(self):
self.assertEqual(
r.install(['accelerate']),
r.install(['accelerate', MatchSpec(track_features='mkl')]))
def test_scipy_mkl(self):
precs = r.install(['scipy', 'python 2.7*', 'numpy 1.7*', MatchSpec(track_features='mkl')])
self.assert_have_mkl(precs, ('numpy', 'scipy'))
dist_strs = [prec.dist_str() for prec in precs]
assert 'channel-1::scipy-0.12.0-np17py27_p0' in dist_strs
def test_anaconda_nomkl(self):
precs = r.install(['anaconda 1.5.0', 'python 2.7*', 'numpy 1.7*'])
assert len(precs) == 107
dist_strs = [prec.dist_str() for prec in precs]
assert 'channel-1::scipy-0.12.0-np17py27_0' in dist_strs
def test_pseudo_boolean():
# The latest version of iopro, 1.5.0, was not built against numpy 1.5
installed = r.install(['iopro', 'python 2.7*', 'numpy 1.5*'], returnall=True)
installed = [rec.dist_str() for rec in installed]
assert installed == [
'channel-1::iopro-1.4.3-np15py27_p0',
'channel-1::numpy-1.5.1-py27_4',
'channel-1::openssl-1.0.1c-0',
'channel-1::python-2.7.5-0',
'channel-1::readline-6.2-0',
'channel-1::sqlite-3.7.13-0',
'channel-1::system-5.8-1',
'channel-1::tk-8.5.13-0',
'channel-1::unixodbc-2.3.1-0',
'channel-1::zlib-1.2.7-0',
]
installed = r.install(['iopro', 'python 2.7*', 'numpy 1.5*', MatchSpec(track_features='mkl')], returnall=True)
installed = [rec.dist_str() for rec in installed]
assert installed == [
'channel-1::iopro-1.4.3-np15py27_p0',
'channel-1::mkl-rt-11.0-p0',
'channel-1::numpy-1.5.1-py27_p4',
'channel-1::openssl-1.0.1c-0',
'channel-1::python-2.7.5-0',
'channel-1::readline-6.2-0',
'channel-1::sqlite-3.7.13-0',
'channel-1::system-5.8-1',
'channel-1::tk-8.5.13-0',
'channel-1::unixodbc-2.3.1-0',
'channel-1::zlib-1.2.7-0',
]
def test_get_dists():
reduced_index = r.get_reduced_index([MatchSpec("anaconda 1.5.0")])
dist_strs = [prec.dist_str() for prec in reduced_index]
assert 'channel-1::anaconda-1.5.0-np17py27_0' in dist_strs
assert 'channel-1::dynd-python-0.3.0-np17py33_0' in dist_strs
def test_get_reduced_index_unmanageable():
index, r = get_index_r_4()
index = index.copy()
channels = r.channels
prefix_path = join(TEST_DATA_DIR, "env_metadata", "envpy27osx")
if not isdir(prefix_path):
pytest.skip("test files not found: %s" % prefix_path)
anchor_file = "lib/python2.7/site-packages/requests-2.19.1-py2.7.egg/EGG-INFO/PKG-INFO"
py_rec = read_python_record(prefix_path, anchor_file, "2.7")
assert py_rec.package_type == PackageType.VIRTUAL_PYTHON_EGG_UNMANAGEABLE
index[py_rec] = py_rec
new_r = Resolve(index, channels=channels)
reduced_index = new_r.get_reduced_index((MatchSpec("requests"),))
new_r2 = Resolve(reduced_index, True, True, channels=channels)
assert len(new_r2.groups["requests"]) == 1, new_r2.groups["requests"]
def test_generate_eq_1():
reduced_index = r.get_reduced_index([MatchSpec('anaconda')])
r2 = Resolve(reduced_index, True, True)
C = r2.gen_clauses()
eqc, eqv, eqb, eqt = r2.generate_version_metrics(C, list(r2.groups.keys()))
# Should satisfy the following criteria:
# - lower versions of the same package should should have higher
# coefficients.
# - the same versions of the same package (e.g., different build strings)
# should have the same coefficients.
# - a package that only has one version should not appear, unless
# include=True as it will have a 0 coefficient. The same is true of the
# latest version of a package.
eqc = {key: value for key, value in iteritems(eqc)}
eqv = {key: value for key, value in iteritems(eqv)}
eqb = {key: value for key, value in iteritems(eqb)}
eqt = {key: value for key, value in iteritems(eqt)}
assert eqc == {}
assert eqv == {
'channel-1::anaconda-1.4.0-np15py26_0': 1,
'channel-1::anaconda-1.4.0-np15py27_0': 1,
'channel-1::anaconda-1.4.0-np16py26_0': 1,
'channel-1::anaconda-1.4.0-np16py27_0': 1,
'channel-1::anaconda-1.4.0-np17py26_0': 1,
'channel-1::anaconda-1.4.0-np17py27_0': 1,
'channel-1::anaconda-1.4.0-np17py33_0': 1,
'channel-1::astropy-0.2-np15py26_0': 1,
'channel-1::astropy-0.2-np15py27_0': 1,
'channel-1::astropy-0.2-np16py26_0': 1,
'channel-1::astropy-0.2-np16py27_0': 1,
'channel-1::astropy-0.2-np17py26_0': 1,
'channel-1::astropy-0.2-np17py27_0': 1,
'channel-1::astropy-0.2-np17py33_0': 1,
'channel-1::biopython-1.60-np15py26_0': 1,
'channel-1::biopython-1.60-np15py27_0': 1,
'channel-1::biopython-1.60-np16py26_0': 1,
'channel-1::biopython-1.60-np16py27_0': 1,
'channel-1::biopython-1.60-np17py26_0': 1,
'channel-1::biopython-1.60-np17py27_0': 1,
'channel-1::bitarray-0.8.0-py26_0': 1,
'channel-1::bitarray-0.8.0-py27_0': 1,
'channel-1::bitarray-0.8.0-py33_0': 1,
'channel-1::boto-2.8.0-py26_0': 1,
'channel-1::boto-2.8.0-py27_0': 1,
'channel-1::conda-1.4.4-py27_0': 1,
'channel-1::cython-0.18-py26_0': 1,
'channel-1::cython-0.18-py27_0': 1,
'channel-1::cython-0.18-py33_0': 1,
'channel-1::distribute-0.6.34-py26_1': 1,
'channel-1::distribute-0.6.34-py27_1': 1,
'channel-1::distribute-0.6.34-py33_1': 1,
'channel-1::gevent-0.13.7-py26_0': 1,
'channel-1::gevent-0.13.7-py27_0': 1,
'channel-1::ipython-0.13.1-py26_1': 1,
'channel-1::ipython-0.13.1-py27_1': 1,
'channel-1::ipython-0.13.1-py33_1': 1,
'channel-1::llvmpy-0.11.1-py26_0': 1,
'channel-1::llvmpy-0.11.1-py27_0': 1,
'channel-1::llvmpy-0.11.1-py33_0': 1,
'channel-1::lxml-3.0.2-py26_0': 1,
'channel-1::lxml-3.0.2-py27_0': 1,
'channel-1::lxml-3.0.2-py33_0': 1,
'channel-1::matplotlib-1.2.0-np15py26_1': 1,
'channel-1::matplotlib-1.2.0-np15py27_1': 1,
'channel-1::matplotlib-1.2.0-np16py26_1': 1,
'channel-1::matplotlib-1.2.0-np16py27_1': 1,
'channel-1::matplotlib-1.2.0-np17py26_1': 1,
'channel-1::matplotlib-1.2.0-np17py27_1': 1,
'channel-1::matplotlib-1.2.0-np17py33_1': 1,
'channel-1::nose-1.2.1-py26_0': 1,
'channel-1::nose-1.2.1-py27_0': 1,
'channel-1::nose-1.2.1-py33_0': 1,
'channel-1::numba-0.7.0-np16py26_1': 1,
'channel-1::numba-0.7.0-np16py27_1': 1,
'channel-1::numba-0.7.0-np17py26_1': 1,
'channel-1::numba-0.7.0-np17py27_1': 1,
'channel-1::numpy-1.5.1-py26_3': 3,
'channel-1::numpy-1.5.1-py27_3': 3,
'channel-1::numpy-1.6.2-py26_3': 2,
'channel-1::numpy-1.6.2-py26_4': 2,
# 'channel-1::numpy-1.6.2-py26_p4': 2,
'channel-1::numpy-1.6.2-py27_3': 2,
'channel-1::numpy-1.6.2-py27_4': 2,
# 'channel-1::numpy-1.6.2-py27_p4': 2,
'channel-1::numpy-1.7.0-py26_0': 1,
'channel-1::numpy-1.7.0-py27_0': 1,
'channel-1::numpy-1.7.0-py33_0': 1,
'channel-1::pandas-0.10.0-np16py26_0': 2,
'channel-1::pandas-0.10.0-np16py27_0': 2,
'channel-1::pandas-0.10.0-np17py26_0': 2,
'channel-1::pandas-0.10.0-np17py27_0': 2,
'channel-1::pandas-0.10.1-np16py26_0': 1,
'channel-1::pandas-0.10.1-np16py27_0': 1,
'channel-1::pandas-0.10.1-np17py26_0': 1,
'channel-1::pandas-0.10.1-np17py27_0': 1,
'channel-1::pandas-0.10.1-np17py33_0': 1,
'channel-1::pandas-0.8.1-np16py26_0': 5,
'channel-1::pandas-0.8.1-np16py27_0': 5,
'channel-1::pandas-0.8.1-np17py26_0': 5,
'channel-1::pandas-0.8.1-np17py27_0': 5,
'channel-1::pandas-0.9.0-np16py26_0': 4,
'channel-1::pandas-0.9.0-np16py27_0': 4,
'channel-1::pandas-0.9.0-np17py26_0': 4,
'channel-1::pandas-0.9.0-np17py27_0': 4,
'channel-1::pandas-0.9.1-np16py26_0': 3,
'channel-1::pandas-0.9.1-np16py27_0': 3,
'channel-1::pandas-0.9.1-np17py26_0': 3,
'channel-1::pandas-0.9.1-np17py27_0': 3,
'channel-1::pip-1.2.1-py26_1': 1,
'channel-1::pip-1.2.1-py27_1': 1,
'channel-1::pip-1.2.1-py33_1': 1,
'channel-1::psutil-0.6.1-py26_0': 1,
'channel-1::psutil-0.6.1-py27_0': 1,
'channel-1::psutil-0.6.1-py33_0': 1,
'channel-1::pyflakes-0.6.1-py26_0': 1,
'channel-1::pyflakes-0.6.1-py27_0': 1,
'channel-1::pyflakes-0.6.1-py33_0': 1,
'channel-1::python-2.6.8-6': 4,
'channel-1::python-2.7.3-7': 3,
'channel-1::python-2.7.4-0': 2,
'channel-1::python-3.3.0-4': 1,
'channel-1::pytz-2012j-py26_0': 1,
'channel-1::pytz-2012j-py27_0': 1,
'channel-1::pytz-2012j-py33_0': 1,
'channel-1::requests-0.13.9-py26_0': 1,
'channel-1::requests-0.13.9-py27_0': 1,
'channel-1::requests-0.13.9-py33_0': 1,
'channel-1::scikit-learn-0.13-np15py26_1': 1,
'channel-1::scikit-learn-0.13-np15py27_1': 1,
'channel-1::scikit-learn-0.13-np16py26_1': 1,
'channel-1::scikit-learn-0.13-np16py27_1': 1,
'channel-1::scikit-learn-0.13-np17py26_1': 1,
'channel-1::scikit-learn-0.13-np17py27_1': 1,
'channel-1::scipy-0.11.0-np15py26_3': 1,
'channel-1::scipy-0.11.0-np15py27_3': 1,
'channel-1::scipy-0.11.0-np16py26_3': 1,
'channel-1::scipy-0.11.0-np16py27_3': 1,
'channel-1::scipy-0.11.0-np17py26_3': 1,
'channel-1::scipy-0.11.0-np17py27_3': 1,
'channel-1::scipy-0.11.0-np17py33_3': 1,
'channel-1::six-1.2.0-py26_0': 1,
'channel-1::six-1.2.0-py27_0': 1,
'channel-1::six-1.2.0-py33_0': 1,
'channel-1::spyder-2.1.13-py27_0': 1,
'channel-1::sqlalchemy-0.7.8-py26_0': 1,
'channel-1::sqlalchemy-0.7.8-py27_0': 1,
'channel-1::sqlalchemy-0.7.8-py33_0': 1,
'channel-1::sympy-0.7.1-py26_0': 1,
'channel-1::sympy-0.7.1-py27_0': 1,
'channel-1::tornado-2.4.1-py26_0': 1,
'channel-1::tornado-2.4.1-py27_0': 1,
'channel-1::tornado-2.4.1-py33_0': 1,
'channel-1::xlrd-0.9.0-py26_0': 1,
'channel-1::xlrd-0.9.0-py27_0': 1,
'channel-1::xlrd-0.9.0-py33_0': 1,
'channel-1::xlwt-0.7.4-py26_0': 1,
'channel-1::xlwt-0.7.4-py27_0': 1,
}
assert eqb == {
'channel-1::cairo-1.12.2-0': 1,
'channel-1::cubes-0.10.2-py27_0': 1,
'channel-1::dateutil-2.1-py26_0': 1,
'channel-1::dateutil-2.1-py27_0': 1,
'channel-1::dateutil-2.1-py33_0': 1,
'channel-1::gevent-websocket-0.3.6-py26_1': 1,
'channel-1::gevent-websocket-0.3.6-py27_1': 1,
'channel-1::gevent_zeromq-0.2.5-py26_1': 1,
'channel-1::gevent_zeromq-0.2.5-py27_1': 1,
'channel-1::libnetcdf-4.2.1.1-0': 1,
'channel-1::numexpr-2.0.1-np16py26_1': 2,
'channel-1::numexpr-2.0.1-np16py26_2': 1,
'channel-1::numexpr-2.0.1-np16py26_ce0': 3,
'channel-1::numexpr-2.0.1-np16py26_p1': 2,
'channel-1::numexpr-2.0.1-np16py26_p2': 1,
'channel-1::numexpr-2.0.1-np16py26_pro0': 3,
'channel-1::numexpr-2.0.1-np16py27_1': 2,
'channel-1::numexpr-2.0.1-np16py27_2': 1,
'channel-1::numexpr-2.0.1-np16py27_ce0': 3,
'channel-1::numexpr-2.0.1-np16py27_p1': 2,
'channel-1::numexpr-2.0.1-np16py27_p2': 1,
'channel-1::numexpr-2.0.1-np16py27_pro0': 3,
'channel-1::numexpr-2.0.1-np17py26_1': 2,
'channel-1::numexpr-2.0.1-np17py26_2': 1,
'channel-1::numexpr-2.0.1-np17py26_ce0': 3,
'channel-1::numexpr-2.0.1-np17py26_p1': 2,
'channel-1::numexpr-2.0.1-np17py26_p2': 1,
'channel-1::numexpr-2.0.1-np17py26_pro0': 3,
'channel-1::numexpr-2.0.1-np17py27_1': 2,
'channel-1::numexpr-2.0.1-np17py27_2': 1,
'channel-1::numexpr-2.0.1-np17py27_ce0': 3,
'channel-1::numexpr-2.0.1-np17py27_p1': 2,
'channel-1::numexpr-2.0.1-np17py27_p2': 1,
'channel-1::numexpr-2.0.1-np17py27_pro0': 3,
'channel-1::numpy-1.6.2-py26_3': 1,
'channel-1::numpy-1.6.2-py27_3': 1,
'channel-1::py2cairo-1.10.0-py26_0': 1,
'channel-1::py2cairo-1.10.0-py27_0': 1,
'channel-1::pycurl-7.19.0-py26_0': 1,
'channel-1::pycurl-7.19.0-py27_0': 1,
'channel-1::pysal-1.5.0-np15py27_0': 1,
'channel-1::pysal-1.5.0-np16py27_0': 1,
'channel-1::pysal-1.5.0-np17py27_0': 1,
'channel-1::pytest-2.3.4-py26_0': 1,
'channel-1::pytest-2.3.4-py27_0': 1,
'channel-1::pyzmq-2.2.0.1-py26_0': 1,
'channel-1::pyzmq-2.2.0.1-py27_0': 1,
'channel-1::pyzmq-2.2.0.1-py33_0': 1,
'channel-1::scikit-image-0.8.2-np16py26_0': 1,
'channel-1::scikit-image-0.8.2-np16py27_0': 1,
'channel-1::scikit-image-0.8.2-np17py26_0': 1,
'channel-1::scikit-image-0.8.2-np17py27_0': 1,
'channel-1::scikit-image-0.8.2-np17py33_0': 1,
'channel-1::sphinx-1.1.3-py26_2': 1,
'channel-1::sphinx-1.1.3-py27_2': 1,
'channel-1::sphinx-1.1.3-py33_2': 1,
'channel-1::statsmodels-0.4.3-np16py26_0': 1,
'channel-1::statsmodels-0.4.3-np16py27_0': 1,
'channel-1::statsmodels-0.4.3-np17py26_0': 1,
'channel-1::statsmodels-0.4.3-np17py27_0': 1,
'channel-1::system-5.8-0': 1,
'channel-1::theano-0.5.0-np15py26_0': 1,
'channel-1::theano-0.5.0-np15py27_0': 1,
'channel-1::theano-0.5.0-np16py26_0': 1,
'channel-1::theano-0.5.0-np16py27_0': 1,
'channel-1::theano-0.5.0-np17py26_0': 1,
'channel-1::theano-0.5.0-np17py27_0': 1,
'channel-1::zeromq-2.2.0-0': 1,
}
# No timestamps in the current data set
assert eqt == {}
def test_unsat():
# scipy 0.12.0b1 is not built for numpy 1.5, only 1.6 and 1.7
assert raises(UnsatisfiableError, lambda: r.install(['numpy 1.5*', 'scipy 0.12.0b1']))
# numpy 1.5 does not have a python 3 package
assert raises(UnsatisfiableError, lambda: r.install(['numpy 1.5*', 'python 3*']))
assert raises(UnsatisfiableError, lambda: r.install(['numpy 1.5*', 'numpy 1.6*']))
def test_nonexistent():
assert not r.find_matches(MatchSpec('notarealpackage 2.0*'))
assert raises(ResolvePackageNotFound, lambda: r.install(['notarealpackage 2.0*']))
# This exact version of NumPy does not exist
assert raises(ResolvePackageNotFound, lambda: r.install(['numpy 1.5']))
def test_timestamps_and_deps():
# If timestamp maximization is performed too early in the solve optimization,
# it will force unnecessary changes to dependencies. Timestamp maximization needs
# to be done at low priority so that conda is free to consider packages with the
# same version and build that are most compatible with the installed environment.
index2 = {key: value for key, value in iteritems(index)}
mypackage1 = PackageRecord(**{
'build': 'hash12_0',
'build_number': 0,
'depends': ['libpng 1.2.*'],
'name': 'mypackage',
'requires': ['libpng 1.2.*'],
'version': '1.0',
'timestamp': 1,
})
index2[mypackage1] = mypackage1
mypackage2 = PackageRecord(**{
'build': 'hash15_0',
'build_number': 0,
'depends': ['libpng 1.5.*'],
'name': 'mypackage',
'requires': ['libpng 1.5.*'],
'version': '1.0',
'timestamp': 0,
})
index2[mypackage2] = mypackage2
r = Resolve(index2)
installed1 = r.install(['libpng 1.2.*', 'mypackage'])
print([prec.dist_str() for prec in installed1])
assert any(k.name == 'libpng' and k.version.startswith('1.2') for k in installed1)
assert any(k.name == 'mypackage' and k.build == 'hash12_0' for k in installed1)
installed2 = r.install(['libpng 1.5.*', 'mypackage'])
assert any(k.name == 'libpng' and k.version.startswith('1.5') for k in installed2)
assert any(k.name == 'mypackage' and k.build == 'hash15_0' for k in installed2)
# this is testing that previously installed reqs are not disrupted by newer timestamps.
# regression test of sorts for https://github.com/conda/conda/issues/6271
installed3 = r.install(['mypackage'], r.install(['libpng 1.2.*']))
assert installed1 == installed3
installed4 = r.install(['mypackage'], r.install(['libpng 1.5.*']))
assert installed2 == installed4
# unspecified python version should maximize libpng (v1.5), even though it has a lower timestamp
installed5 = r.install(['mypackage'])
assert installed2 == installed5
def test_nonexistent_deps():
index2 = index.copy()
p1 = PackageRecord(**{
"channel": "defaults",
"subdir": context.subdir,
"md5": "0123456789",
"fn": "doesnt-matter-here",
'build': 'py33_0',
'build_number': 0,
'depends': ['nose', 'python 3.3*', 'notarealpackage 2.0*'],
'name': 'mypackage',
'requires': ['nose 1.2.1', 'python 3.3'],
'version': '1.0',
})
p2 = PackageRecord(**{
"channel": "defaults",
"subdir": context.subdir,
"md5": "0123456789",
"fn": "doesnt-matter-here",
'build': 'py33_0',
'build_number': 0,
'depends': ['nose', 'python 3.3*'],
'name': 'mypackage',
'requires': ['nose 1.2.1', 'python 3.3'],
'version': '1.1',
})
p3 = PackageRecord(**{
"channel": "defaults",
"subdir": context.subdir,
"md5": "0123456789",
"fn": "doesnt-matter-here",
'build': 'py33_0',
'build_number': 0,
'depends': ['nose', 'mypackage 1.1'],
'name': 'anotherpackage',
'requires': ['nose', 'mypackage 1.1'],
'version': '1.0',
})
p4 = PackageRecord(**{
"channel": "defaults",
"subdir": context.subdir,
"md5": "0123456789",
"fn": "doesnt-matter-here",
'build': 'py33_0',
'build_number': 0,
'depends': ['nose', 'mypackage'],
'name': 'anotherpackage',
'requires': ['nose', 'mypackage'],
'version': '2.0',
})
index2.update({p1: p1, p2: p2, p3: p3, p4: p4})
index2 = {key: value for key, value in iteritems(index2)}
r = Resolve(index2)
assert set(prec.dist_str() for prec in r.find_matches(MatchSpec('mypackage'))) == {
'defaults::mypackage-1.0-py33_0',
'defaults::mypackage-1.1-py33_0',
}
assert set(prec.dist_str() for prec in r.get_reduced_index([MatchSpec('mypackage')])) == {
'defaults::mypackage-1.1-py33_0',
'channel-1::nose-1.1.2-py33_0',
'channel-1::nose-1.2.1-py33_0',
'channel-1::nose-1.3.0-py33_0',
'channel-1::openssl-1.0.1c-0',
'channel-1::python-3.3.0-2',
'channel-1::python-3.3.0-3',
'channel-1::python-3.3.0-4',
'channel-1::python-3.3.0-pro0',
'channel-1::python-3.3.0-pro1',
'channel-1::python-3.3.1-0',
'channel-1::python-3.3.2-0',
'channel-1::readline-6.2-0',
'channel-1::sqlite-3.7.13-0',
'channel-1::system-5.8-0',
'channel-1::system-5.8-1',
'channel-1::tk-8.5.13-0',
'channel-1::zlib-1.2.7-0',
}
target_result = r.install(['mypackage'])
assert target_result == r.install(['mypackage 1.1'])
target_result = [rec.dist_str() for rec in target_result]
assert target_result == [
'defaults::mypackage-1.1-py33_0',
'channel-1::nose-1.3.0-py33_0',
'channel-1::openssl-1.0.1c-0',
'channel-1::python-3.3.2-0',
'channel-1::readline-6.2-0',
'channel-1::sqlite-3.7.13-0',
'channel-1::system-5.8-1',
'channel-1::tk-8.5.13-0',
'channel-1::zlib-1.2.7-0',
]
assert raises(ResolvePackageNotFound, lambda: r.install(['mypackage 1.0']))
assert raises(ResolvePackageNotFound, lambda: r.install(['mypackage 1.0', 'burgertime 1.0']))
target_result = r.install(['anotherpackage 1.0'])
target_result = [rec.dist_str() for rec in target_result]
assert target_result == [
'defaults::anotherpackage-1.0-py33_0',
'defaults::mypackage-1.1-py33_0',
'channel-1::nose-1.3.0-py33_0',
'channel-1::openssl-1.0.1c-0',
'channel-1::python-3.3.2-0',
'channel-1::readline-6.2-0',
'channel-1::sqlite-3.7.13-0',
'channel-1::system-5.8-1',
'channel-1::tk-8.5.13-0',
'channel-1::zlib-1.2.7-0',
]
target_result = r.install(['anotherpackage'])
target_result = [rec.dist_str() for rec in target_result]
assert target_result == [
'defaults::anotherpackage-2.0-py33_0',
'defaults::mypackage-1.1-py33_0',
'channel-1::nose-1.3.0-py33_0',
'channel-1::openssl-1.0.1c-0',
'channel-1::python-3.3.2-0',
'channel-1::readline-6.2-0',
'channel-1::sqlite-3.7.13-0',
'channel-1::system-5.8-1',
'channel-1::tk-8.5.13-0',
'channel-1::zlib-1.2.7-0',
]
# This time, the latest version is messed up
index3 = index.copy()
p5 = PackageRecord(**{
"channel": "defaults",
"subdir": context.subdir,
"md5": "0123456789",
"fn": "doesnt-matter-here",
'build': 'py33_0',
'build_number': 0,
'depends': ['nose', 'python 3.3*', 'notarealpackage 2.0*'],
'name': 'mypackage',
'requires': ['nose 1.2.1', 'python 3.3'],
'version': '1.1',
})
p6 = PackageRecord(**{
"channel": "defaults",
"subdir": context.subdir,
"md5": "0123456789",
"fn": "doesnt-matter-here",
'build': 'py33_0',
'build_number': 0,
'depends': ['nose', 'python 3.3*'],
'name': 'mypackage',
'requires': ['nose 1.2.1', 'python 3.3'],
'version': '1.0',
})
p7 = PackageRecord(**{
"channel": "defaults",
"subdir": context.subdir,
"md5": "0123456789",
"fn": "doesnt-matter-here",
'build': 'py33_0',
'build_number': 0,
'depends': ['nose', 'mypackage 1.0'],
'name': 'anotherpackage',
'requires': ['nose', 'mypackage 1.0'],
'version': '1.0',
})
p8 = PackageRecord(**{
"channel": "defaults",
"subdir": context.subdir,
"md5": "0123456789",
"fn": "doesnt-matter-here",
'build': 'py33_0',
'build_number': 0,
'depends': ['nose', 'mypackage'],
'name': 'anotherpackage',
'requires': ['nose', 'mypackage'],
'version': '2.0',
})
index3.update({p5: p5, p6: p6, p7: p7, p8: p8})
index3 = {key: value for key, value in iteritems(index3)}
r = Resolve(index3)
assert set(prec.dist_str() for prec in r.find_matches(MatchSpec('mypackage'))) == {
'defaults::mypackage-1.0-py33_0',
'defaults::mypackage-1.1-py33_0',
}
assert set(prec.dist_str() for prec in r.get_reduced_index([MatchSpec('mypackage')]).keys()) == {
'defaults::mypackage-1.0-py33_0',
'channel-1::nose-1.1.2-py33_0',
'channel-1::nose-1.2.1-py33_0',
'channel-1::nose-1.3.0-py33_0',
'channel-1::openssl-1.0.1c-0',
'channel-1::python-3.3.0-2',
'channel-1::python-3.3.0-3',
'channel-1::python-3.3.0-4',
'channel-1::python-3.3.0-pro0',
'channel-1::python-3.3.0-pro1',
'channel-1::python-3.3.1-0',
'channel-1::python-3.3.2-0',
'channel-1::readline-6.2-0',
'channel-1::sqlite-3.7.13-0',
'channel-1::system-5.8-0',
'channel-1::system-5.8-1',
'channel-1::tk-8.5.13-0',
'channel-1::zlib-1.2.7-0',
}
target_result = r.install(['mypackage'])
target_result = [rec.dist_str() for rec in target_result]
assert target_result == [
'defaults::mypackage-1.0-py33_0',
'channel-1::nose-1.3.0-py33_0',
'channel-1::openssl-1.0.1c-0',
'channel-1::python-3.3.2-0',
'channel-1::readline-6.2-0',
'channel-1::sqlite-3.7.13-0',
'channel-1::system-5.8-1',
'channel-1::tk-8.5.13-0',
'channel-1::zlib-1.2.7-0',
]
assert raises(ResolvePackageNotFound, lambda: r.install(['mypackage 1.1']))
target_result = r.install(['anotherpackage 1.0'])
target_result = [rec.dist_str() for rec in target_result]
assert target_result == [
'defaults::anotherpackage-1.0-py33_0',
'defaults::mypackage-1.0-py33_0',
'channel-1::nose-1.3.0-py33_0',
'channel-1::openssl-1.0.1c-0',
'channel-1::python-3.3.2-0',
'channel-1::readline-6.2-0',
'channel-1::sqlite-3.7.13-0',
'channel-1::system-5.8-1',
'channel-1::tk-8.5.13-0',
'channel-1::zlib-1.2.7-0',
]
# If recursive checking is working correctly, this will give
# anotherpackage 2.0, not anotherpackage 1.0
target_result = r.install(['anotherpackage'])
target_result = [rec.dist_str() for rec in target_result]
assert target_result == [
'defaults::anotherpackage-2.0-py33_0',
'defaults::mypackage-1.0-py33_0',
'channel-1::nose-1.3.0-py33_0',
'channel-1::openssl-1.0.1c-0',
'channel-1::python-3.3.2-0',
'channel-1::readline-6.2-0',
'channel-1::sqlite-3.7.13-0',
'channel-1::system-5.8-1',
'channel-1::tk-8.5.13-0',
'channel-1::zlib-1.2.7-0',
]
def test_install_package_with_feature():
index2 = index.copy()
p1 = PackageRecord(**{
"channel": "defaults",
"subdir": context.subdir,
"md5": "0123456789",
"fn": "doesnt-matter-here",
'build': 'featurepy33_0',
'build_number': 0,
'depends': ['python 3.3*'],
'name': 'mypackage',
'version': '1.0',
'features': 'feature',
})
p2 = PackageRecord(**{
"channel": "defaults",
"subdir": context.subdir,
"md5": "0123456789",
"fn": "doesnt-matter-here",
'build': 'py33_0',
'build_number': 0,
'depends': ['python 3.3*'],
'name': 'feature',
'version': '1.0',
'track_features': 'feature',
})
index2.update({p1: p1, p2: p2})
index2 = {key: value for key, value in iteritems(index2)}
r = Resolve(index2)
# It should not raise
r.install(['mypackage','feature 1.0'])
def test_unintentional_feature_downgrade():
# See https://github.com/conda/conda/issues/6765
# With the bug in place, this bad build of scipy
# will be selected for install instead of a later
# build of scipy 0.11.0.
good_rec_match = MatchSpec("channel-1::scipy==0.11.0=np17py33_3")
good_rec = next(prec for prec in itervalues(index) if good_rec_match.match(prec))
bad_deps = tuple(d for d in good_rec.depends
if not d.startswith('numpy'))
bad_rec = PackageRecord.from_objects(good_rec,
build=good_rec.build.replace('_3','_x0'),
build_number=0, depends=bad_deps,
fn=good_rec.fn.replace('_3','_x0'),
url=good_rec.url.replace('_3','_x0'))
index2 = index.copy()
index2[bad_rec] = bad_rec
r = Resolve(index2)
install = r.install(['scipy 0.11.0'])
assert bad_rec not in install
assert any(d.name == 'numpy' for d in install)
def test_circular_dependencies():
index2 = index.copy()
package1 = PackageRecord(**{
"channel": "defaults",
"subdir": context.subdir,
"md5": "0123456789",
"fn": "doesnt-matter-here",
'build': '0',
'build_number': 0,
'depends': ['package2'],
'name': 'package1',
'requires': ['package2'],
'version': '1.0',
})
index2[package1] = package1
package2 = PackageRecord(**{
"channel": "defaults",
"subdir": context.subdir,
"md5": "0123456789",
"fn": "doesnt-matter-here",
'build': '0',
'build_number': 0,
'depends': ['package1'],
'name': 'package2',
'requires': ['package1'],
'version': '1.0',
})
index2[package2] = package2
index2 = {key: value for key, value in iteritems(index2)}
r = Resolve(index2)
assert set(prec.dist_str() for prec in r.find_matches(MatchSpec('package1'))) == {
'defaults::package1-1.0-0',
}
assert set(prec.dist_str() for prec in r.get_reduced_index([MatchSpec('package1')]).keys()) == {
'defaults::package1-1.0-0',
'defaults::package2-1.0-0',
}
result = r.install(['package1', 'package2'])
assert r.install(['package1']) == r.install(['package2']) == result
result = [r.dist_str() for r in result]
assert result == [
'defaults::package1-1.0-0',
'defaults::package2-1.0-0',
]
def test_optional_dependencies():
index2 = index.copy()
p1 = PackageRecord(**{
"channel": "defaults",
"subdir": context.subdir,
"md5": "0123456789",
"fn": "doesnt-matter-here",
'build': '0',
'build_number': 0,
'constrains': ['package2 >1.0'],
'name': 'package1',
'requires': ['package2'],
'version': '1.0',
})
p2 = PackageRecord(**{
"channel": "defaults",
"subdir": context.subdir,
"md5": "0123456789",
"fn": "doesnt-matter-here",
'build': '0',
'build_number': 0,
'depends': [],
'name': 'package2',
'requires': [],
'version': '1.0',
})
p3 = PackageRecord(**{
"channel": "defaults",
"subdir": context.subdir,
"md5": "0123456789",
"fn": "doesnt-matter-here",
'build': '0',
'build_number': 0,
'depends': [],
'name': 'package2',
'requires': [],
'version': '2.0',
})
index2.update({p1: p1, p2: p2, p3: p3})
index2 = {key: value for key, value in iteritems(index2)}
r = Resolve(index2)
assert set(prec.dist_str() for prec in r.find_matches(MatchSpec('package1'))) == {
'defaults::package1-1.0-0',
}
assert set(prec.dist_str() for prec in r.get_reduced_index([MatchSpec('package1')]).keys()) == {
'defaults::package1-1.0-0',
'defaults::package2-2.0-0',
}
result = r.install(['package1'])
result = [rec.dist_str() for rec in result]
assert result == [
'defaults::package1-1.0-0',
]
result = r.install(['package1', 'package2'])
assert result == r.install(['package1', 'package2 >1.0'])
result = [rec.dist_str() for rec in result]
assert result == [
'defaults::package1-1.0-0',
'defaults::package2-2.0-0',
]
assert raises(UnsatisfiableError, lambda: r.install(['package1', 'package2 <2.0']))
assert raises(UnsatisfiableError, lambda: r.install(['package1', 'package2 1.0']))
def test_irrational_version():
result = r.install(['pytz 2012d', 'python 3*'], returnall=True)
result = [rec.dist_str() for rec in result]
assert result == [
'channel-1::openssl-1.0.1c-0',
'channel-1::python-3.3.2-0',
'channel-1::pytz-2012d-py33_0',
'channel-1::readline-6.2-0',
'channel-1::sqlite-3.7.13-0',
'channel-1::system-5.8-1',
'channel-1::tk-8.5.13-0',
'channel-1::zlib-1.2.7-0',
]
def test_no_features():
# Without this, there would be another solution including 'scipy-0.11.0-np16py26_p3.tar.bz2'.
result = r.install(['python 2.6*', 'numpy 1.6*', 'scipy 0.11*'], returnall=True)
result = [rec.dist_str() for rec in result]
assert result == [
'channel-1::numpy-1.6.2-py26_4',
'channel-1::openssl-1.0.1c-0',
'channel-1::python-2.6.8-6',
'channel-1::readline-6.2-0',
'channel-1::scipy-0.11.0-np16py26_3',
'channel-1::sqlite-3.7.13-0',
'channel-1::system-5.8-1',
'channel-1::tk-8.5.13-0',
'channel-1::zlib-1.2.7-0',
]
result = r.install(['python 2.6*', 'numpy 1.6*', 'scipy 0.11*', MatchSpec(track_features='mkl')], returnall=True)
result = [rec.dist_str() for rec in result]
assert result == [
'channel-1::mkl-rt-11.0-p0', # This,
'channel-1::numpy-1.6.2-py26_p4', # this,
'channel-1::openssl-1.0.1c-0',
'channel-1::python-2.6.8-6',
'channel-1::readline-6.2-0',
'channel-1::scipy-0.11.0-np16py26_p3', # and this are different.
'channel-1::sqlite-3.7.13-0',
'channel-1::system-5.8-1',
'channel-1::tk-8.5.13-0',
'channel-1::zlib-1.2.7-0',
]
index2 = index.copy()
pandas = PackageRecord(**{
"channel": "channel-1",
"subdir": context.subdir,
"md5": "0123456789",
"fn": "doesnt-matter-here",
"build": "np16py27_0",
"build_number": 0,
"depends": [
"dateutil",
"numpy 1.6*",
"python 2.7*",
"pytz"
],
"name": "pandas",
"requires": [
"dateutil 1.5",
"numpy 1.6",
"python 2.7",
"pytz"
],
"version": "0.12.0"
})
index2[pandas] = pandas
# Make it want to choose the pro version by having it be newer.
numpy = PackageRecord(**{
"channel": "channel-1",
"subdir": context.subdir,
"md5": "0123456789",
"fn": "doesnt-matter-here",
"build": "py27_p5",
"build_number": 5,
"depends": [
"mkl-rt 11.0",
"python 2.7*"
],
"features": "mkl",
"name": "numpy",
"pub_date": "2013-04-29",
"requires": [
"mkl-rt 11.0",
"python 2.7"
],
"version": "1.6.2"
})
index2[numpy] = numpy
index2 = {key: value for key, value in iteritems(index2)}
r2 = Resolve(index2)
# This should not pick any mkl packages (the difference here is that none
# of the specs directly have mkl versions)
result = r2.solve(['pandas 0.12.0 np16py27_0', 'python 2.7*'], returnall=True)
result = [rec.dist_str() for rec in result]
assert result == [
'channel-1::dateutil-2.1-py27_1',
'channel-1::numpy-1.6.2-py27_4',
'channel-1::openssl-1.0.1c-0',
'channel-1::pandas-0.12.0-np16py27_0',
'channel-1::python-2.7.5-0',
'channel-1::pytz-2013b-py27_0',