@@ -143,40 +143,6 @@ def literal_unicode_representer(dumper, data):
143
143
parsed_args = None
144
144
145
145
146
- def parse_command_line (argv ):
147
- parser = argparse .ArgumentParser (
148
- description = "Conda recipe Azure pipeline generator for ROS packages"
149
- )
150
-
151
- default_dir = "./recipes"
152
- parser .add_argument (
153
- "-d" ,
154
- "--dir" ,
155
- dest = "dir" ,
156
- default = default_dir ,
157
- help = "The recipes directory to process (default: {})." .format (default_dir ),
158
- )
159
-
160
- parser .add_argument (
161
- "-t" , "--trigger-branch" , dest = "trigger_branch" , help = "Trigger branch for Azure"
162
- )
163
-
164
- parser .add_argument (
165
- "-p" ,
166
- "--platform" ,
167
- dest = "platform" ,
168
- default = "linux-64" ,
169
- help = "Platform to emit build pipeline for" ,
170
- )
171
-
172
- parser .add_argument (
173
- "-a" , "--additional-recipes" , action = "store_true" , help = "search for additional_recipes folder?" )
174
-
175
- arguments = parser .parse_args (argv [1 :])
176
- global parsed_args
177
- parsed_args = arguments
178
- return arguments
179
-
180
146
181
147
def normalize_name (s ):
182
148
s = s .replace ("-" , "_" )
@@ -197,6 +163,7 @@ def chunks(lst, n):
197
163
"""Yield successive n-sized chunks from lst."""
198
164
for i in range (0 , len (lst ), n ):
199
165
yield lst [i :i + n ]
166
+
200
167
i = 0
201
168
while i < len (stages ):
202
169
for build_individually_pkg in build_individually :
@@ -247,8 +214,8 @@ def get_skip_existing(vinca_conf, platform):
247
214
248
215
return repodatas
249
216
250
- def add_additional_recipes (args ):
251
- additional_recipes_path = os .path .abspath (os .path .join (args . dir , '..' , 'additional_recipes' ))
217
+ def add_additional_recipes (recipe_dir , platform ):
218
+ additional_recipes_path = os .path .abspath (os .path .join (recipe_dir , '..' , 'additional_recipes' ))
252
219
253
220
print ("Searching additional recipes in " , additional_recipes_path )
254
221
@@ -258,7 +225,10 @@ def add_additional_recipes(args):
258
225
with open ("vinca.yaml" , "r" ) as vinca_yaml :
259
226
vinca_conf = yaml .safe_load (vinca_yaml )
260
227
261
- repodatas = get_skip_existing (vinca_conf , args .platform )
228
+ if vinca_conf .get ("is_migration" ):
229
+ return
230
+
231
+ repodatas = get_skip_existing (vinca_conf , platform )
262
232
263
233
for recipe_path in glob .glob (additional_recipes_path + '/**/recipe.yaml' ):
264
234
with open (recipe_path ) as recipe :
@@ -276,7 +246,7 @@ def add_additional_recipes(args):
276
246
277
247
if not skip :
278
248
print ("Adding " , os .path .dirname (recipe_path ))
279
- goal_folder = os .path .join (args . dir , name )
249
+ goal_folder = os .path .join (recipe_dir , name )
280
250
os .makedirs (goal_folder , exist_ok = True )
281
251
copy_tree (os .path .dirname (recipe_path ), goal_folder )
282
252
@@ -521,7 +491,7 @@ def build_osx_arm64(stages, trigger_branch):
521
491
fo .write (yaml .dump (azure_template , sort_keys = False ))
522
492
523
493
524
- def extend_graph (graph , arch = 'linux-64' ):
494
+ def extend_graph (graph , arch = 'linux-64' , distro = 'noetic' ):
525
495
url = f"https://conda.anaconda.org/robostack/{ arch } /repodata.json"
526
496
repodata = requests .get (url ).json ()
527
497
@@ -567,19 +537,9 @@ def extend_graph(graph, arch='linux-64'):
567
537
if req .startswith (ros_prefix ):
568
538
graph .add_edge (pkg , req )
569
539
570
- def main ():
571
-
572
- args = parse_command_line (sys .argv )
573
-
540
+ def generate_pipeline (recipe_dir , platform , trigger_branch , sequential = False ):
574
541
metas = []
575
-
576
- if args .additional_recipes :
577
- add_additional_recipes (args )
578
-
579
- if not os .path .exists (args .dir ):
580
- print (f"{ args .dir } not found. Not generating a pipeline." )
581
-
582
- all_recipes = glob .glob (os .path .join (args .dir , "**" , "*.yaml" ))
542
+ all_recipes = glob .glob (os .path .join (recipe_dir , "**" , "*.yaml" ))
583
543
for f in all_recipes :
584
544
with open (f ) as fi :
585
545
metas .append (yaml .safe_load (fi .read ()))
@@ -601,7 +561,7 @@ def main():
601
561
if r .startswith ("ros-" ):
602
562
G .add_edge (pkg , r )
603
563
604
- extend_graph (G , arch = args . platform )
564
+ extend_graph (G , arch = platform )
605
565
# import matplotlib.pyplot as plt
606
566
# nx.draw(G, with_labels=True, font_weight='bold')
607
567
# plt.show()
@@ -656,16 +616,77 @@ def main():
656
616
if len (filtered ):
657
617
filtered_stages .append (filtered )
658
618
659
- stages = batch_stages (filtered_stages )
660
- print (stages )
661
-
662
- if args .platform == "linux-64" :
663
- build_linux (stages , args .trigger_branch )
664
- elif args .platform == "linux-aarch64" :
665
- build_linux_aarch64 (stages , args .trigger_branch )
666
- elif args .platform == "osx-64" :
667
- build_osx (stages , args .trigger_branch )
668
- elif args .platform == "osx-arm64" :
669
- build_osx_arm64 (stages , args .trigger_branch )
670
- elif args .platform == "win-64" :
671
- build_win (stages , args .trigger_branch )
619
+ if sequential :
620
+ single_stage = []
621
+ for s in filtered_stages :
622
+ single_stage .extend (s )
623
+ stages = [[single_stage ]]
624
+ else :
625
+ stages = batch_stages (filtered_stages )
626
+
627
+ if platform == "linux-64" :
628
+ build_linux (stages , trigger_branch )
629
+ elif platform == "linux-aarch64" :
630
+ build_linux_aarch64 (stages , trigger_branch )
631
+ elif platform == "osx-64" :
632
+ build_osx (stages , trigger_branch )
633
+ elif platform == "osx-arm64" :
634
+ build_osx_arm64 (stages , trigger_branch )
635
+ elif platform == "win-64" :
636
+ build_win (stages , trigger_branch )
637
+
638
+
639
+ def parse_command_line (argv ):
640
+ parser = argparse .ArgumentParser (
641
+ description = "Conda recipe Azure pipeline generator for ROS packages"
642
+ )
643
+
644
+ default_dir = "./recipes"
645
+ parser .add_argument (
646
+ "-d" ,
647
+ "--dir" ,
648
+ dest = "dir" ,
649
+ default = default_dir ,
650
+ help = "The recipes directory to process (default: {})." .format (default_dir ),
651
+ )
652
+ parser .add_argument (
653
+ "--sequential" ,
654
+ dest = "sequential" ,
655
+ action = "store_true" ,
656
+ help = "Don't parallelize stages" ,
657
+ )
658
+ parser .add_argument (
659
+ "-t" , "--trigger-branch" , dest = "trigger_branch" , help = "Trigger branch for Azure"
660
+ )
661
+
662
+ parser .add_argument (
663
+ "-p" ,
664
+ "--platform" ,
665
+ dest = "platform" ,
666
+ default = "linux-64" ,
667
+ help = "Platform to emit build pipeline for" ,
668
+ )
669
+
670
+ parser .add_argument (
671
+ "-a" , "--additional-recipes" , action = "store_true" , help = "search for additional_recipes folder?" )
672
+
673
+ arguments = parser .parse_args (argv [1 :])
674
+ global parsed_args
675
+ parsed_args = arguments
676
+ return arguments
677
+
678
+
679
+ def main ():
680
+
681
+ args = parse_command_line (sys .argv )
682
+
683
+ metas = []
684
+
685
+ if not os .path .exists (args .dir ):
686
+ print (f"{ args .dir } not found. Not generating a pipeline." )
687
+ return
688
+
689
+ if args .additional_recipes :
690
+ add_additional_recipes (args .dir , args .platform )
691
+
692
+ generate_pipeline (args .dir , args .platform , args .trigger_branch , args .sequential )
0 commit comments