-
Notifications
You must be signed in to change notification settings - Fork 91
Expand file tree
/
Copy pathtest_recipe_parser.py
More file actions
1866 lines (1609 loc) · 57.2 KB
/
test_recipe_parser.py
File metadata and controls
1866 lines (1609 loc) · 57.2 KB
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 io
import os
from collections.abc import Iterator
from pathlib import Path
import pytest
from conda_forge_tick.recipe_parser import CONDA_SELECTOR, CondaMetaYAML
from conda_forge_tick.recipe_parser._parser import (
_build_jinja2_expr_tmp,
_demunge_jinja2_vars,
_munge_line,
_parse_jinja2_variables,
_remunge_jinja2_vars,
_replace_jinja2_vars,
_unmunge_line,
)
def test_parsing_ml_jinja2():
meta_yaml = """\
{% set namesel = 'val1' %} # [py2k]
{% set name = 'val1' %} # [py2k]
{% set name = 'val2' %}#[py3k and win]
{% set version = '4.5.6' %}
{% set major_ver = version.split('.')[0] %}
{% set bad_ver = bad_version.split('.')[0] %}
{% set vmajor,vminor,vpatch = version.split('.') %}
{% set crazy_string1 = ">=5,<7" ~ version %}
{% set crazy_string2 = '"' ~ version %}
{% set crazy_string3 = "'" ~ version %}
{% set crazy_string4 = "|" ~ version %}
{% set build = 0 %}
{% if False %}
{% set build = build + 100 %}
{% endif %}
{# this is a comment #}
package:
name: {{ name|lower }}
source:
url: foobar
sha256: 1 # [py2k]
sha256: 5#[py3k and win]
{% if (
True
and False
) %}
{% for i in [
1, 2, 3, 4
] %}
{% for blah in [2, 3] %}
{% endfor %}
{% if False %}
{% endif %}
{% endfor %}
{% if False %}
{% endif %}
{% endif %}
{% set list = [
blah1,
blah2,
] %}
{% for i in [
1, 2, 3, 4
] %}
{% for blah in [2, 3] %}
{% endfor %}
{% if False %}
{% endif %}
{% endfor %}
build:
number: 10
"""
meta_yaml_canonical = """\
{% set namesel = "val1" %} # [py2k]
{% set name = "val1" %} # [py2k]
{% set name = "val2" %} # [py3k and win]
{% set version = "4.5.6" %}
{% set major_ver = version.split('.')[0] %}
{% set bad_ver = bad_version.split('.')[0] %}
{% set vmajor,vminor,vpatch = version.split('.') %}
{% set crazy_string1 = ">=5,<7" ~ version %}
{% set crazy_string2 = '"' ~ version %}
{% set crazy_string3 = "'" ~ version %}
{% set crazy_string4 = "|" ~ version %}
{% set build = 0 %}
{% if False %}
{% set build = build + 100 %}
{% endif %}
# this is a comment
package:
name: {{ name|lower }}
source:
url: foobar
sha256: 1 # [py2k]
sha256: 5 # [py3k and win]
{% if (
True
and False
) %}
{% for i in [
1, 2, 3, 4
] %}
{% for blah in [2, 3] %}
{% endfor %}
{% if False %}
{% endif %}
{% endfor %}
{% if False %}
{% endif %}
{% endif %}
{% set list = [
blah1,
blah2,
] %}
{% for i in [
1, 2, 3, 4
] %}
{% for blah in [2, 3] %}
{% endfor %}
{% if False %}
{% endif %}
{% endfor %}
build:
number: 10
"""
cm = CondaMetaYAML(meta_yaml)
# check the jinja2 keys
assert cm.jinja2_vars["namesel__###conda-selector###__py2k"] == "val1"
assert cm.jinja2_vars["name__###conda-selector###__py2k"] == "val1"
assert cm.jinja2_vars["name__###conda-selector###__py3k and win"] == "val2"
assert cm.jinja2_vars["version"] == "4.5.6"
# check jinja2 expressions
assert cm.jinja2_exprs["major_ver"] == "{% set major_ver = version.split('.')[0] %}"
assert cm.jinja2_exprs["bad_ver"] == "{% set bad_ver = bad_version.split('.')[0] %}"
assert (
cm.jinja2_exprs["vmajor"]
== "{% set vmajor,vminor,vpatch = version.split('.') %}"
)
assert (
cm.jinja2_exprs["vminor"]
== "{% set vmajor,vminor,vpatch = version.split('.') %}"
)
assert (
cm.jinja2_exprs["vpatch"]
== "{% set vmajor,vminor,vpatch = version.split('.') %}"
)
assert (
cm.jinja2_exprs["crazy_string1"]
== '{% set crazy_string1 = ">=5,<7" ~ version %}'
)
assert (
cm.jinja2_exprs["crazy_string2"] == "{% set crazy_string2 = '\"' ~ version %}"
)
assert (
cm.jinja2_exprs["crazy_string3"] == '{% set crazy_string3 = "\'" ~ version %}'
)
assert cm.jinja2_exprs["crazy_string4"] == '{% set crazy_string4 = "|" ~ version %}'
# check it when we eval
jinja2_exprs_evaled = cm.eval_jinja2_exprs(cm.jinja2_vars)
assert jinja2_exprs_evaled["major_ver"] == "4"
assert jinja2_exprs_evaled["vmajor"] == "4"
assert jinja2_exprs_evaled["vminor"] == "5"
assert jinja2_exprs_evaled["vpatch"] == "6"
assert jinja2_exprs_evaled["crazy_string1"] == ">=5,<74.5.6"
assert jinja2_exprs_evaled["crazy_string2"] == '"4.5.6'
assert jinja2_exprs_evaled["crazy_string3"] == "'4.5.6"
assert jinja2_exprs_evaled["crazy_string4"] == "|4.5.6"
# check selectors
assert cm.meta["source"]["sha256__###conda-selector###__py2k"] == 1
assert cm.meta["source"]["sha256__###conda-selector###__py3k and win"] == 5
# check other keys
assert cm.meta["build"]["number"] == 10
assert cm.meta["package"]["name"] == "{{ name|lower }}"
assert cm.meta["source"]["url"] == "foobar"
s = io.StringIO()
cm.dump(s)
s.seek(0)
assert meta_yaml_canonical == s.read()
# now add stuff and test outputs
cm.jinja2_vars["foo"] = "bar"
cm.jinja2_vars["xfoo__###conda-selector###__win or osx"] = 10
cm.jinja2_vars["build"] = 100
cm.meta["about"] = 10
cm.meta["extra__###conda-selector###__win"] = "blah"
cm.meta["extra__###conda-selector###__not win"] = "not_win_blah"
s = io.StringIO()
cm.dump(s)
s.seek(0)
new_meta_yaml = s.read()
true_new_meta_yaml = """\
{% set foo = "bar" %}
{% set xfoo = 10 %} # [win or osx]
{% set namesel = "val1" %} # [py2k]
{% set name = "val1" %} # [py2k]
{% set name = "val2" %} # [py3k and win]
{% set version = "4.5.6" %}
{% set major_ver = version.split('.')[0] %}
{% set bad_ver = bad_version.split('.')[0] %}
{% set vmajor,vminor,vpatch = version.split('.') %}
{% set crazy_string1 = ">=5,<7" ~ version %}
{% set crazy_string2 = '"' ~ version %}
{% set crazy_string3 = "'" ~ version %}
{% set crazy_string4 = "|" ~ version %}
{% set build = 100 %}
{% if False %}
{% set build = build + 100 %}
{% endif %}
# this is a comment
package:
name: {{ name|lower }}
source:
url: foobar
sha256: 1 # [py2k]
sha256: 5 # [py3k and win]
{% if (
True
and False
) %}
{% for i in [
1, 2, 3, 4
] %}
{% for blah in [2, 3] %}
{% endfor %}
{% if False %}
{% endif %}
{% endfor %}
{% if False %}
{% endif %}
{% endif %}
{% set list = [
blah1,
blah2,
] %}
{% for i in [
1, 2, 3, 4
] %}
{% for blah in [2, 3] %}
{% endfor %}
{% if False %}
{% endif %}
{% endfor %}
build:
number: 10
"""
true_new_meta_yaml += """\
about: 10
extra: blah # [win]
extra: not_win_blah # [not win]
"""
assert new_meta_yaml == true_new_meta_yaml
@pytest.mark.parametrize("add_extra_req", [True, False])
def test_parsing(add_extra_req):
meta_yaml = """\
{% set name = 'val1' %} # [py2k]
{% set name = 'val2' %}#[py3k and win]
{% set version = '4.5.6' %}
{% set major_ver = version.split('.')[0] %}
{% set bad_ver = bad_version.split('.')[0] %}
{% set vmajor,vminor,vpatch = version.split('.') %}
{% set crazy_string1 = ">=5,<7" ~ version %}
{% set crazy_string2 = '"' ~ version %}
{% set crazy_string3 = "'" ~ version %}
{% set crazy_string4 = "|" ~ version %}
{% set build = 0 %}
{% if False %}
{% set build = build + 100 %}
{% endif %}
package:
name: {{ name|lower }}
source:
url: foobar
sha256: 1 # [py2k]
sha256: 5#[py3k and win]
build:
number: 10
"""
if add_extra_req:
meta_yaml += """\
requirements:
host:
- blah <{{ blarg }}
"""
meta_yaml_canonical = """\
{% set name = "val1" %} # [py2k]
{% set name = "val2" %} # [py3k and win]
{% set version = "4.5.6" %}
{% set major_ver = version.split('.')[0] %}
{% set bad_ver = bad_version.split('.')[0] %}
{% set vmajor,vminor,vpatch = version.split('.') %}
{% set crazy_string1 = ">=5,<7" ~ version %}
{% set crazy_string2 = '"' ~ version %}
{% set crazy_string3 = "'" ~ version %}
{% set crazy_string4 = "|" ~ version %}
{% set build = 0 %}
{% if False %}
{% set build = build + 100 %}
{% endif %}
package:
name: {{ name|lower }}
source:
url: foobar
sha256: 1 # [py2k]
sha256: 5 # [py3k and win]
build:
number: 10
"""
if add_extra_req:
meta_yaml_canonical += """\
requirements:
host:
- blah <{{ blarg }}
"""
cm = CondaMetaYAML(meta_yaml)
# check the jinja2 keys
assert cm.jinja2_vars["name__###conda-selector###__py2k"] == "val1"
assert cm.jinja2_vars["name__###conda-selector###__py3k and win"] == "val2"
assert cm.jinja2_vars["version"] == "4.5.6"
# check jinja2 expressions
assert cm.jinja2_exprs["major_ver"] == "{% set major_ver = version.split('.')[0] %}"
assert cm.jinja2_exprs["bad_ver"] == "{% set bad_ver = bad_version.split('.')[0] %}"
assert (
cm.jinja2_exprs["vmajor"]
== "{% set vmajor,vminor,vpatch = version.split('.') %}"
)
assert (
cm.jinja2_exprs["vminor"]
== "{% set vmajor,vminor,vpatch = version.split('.') %}"
)
assert (
cm.jinja2_exprs["vpatch"]
== "{% set vmajor,vminor,vpatch = version.split('.') %}"
)
assert (
cm.jinja2_exprs["crazy_string1"]
== '{% set crazy_string1 = ">=5,<7" ~ version %}'
)
assert (
cm.jinja2_exprs["crazy_string2"] == "{% set crazy_string2 = '\"' ~ version %}"
)
assert (
cm.jinja2_exprs["crazy_string3"] == '{% set crazy_string3 = "\'" ~ version %}'
)
assert cm.jinja2_exprs["crazy_string4"] == '{% set crazy_string4 = "|" ~ version %}'
# check it when we eval
jinja2_exprs_evaled = cm.eval_jinja2_exprs(cm.jinja2_vars)
assert jinja2_exprs_evaled["major_ver"] == "4"
assert jinja2_exprs_evaled["vmajor"] == "4"
assert jinja2_exprs_evaled["vminor"] == "5"
assert jinja2_exprs_evaled["vpatch"] == "6"
assert jinja2_exprs_evaled["crazy_string1"] == ">=5,<74.5.6"
assert jinja2_exprs_evaled["crazy_string2"] == '"4.5.6'
assert jinja2_exprs_evaled["crazy_string3"] == "'4.5.6"
assert jinja2_exprs_evaled["crazy_string4"] == "|4.5.6"
# check selectors
assert cm.meta["source"]["sha256__###conda-selector###__py2k"] == 1
assert cm.meta["source"]["sha256__###conda-selector###__py3k and win"] == 5
# check other keys
assert cm.meta["build"]["number"] == 10
assert cm.meta["package"]["name"] == "{{ name|lower }}"
assert cm.meta["source"]["url"] == "foobar"
if add_extra_req:
assert cm.meta["requirements"]["host"][0] == "blah <{{ blarg }}"
s = io.StringIO()
cm.dump(s)
s.seek(0)
assert meta_yaml_canonical == s.read()
# now add stuff and test outputs
cm.jinja2_vars["foo"] = "bar"
cm.jinja2_vars["xfoo__###conda-selector###__win or osx"] = 10
cm.jinja2_vars["build"] = 100
cm.meta["about"] = 10
cm.meta["extra__###conda-selector###__win"] = "blah"
cm.meta["extra__###conda-selector###__not win"] = "not_win_blah"
s = io.StringIO()
cm.dump(s)
s.seek(0)
new_meta_yaml = s.read()
true_new_meta_yaml = """\
{% set foo = "bar" %}
{% set xfoo = 10 %} # [win or osx]
{% set name = "val1" %} # [py2k]
{% set name = "val2" %} # [py3k and win]
{% set version = "4.5.6" %}
{% set major_ver = version.split('.')[0] %}
{% set bad_ver = bad_version.split('.')[0] %}
{% set vmajor,vminor,vpatch = version.split('.') %}
{% set crazy_string1 = ">=5,<7" ~ version %}
{% set crazy_string2 = '"' ~ version %}
{% set crazy_string3 = "'" ~ version %}
{% set crazy_string4 = "|" ~ version %}
{% set build = 100 %}
{% if False %}
{% set build = build + 100 %}
{% endif %}
package:
name: {{ name|lower }}
source:
url: foobar
sha256: 1 # [py2k]
sha256: 5 # [py3k and win]
build:
number: 10
"""
if add_extra_req:
true_new_meta_yaml += """\
requirements:
host:
- blah <{{ blarg }}
"""
true_new_meta_yaml += """\
about: 10
extra: blah # [win]
extra: not_win_blah # [not win]
"""
assert new_meta_yaml == true_new_meta_yaml
def test_replace_jinja2_vars():
lines = [
'{% set var1 = "val1" %} # [sel]\n',
"blah\n",
"{% set var2 = 5 %} # a comment\n",
'{% set var3 = "none" %}#[sel2 and none and osx]\n',
'{% set var4 = "val4" %}\n',
'{% set var5 = "val5" %}\n',
]
jinja2_vars = {
"var1" + CONDA_SELECTOR + "sel": "val4",
"var2": "4.5.6",
"var3" + CONDA_SELECTOR + "sel2 and none and osx": "None",
"var4": "val4",
"var5": 3.5,
"new_var": "new_val",
"new_var" + CONDA_SELECTOR + "py3k and win": "new_val",
}
new_lines_true = [
'{% set new_var = "new_val" %}\n',
'{% set new_var = "new_val" %} # [py3k and win]\n',
'{% set var1 = "val4" %} # [sel]\n',
"blah\n",
'{% set var2 = "4.5.6" %} # a comment\n',
'{% set var3 = "None" %} # [sel2 and none and osx]\n',
'{% set var4 = "val4" %}\n',
"{% set var5 = 3.5 %}\n",
]
new_lines = _replace_jinja2_vars(lines, jinja2_vars)
assert new_lines == new_lines_true
def test_munge_jinja2_vars():
meta = {
"val": "<{ var }}",
"list": [
"val",
"<{ val_34 }}",
{
"fg": 2,
"str": "valish",
"ab": "<{ val_again }}",
"dict": {"hello": "<{ val_45 }}", "int": 4},
"list_again": [
"hi",
{"hello": "<{ val_12 }}", "int": 5},
"<{ val_56 }}",
],
},
],
}
demunged_meta_true = {
"val": "{{ var }}",
"list": [
"val",
"{{ val_34 }}",
{
"fg": 2,
"str": "valish",
"ab": "{{ val_again }}",
"dict": {"hello": "{{ val_45 }}", "int": 4},
"list_again": [
"hi",
{"hello": "{{ val_12 }}", "int": 5},
"{{ val_56 }}",
],
},
],
}
# dict
demunged_meta = _demunge_jinja2_vars(meta, "<")
assert demunged_meta_true == demunged_meta
redemunged_meta = _remunge_jinja2_vars(demunged_meta, "<")
assert redemunged_meta == meta
# start with list
demunged_meta = _demunge_jinja2_vars(meta["list"], "<")
assert demunged_meta_true["list"] == demunged_meta
redemunged_meta = _remunge_jinja2_vars(demunged_meta, "<")
assert redemunged_meta == meta["list"]
# string only?
demunged_meta = _demunge_jinja2_vars("<{ val }}", "<")
assert "{{ val }}" == demunged_meta
redemunged_meta = _remunge_jinja2_vars(demunged_meta, "<")
assert redemunged_meta == "<{ val }}"
demunged_meta = _demunge_jinja2_vars("<<{ val }}", "<<")
assert "{{ val }}" == demunged_meta
redemunged_meta = _remunge_jinja2_vars(demunged_meta, "<<")
assert redemunged_meta == "<<{ val }}"
# an int
demunged_meta = _demunge_jinja2_vars(5, "<")
assert 5 == demunged_meta
redemunged_meta = _remunge_jinja2_vars(demunged_meta, "<")
assert redemunged_meta == 5
@pytest.mark.parametrize(
"line,correct_line,formatted_line",
[
(" key1: val2\n", " key1: val2\n", None),
("key2: val2\n", "key2: val2\n", None),
(
"key3: val3#[sel3]\n",
"key3" + CONDA_SELECTOR + "sel3: val3\n",
"key3: val3 # [sel3]\n",
),
(
"key4: val4 #[sel4]\n",
"key4" + CONDA_SELECTOR + "sel4: val4 \n",
"key4: val4 # [sel4]\n",
),
("key5: val5 # [sel5]\n", "key5" + CONDA_SELECTOR + "sel5: val5 \n", None),
("blah\n", "blah\n", None),
("# [sel7]\n", "# [sel7]\n", None),
],
)
def test_munge_lines(line, correct_line, formatted_line):
munged_line = _munge_line(line)
assert munged_line == correct_line
unmunged_line = _unmunge_line(munged_line)
if formatted_line is None:
assert unmunged_line == line
else:
assert unmunged_line == formatted_line
assert unmunged_line != line
def test_parse_jinja2_variables():
meta_yaml = """\
{% set var1 = "name" %}
{% set var2 = 0.1 %}
{% set var3 = 5 %}
# comments
gh:
hi:
other: other text
{% set var4 = 'foo' %} # [py3k and win or (hi!)]
{% set var4 = 'foo' %} #[py3k and win]
{% set var4 = 'bar' %}#[win]
{% set var5 = var3 + 10 %}
{% set var7 = var1.replace('n', 'm') %}
"""
jinja2_vars, jinja2_exprs = _parse_jinja2_variables(meta_yaml)
assert jinja2_vars == {
"var1": "name",
"var2": 0.1,
"var3": 5,
"var4__###conda-selector###__py3k and win or (hi!)": "foo",
"var4__###conda-selector###__py3k and win": "foo",
"var4__###conda-selector###__win": "bar",
}
assert jinja2_exprs == {
"var5": "{% set var5 = var3 + 10 %}",
"var7": "{% set var7 = var1.replace('n', 'm') %}",
}
tmpl = _build_jinja2_expr_tmp(jinja2_exprs)
assert (
tmpl
== """\
{% set var5 = var3 + 10 %}
{% set var7 = var1.replace('n', 'm') %}
var5: >-
{{ var5 }}
var7: >-
{{ var7 }}"""
)
def test_recipe_parses_islpy():
meta_yaml_ok = """\
{% set name = "islpy" %}
{% set version = "2020.2.2" %}
{% set sha256 = "7eb7dfa41d6a67d9ee4ea4bb9f08bdbcbee42b364502136b7882cfd80ff427e0" %}
package:
name: {{ name|lower }}
version: {{ version }}
source:
url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/{{ name }}-{{ version }}.tar.gz
sha256: {{ sha256 }}
build:
number: 0
requirements:
build:
- python # [build_platform != target_platform]
- cross-python_{{ target_platform }} # [build_platform != target_platform]
- pybind11 # [build_platform != target_platform]
- {{ compiler('cxx') }}
host:
- python
- setuptools
- six
- pybind11
- isl
run:
- python
- six
# Need the same version of isl we had when the package was built
- {{ pin_compatible("isl", max_pin="x.x.x") }}
test:
requires:
- pytest
imports:
- islpy
source_files:
- test
commands:
- cd test && python -m pytest
about:
home: http://github.com/inducer/islpy
license: MIT
license_file:
- doc/misc.rst
license_family: MIT
summary: Wrapper around isl, an integer set library
description: |
islpy is a Python wrapper around Sven Verdoolaege's
[isl](http://www.kotnet.org/~skimo/isl/), a library for manipulating
sets and relations of integer points bounded by linear constraints.
Supported operations on sets include
- intersection, union, set difference,
- emptiness check,
- convex hull,
- (integer) affine hull,
- integer projection,
- computing the lexicographic minimum using parametric integer
programming,
- coalescing, and
- parametric vertex enumeration.
It also includes an ILP solver based on generalized basis reduction,
transitive closures on maps (which may encode infinite graphs),
dependence analysis and bounds on piecewise step-polynomials.
extra:
recipe-maintainers:
- inducer
""" # noqa
meta_yaml_notok = """\
{% set name = "islpy" %}
{% set version = "2020.2.2" %}
{% set sha256 = "7eb7dfa41d6a67d9ee4ea4bb9f08bdbcbee42b364502136b7882cfd80ff427e0" %}
package:
name: {{ name|lower }}
version: {{ version }}
source:
url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/{{ name }}-{{ version }}.tar.gz
sha256: {{ sha256 }}
build:
number: 0
requirements:
build:
- python # [build_platform != target_platform]
- cross-python_{{ target_platform }} # [build_platform != target_platform]
- pybind11 # [build_platform != target_platform]
- {{ compiler('cxx') }}
host:
- python
- setuptools
- six
- pybind11
- isl
run:
- python
- six
# Need the same version of isl we had when the package was built
- {{ pin_compatible("isl", max_pin="x.x.x") }}
test:
requires:
- pytest
imports:
- islpy
source_files:
- test
commands:
- cd test && python -m pytest
about:
home: http://github.com/inducer/islpy
license: MIT
license_file:
- doc/misc.rst
license_family: MIT
summary: Wrapper around isl, an integer set library
description: |
islpy is a Python wrapper around Sven Verdoolaege's
[isl](http://www.kotnet.org/~skimo/isl/), a library for manipulating
sets and relations of integer points bounded by linear constraints.
Supported operations on sets include
- intersection, union, set difference,
- emptiness check,
- convex hull,
- (integer) affine hull,
- integer projection,
- computing the lexicographic minimum using parametric integer
programming,
- coalescing, and
- parametric vertex enumeration.
It also includes an ILP solver based on generalized basis reduction,
transitive closures on maps (which may encode infinite graphs),
dependence analysis and bounds on piecewise step-polynomials.
extra:
recipe-maintainers:
- inducer
""" # noqa
cm = CondaMetaYAML(meta_yaml_ok)
s = io.StringIO()
cm.dump(s)
s.seek(0)
assert meta_yaml_ok == s.read()
cm = CondaMetaYAML(meta_yaml_notok)
s = io.StringIO()
cm.dump(s)
s.seek(0)
assert meta_yaml_notok != s.read()
def test_recipe_parses_fftw():
recipe = """\
{% set version = "3.3.9" %}
{% set build = 1 %}
# ensure mpi is defined (needed for conda-smithy recipe-lint)
{% set mpi = mpi or 'nompi' %}
package:
name: fftw
version: {{ version }}
source:
fn: fftw-{{ version }}.tar.gz
url: http://www.fftw.org/fftw-{{ version }}.tar.gz
sha256: bf2c7ce40b04ae811af714deb512510cc2c17b9ab9d6ddcf49fe4487eea7af3d
build:
# prioritize nompi variant via build number
{% if mpi == 'nompi' %}
{% set build = build + 100 %}
{% endif %}
number: {{ build }}
# add build string so packages can depend on
# mpi or nompi variants explicitly:
# `pkg * mpi_mpich_*` for mpich
# `pkg * mpi_*` for any mpi
# `pkg * nompi_*` for no mpi
{% if mpi != 'nompi' %}
{% set mpi_prefix = "mpi_" + mpi %}
{% else %}
{% set mpi_prefix = "nompi" %}
{% endif %}
string: "{{ mpi_prefix }}_h{{ PKG_HASH }}_{{ build }}"
run_exports:
- {{ pin_compatible('fftw', max_pin='x') }}
{% if mpi != 'nompi' %}
- fftw * {{ mpi_prefix }}_*
{% endif %}
requirements:
build:
- perl 5.* # [not win]
- cmake # [win]
- {{ compiler('c') }}
- {{ compiler('fortran') }} # [not win]
- llvm-openmp >=4.0.1 # [osx]
- make # [unix]
- autoconf # [unix]
- automake # [unix]
- gettext # [unix]
- m4 # [unix]
- libtool # [unix]
- {{ mpi }} # [build_platform != target_platform and mpi == 'openmpi']
host:
- {{ mpi }} # [mpi != 'nompi']
- llvm-openmp >=4.0.1 # [osx]
run:
- llvm-openmp >=4.0.1 # [osx]
test:
requires:
- python
commands:
# Verify library contains Fortran symbols
- strings ${PREFIX}/lib/libfftw3.a | grep -q dfftw || exit 1 # [not win]
# Verify existence of library files
- test -f ${PREFIX}/lib/libfftw3f.a || exit 1 # [not win]
- test -f ${PREFIX}/lib/libfftw3.a || exit 1 # [not win]
- test -f ${PREFIX}/lib/libfftw3l.a || exit 1 # [not win]
- test -f ${PREFIX}/lib/libfftw3f_threads.a || exit 1 # [not win]
- test -f ${PREFIX}/lib/libfftw3_threads.a || exit 1 # [not win]
- test -f ${PREFIX}/lib/libfftw3l_threads.a || exit 1 # [not win]
- test -f ${PREFIX}/lib/libfftw3f_omp.a || exit 1 # [not win]
- test -f ${PREFIX}/lib/libfftw3_omp.a || exit 1 # [not win]
- test -f ${PREFIX}/lib/libfftw3l_omp.a || exit 1 # [not win]
# Verify headers are installed
- test -f ${PREFIX}/include/fftw3.h || exit 1 # [not win]
- if not exist %LIBRARY_INC%\\fftw3.h exit 1 # [win]
# Verify shared libraries are installed
{% set fftw_libs = [
"libfftw3",
"libfftw3_threads",
"libfftw3f",
"libfftw3f_threads",
"libfftw3l",
"libfftw3l_threads",
] %}
{% set fftw_omp_libs = [
"libfftw3_omp",
"libfftw3f_omp",
"libfftw3l_omp",
] %}
{% set fftw_mpi_libs = [
"libfftw3_mpi",
"libfftw3f_mpi",
"libfftw3l_mpi",
] %}
{% for lib in fftw_libs %}
- python -c "import ctypes; ctypes.cdll[r'${PREFIX}/lib/{{ lib }}${SHLIB_EXT}']" # [unix]
{% endfor %}
{% for lib in fftw_omp_libs %}
- python -c "import ctypes; ctypes.cdll[r'${PREFIX}/lib/{{ lib }}${SHLIB_EXT}']" # [unix]
{% endfor %}
{% if mpi != 'nompi' %}
{% for lib in fftw_mpi_libs %}
# you need to link to the mpi libs to load the dll, so we just test
# if it exists
- test -f ${PREFIX}/lib/{{ lib }}${SHLIB_EXT} || exit 1 # [unix]
{% endfor %}
{% endif %}
{% set fftw_libs = ["fftw3f", "fftw3"] %}
{% for base in fftw_libs %}
- if not exist %LIBRARY_LIB%\\{{ base }}.lib exit 1 # [win]
- if not exist %LIBRARY_BIN%\\{{ base }}.dll exit 1 # [win]
{% endfor %}
about:
home: http://fftw.org
license: GPL-2.0-or-later
license_file: COPYING
summary: "The fastest Fourier transform in the west."
extra:
recipe-maintainers:
- alexbw
- jakirkham
- grlee77
- jschueller
- egpbos
""" # noqa
recipe_parsed = """\
{% set version = "3.3.9" %}
{% set build = 1 %}
# ensure mpi is defined (needed for conda-smithy recipe-lint)
{% set mpi = mpi or 'nompi' %}