@@ -326,6 +326,7 @@ def migrate(self, recipe_dir: str, attrs: "AttrsTypedDict", **kwargs: Any) -> No
326
326
327
327
328
328
class CrossRBaseMigrator (MiniMigrator ):
329
+ allowed_schema_versions = {0 , 1 }
329
330
post_migration = True
330
331
331
332
def filter (self , attrs : "AttrsTypedDict" , not_bad_str_start : str = "" ) -> bool :
@@ -340,7 +341,8 @@ def filter(self, attrs: "AttrsTypedDict", not_bad_str_start: str = "") -> bool:
340
341
341
342
def migrate (self , recipe_dir : str , attrs : "AttrsTypedDict" , ** kwargs : Any ) -> None :
342
343
with pushd (recipe_dir ):
343
- with open ("meta.yaml" ) as fp :
344
+ recipe_file = next (filter (os .path .exists , ("recipe.yaml" , "meta.yaml" )))
345
+ with open (recipe_file ) as fp :
344
346
meta_yaml = fp .readlines ()
345
347
346
348
new_lines = []
@@ -349,10 +351,20 @@ def migrate(self, recipe_dir: str, attrs: "AttrsTypedDict", **kwargs: Any) -> No
349
351
for line in meta_yaml :
350
352
if previous_was_build :
351
353
nspaces = len (line ) - len (line .lstrip ())
352
- new_lines .append (
353
- " " * nspaces
354
- + "- cross-r-base {{ r_base }} # [build_platform != target_platform]\n " ,
355
- )
354
+ if recipe_file == "recipe.yaml" :
355
+ new_lines .extend (
356
+ [
357
+ " " * nspaces
358
+ + "- if: build_platform != target_platform\n " ,
359
+ " " * nspaces + " then:\n " ,
360
+ " " * nspaces + " - cross-r-base ${{ r_base }}\n " ,
361
+ ]
362
+ )
363
+ else :
364
+ new_lines .append (
365
+ " " * nspaces
366
+ + "- cross-r-base {{ r_base }} # [build_platform != target_platform]\n " ,
367
+ )
356
368
# Add host R requirements to build
357
369
host_reqs = attrs .get ("requirements" , {}).get ("host" , set ())
358
370
r_host_reqs = [
@@ -361,15 +373,18 @@ def migrate(self, recipe_dir: str, attrs: "AttrsTypedDict", **kwargs: Any) -> No
361
373
if req .startswith ("r-" ) and req != "r-base"
362
374
]
363
375
for r_req in r_host_reqs :
364
- # Ensure nice formatting
365
- post_nspaces = max (0 , 25 - len (r_req ))
366
- new_lines .append (
367
- " " * nspaces
368
- + "- "
369
- + r_req
370
- + " " * post_nspaces
371
- + " # [build_platform != target_platform]\n " ,
372
- )
376
+ if recipe_file == "recipe.yaml" :
377
+ new_lines .append (" " * nspaces + f" - { r_req } \n " )
378
+ else :
379
+ # Ensure nice formatting
380
+ post_nspaces = max (0 , 25 - len (r_req ))
381
+ new_lines .append (
382
+ " " * nspaces
383
+ + "- "
384
+ + r_req
385
+ + " " * post_nspaces
386
+ + " # [build_platform != target_platform]\n " ,
387
+ )
373
388
in_req = False
374
389
previous_was_build = False
375
390
if "requirements:" in line :
@@ -378,7 +393,7 @@ def migrate(self, recipe_dir: str, attrs: "AttrsTypedDict", **kwargs: Any) -> No
378
393
previous_was_build = True
379
394
new_lines .append (line )
380
395
381
- with open ("meta.yaml" , "w" ) as f :
396
+ with open (recipe_file , "w" ) as f :
382
397
f .write ("" .join (new_lines ))
383
398
384
399
if os .path .exists ("build.sh" ):
0 commit comments