@@ -130,7 +130,6 @@ def split_macros(parsed_versions):
130
130
macros = []
131
131
macro = ""
132
132
in_macro = False
133
- in_comment = False
134
133
for line in parsed_versions :
135
134
if line .startswith ("class vn" ) and not line .startswith (
136
135
"class vnXX_txxx"
@@ -234,6 +233,7 @@ def __init__(self, tag, cname, version, apps, core, jules):
234
233
# copy in LFRic, rather than using the Jules version. The LFRic build
235
234
# system needs modifying to enable this
236
235
# self.jules_source = self.get_dependency_paths(jules, "jules")
236
+ self .central_rose_meta = False
237
237
self .set_rose_meta_path ()
238
238
if version is None :
239
239
self .version = re .search (r".*vn(\d+\.\d+)(_.*)?" , tag ).group (1 )
@@ -255,7 +255,15 @@ def set_rose_meta_path(self):
255
255
When Jules Shared from Jules is enabled, self.jules_source will need
256
256
adding here
257
257
"""
258
- rose_meta_path = f"{ self .root_path } :{ self .core_source } "
258
+ if os .path .isdir (os .path .join (self .root_path , "rose-meta" )):
259
+ # For backwards compatibility with central rose-meta imports
260
+ rose_meta_path = (
261
+ f"{ os .path .join (self .root_path , 'rose-meta' )} :"
262
+ f"{ os .path .join (self .core_source , 'rose-meta' )} "
263
+ )
264
+ self .central_rose_meta = True
265
+ else :
266
+ rose_meta_path = f"{ self .root_path } :{ self .core_source } "
259
267
os .environ ["ROSE_META_PATH" ] = rose_meta_path
260
268
261
269
def parse_application_section (self , meta_dir ):
@@ -396,7 +404,7 @@ def find_meta_dirs(self, path):
396
404
- str, stdout of find command looking for versions.py files
397
405
"""
398
406
399
- for dirpath , dirnames , filenames in os .walk (path ):
407
+ for dirpath , dirnames , filenames in os .walk (path , followlinks = True ):
400
408
dirnames [:] = [d for d in dirnames if d not in [".svn" ]]
401
409
if "versions.py" in filenames :
402
410
self .meta_dirs .add (dirpath )
@@ -570,23 +578,23 @@ def get_full_import_path(self, imp):
570
578
not found
571
579
"""
572
580
573
- core_imp = os .path .join (self .core_source , imp )
574
- if os .path .exists (core_imp ) or os .path .exists (
575
- os .path .dirname (core_imp )
576
- ):
577
- return core_imp
581
+ # TODO: Reinstate Jules checks when using Jules Metadata from Jules
578
582
579
- # Reinstate when using Jules Shared from Jules
580
- # jules_imp = os.path.join(self.jules_source, imp)
581
- # if os.path.exists(jules_imp) or os.path.exists(
582
- # os.path.dirname(jules_imp)
583
- # ):
584
- # return jules_imp
585
-
586
- apps_imp = os .path .join (self .root_path , imp )
587
- if os .path .exists (apps_imp ) or os .path .exists (
588
- os .path .dirname (apps_imp )
589
- ):
583
+ # For backwards compatibility with central rose-meta imports
584
+ if self .central_rose_meta :
585
+ core_imp = os .path .join (self .core_source , "rose-meta" , imp )
586
+ apps_imp = os .path .join (self .root_path , "rose-meta" , imp )
587
+ else :
588
+ core_imp = os .path .join (self .core_source , imp )
589
+ apps_imp = os .path .join (self .root_path , imp )
590
+
591
+ if os .path .exists (core_imp ):
592
+ return core_imp
593
+ if os .path .exists (apps_imp ):
594
+ return apps_imp
595
+ if os .path .exists (os .path .dirname (core_imp )):
596
+ return core_imp
597
+ if os .path .exists (os .path .dirname (apps_imp )):
590
598
return apps_imp
591
599
592
600
raise Exception (
@@ -684,7 +692,14 @@ def determine_import_order(self, app):
684
692
- A list of meta imports in the correct order
685
693
"""
686
694
687
- import_list = [app ]
695
+ # If using central metadata, use the basename, otherwise the full path
696
+ if self .central_rose_meta :
697
+ app_name = os .path .basename (app )
698
+ else :
699
+ app_name = app
700
+
701
+ import_list = [app_name ]
702
+
688
703
try :
689
704
imports = self .parsed_macros [app ]["imports" ]
690
705
except KeyError :
@@ -709,6 +724,7 @@ def combine_macros(self, import_order):
709
724
710
725
full_command = ""
711
726
for meta_import in import_order :
727
+ meta_import = self .get_full_import_path (meta_import )
712
728
if (
713
729
meta_import in self .parsed_macros
714
730
and self .parsed_macros [meta_import ]["commands" ]
@@ -758,7 +774,7 @@ def write_new_macro(self, meta_dir, full_command):
758
774
759
775
def preprocess_macros (self ):
760
776
"""
761
- Overraching function to pre-process added macros
777
+ Overarching function to pre-process added macros
762
778
Run before running any rose macro upgrade commands"
763
779
Search through versions.py files for macros with the correct after-tag
764
780
Save info and then delete the macro when found
@@ -768,8 +784,13 @@ def preprocess_macros(self):
768
784
"""
769
785
770
786
# Get list of versions files to check - in both core and apps
771
- self .find_meta_dirs (self .root_path )
772
- self .find_meta_dirs (self .core_source )
787
+ # Duplicated for backwards compatibility with central rose-meta imports
788
+ if self .central_rose_meta :
789
+ self .find_meta_dirs (os .path .join (self .root_path , "rose-meta" ))
790
+ self .find_meta_dirs (os .path .join (self .core_source , "rose-meta" ))
791
+ else :
792
+ self .find_meta_dirs (self .root_path )
793
+ self .find_meta_dirs (self .core_source )
773
794
774
795
for meta_dir in self .meta_dirs :
775
796
print (
0 commit comments