1010import numpy as np
1111import timing
1212
13- from transpyle .general .code_reader import CodeReader
14- from transpyle .general .binder import Binder
15- from transpyle .fortran .parser import FortranParser
16- from transpyle .fortran .ast_generalizer import FortranAstGeneralizer
17- from transpyle .fortran .unparser import Fortran77Unparser
18- from transpyle .fortran .compiler import F2PyCompiler
19- from transpyle .fortran .compiler_interface import GfortranInterface , PgifortranInterface
13+ from transpyle .general import AstGeneralizer , Binder , CodeReader , Compiler , Parser , Unparser
14+ try :
15+ from transpyle .fortran .parser import FortranParser
16+ except ImportError :
17+ pass
18+ try :
19+ from transpyle .fortran .ast_generalizer import FortranAstGeneralizer
20+ except ImportError :
21+ pass
22+ try :
23+ from transpyle .fortran .unparser import Fortran77Unparser
24+ except ImportError :
25+ pass
26+ try :
27+ from transpyle .fortran .compiler import F2PyCompiler
28+ except ImportError :
29+ pass
30+ try :
31+ from transpyle .fortran .compiler_interface import GfortranInterface , PgifortranInterface
32+ except ImportError :
33+ pass
2034
2135from .common import \
2236 random_data , EXAMPLES_ROOT , EXAMPLES_ROOTS , PERFORMANCE_RESULTS_ROOT , \
3246MB = 1024 * KB
3347
3448
49+ @unittest .skipIf (Parser .find ('Fortran' ) is None , 'skipping due to missing Fortran language support' )
3550class ParserTests (unittest .TestCase ):
3651
3752 @execute_on_language_examples ('f77' , 'f95' )
@@ -51,6 +66,8 @@ def test_try_parse_invalid(self):
5166 _LOG .debug ('%s' , err .exception )
5267
5368
69+ @unittest .skipIf (
70+ AstGeneralizer .find ('Fortran' ) is None , 'skipping due to missing Fortran language support' )
5471class AstGeneralizerTests (unittest .TestCase ):
5572
5673 @execute_on_language_examples ('f77' , 'f95' )
@@ -65,6 +82,8 @@ def test_generalize_examples(self, input_path):
6582 _LOG .info ('generalized "%s" in %fs' , input_path , timer .elapsed )
6683
6784
85+ @unittest .skipIf (
86+ Unparser .find ('Fortran' ) is None , 'skipping due to missing Fortran language support' )
6887class UnparserTests (unittest .TestCase ):
6988
7089 @execute_on_language_fundamentals ('f77' , 'f95' )
@@ -82,6 +101,8 @@ def test_unparse_fundamentals(self, input_path):
82101 _LOG .info ('unparsed "%s" in %fs' , input_path , timer .elapsed )
83102
84103
104+ @unittest .skipIf (
105+ Compiler .find ('Fortran' ) is None , 'skipping due to missing Fortran language support' )
85106class CompilerTests (unittest .TestCase ):
86107
87108 @execute_on_language_examples ('f77' , 'f95' , predicate_not = accelerated )
0 commit comments