sci-fab 2.0__tar.gz → 2.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. sci_fab-2.2.0/CODE_OF_CONDUCT.md +4 -0
  2. sci_fab-2.0/LICENSE → sci_fab-2.2.0/LICENCE +1 -1
  3. {sci_fab-2.0 → sci_fab-2.2.0}/PKG-INFO +17 -38
  4. sci_fab-2.0/README.md → sci_fab-2.2.0/README.rst +15 -6
  5. {sci_fab-2.0 → sci_fab-2.2.0}/pyproject.toml +5 -5
  6. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/__init__.py +1 -1
  7. sci_fab-2.2.0/source/fab/api.py +95 -0
  8. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/artefacts.py +14 -14
  9. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/build_config.py +23 -55
  10. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/cli.py +19 -13
  11. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/cui/__main__.py +3 -3
  12. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/dep_tree.py +69 -37
  13. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/fab_base/fab_base.py +102 -47
  14. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/fab_base/site_specific/default/config.py +55 -49
  15. sci_fab-2.0/source/fab/fab_base/site_specific/default/setup_cray.py → sci_fab-2.2.0/source/fab/fab_base/site_specific/default/setup_script_cray.py +11 -8
  16. sci_fab-2.0/source/fab/fab_base/site_specific/default/setup_gnu.py → sci_fab-2.2.0/source/fab/fab_base/site_specific/default/setup_script_gnu.py +13 -8
  17. sci_fab-2.0/source/fab/fab_base/site_specific/default/setup_intel_classic.py → sci_fab-2.2.0/source/fab/fab_base/site_specific/default/setup_script_intel_classic.py +12 -9
  18. sci_fab-2.0/source/fab/fab_base/site_specific/default/setup_intel_llvm.py → sci_fab-2.2.0/source/fab/fab_base/site_specific/default/setup_script_intel_llvm.py +12 -9
  19. sci_fab-2.0/source/fab/fab_base/site_specific/default/setup_nvidia.py → sci_fab-2.2.0/source/fab/fab_base/site_specific/default/setup_script_nvidia.py +11 -8
  20. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/metrics.py +2 -2
  21. sci_fab-2.2.0/source/fab/mo.py +60 -0
  22. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/parse/__init__.py +4 -4
  23. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/parse/c.py +11 -5
  24. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/parse/fortran.py +90 -39
  25. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/parse/fortran_common.py +10 -6
  26. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/parse/x90.py +20 -10
  27. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/steps/analyse.py +37 -34
  28. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/steps/archive_objects.py +3 -2
  29. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/steps/c_pragma_injector.py +22 -9
  30. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/steps/cleanup_prebuilds.py +3 -3
  31. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/steps/compile_c.py +23 -19
  32. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/steps/compile_fortran.py +57 -48
  33. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/steps/find_source_files.py +67 -29
  34. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/steps/grab/fcm.py +1 -1
  35. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/steps/grab/folder.py +2 -2
  36. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/steps/grab/git.py +3 -3
  37. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/steps/grab/prebuild.py +2 -2
  38. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/steps/grab/svn.py +8 -7
  39. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/steps/link.py +7 -6
  40. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/steps/preprocess.py +24 -22
  41. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/steps/psyclone.py +61 -109
  42. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/steps/root_inc_files.py +28 -27
  43. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/target/zero.py +3 -1
  44. sci_fab-2.2.0/source/fab/tools/__init__.py +5 -0
  45. sci_fab-2.2.0/source/fab/tools/abstract_tool_box.py +60 -0
  46. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/tools/ar.py +5 -3
  47. sci_fab-2.2.0/source/fab/tools/category.py +139 -0
  48. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/tools/compiler.py +148 -128
  49. sci_fab-2.2.0/source/fab/tools/compiler_suite_tool.py +50 -0
  50. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/tools/compiler_wrapper.py +37 -21
  51. sci_fab-2.2.0/source/fab/tools/flags.py +583 -0
  52. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/tools/linker.py +46 -32
  53. sci_fab-2.2.0/source/fab/tools/pfunit.py +73 -0
  54. sci_fab-2.2.0/source/fab/tools/pkg_config.py +42 -0
  55. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/tools/preprocessor.py +23 -7
  56. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/tools/psyclone.py +20 -13
  57. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/tools/rsync.py +4 -2
  58. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/tools/shell.py +6 -3
  59. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/tools/tool.py +8 -58
  60. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/tools/tool_box.py +5 -11
  61. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/tools/tool_repository.py +14 -6
  62. sci_fab-2.2.0/source/fab/tools/tool_with_flags.py +124 -0
  63. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/tools/versioning.py +16 -9
  64. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/util.py +4 -4
  65. {sci_fab-2.0 → sci_fab-2.2.0}/source/sci_fab.egg-info/PKG-INFO +17 -38
  66. {sci_fab-2.0 → sci_fab-2.2.0}/source/sci_fab.egg-info/SOURCES.txt +13 -7
  67. sci_fab-2.0/CODE_OF_CONDUCT.md +0 -3
  68. sci_fab-2.0/source/fab/mo.py +0 -38
  69. sci_fab-2.0/source/fab/tools/__init__.py +0 -67
  70. sci_fab-2.0/source/fab/tools/category.py +0 -39
  71. sci_fab-2.0/source/fab/tools/flags.py +0 -227
  72. {sci_fab-2.0 → sci_fab-2.2.0}/COPYRIGHT +0 -0
  73. {sci_fab-2.0 → sci_fab-2.2.0}/MANIFEST.in +0 -0
  74. {sci_fab-2.0 → sci_fab-2.2.0}/setup.cfg +0 -0
  75. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/constants.py +0 -0
  76. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/cui/arguments.py +0 -0
  77. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/fab_base/__init__.py +0 -0
  78. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/fab_base/site_specific/__init__.py +0 -0
  79. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/fab_base/site_specific/default/__init__.py +0 -0
  80. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/logtools.py +0 -0
  81. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/steps/__init__.py +0 -0
  82. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/steps/grab/__init__.py +0 -0
  83. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/steps/grab/archive.py +0 -0
  84. {sci_fab-2.0 → sci_fab-2.2.0}/source/fab/target/base.py +0 -0
  85. {sci_fab-2.0 → sci_fab-2.2.0}/source/sci_fab.egg-info/dependency_links.txt +0 -0
  86. {sci_fab-2.0 → sci_fab-2.2.0}/source/sci_fab.egg-info/entry_points.txt +0 -0
  87. {sci_fab-2.0 → sci_fab-2.2.0}/source/sci_fab.egg-info/requires.txt +0 -0
  88. {sci_fab-2.0 → sci_fab-2.2.0}/source/sci_fab.egg-info/top_level.txt +0 -0
@@ -0,0 +1,4 @@
1
+ # Code of Conduct
2
+
3
+ All contributors to Fab must follow the
4
+ [Met Office Simulation Systems Code of Conduct](https://metoffice.github.io/simulation-systems/FurtherDetails/code_of_conduct).
@@ -1,4 +1,4 @@
1
- BSD 3-Clause License
1
+ BSD 3-Clause Licence
2
2
 
3
3
  Copyright (c) 2019, Met Office Modelling Infrastructure Support Systems
4
4
  All rights reserved.
@@ -1,38 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sci-fab
3
- Version: 2.0
3
+ Version: 2.2.0
4
4
  Summary: Build system for scientific software
5
5
  Author-email: Core Capabilities Development Team <CoreCapabilityDevelopmentTeam@metoffice.gov.uk>
6
- License: BSD 3-Clause License
7
-
8
- Copyright (c) 2019, Met Office Modelling Infrastructure Support Systems
9
- All rights reserved.
10
-
11
- Redistribution and use in source and binary forms, with or without
12
- modification, are permitted provided that the following conditions are met:
13
-
14
- 1. Redistributions of source code must retain the above copyright notice, this
15
- list of conditions and the following disclaimer.
16
-
17
- 2. Redistributions in binary form must reproduce the above copyright notice,
18
- this list of conditions and the following disclaimer in the documentation
19
- and/or other materials provided with the distribution.
20
-
21
- 3. Neither the name of the copyright holder nor the names of its
22
- contributors may be used to endorse or promote products derived from
23
- this software without specific prior written permission.
24
-
25
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
29
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35
-
36
6
  Project-URL: homepage, https://github.com/MetOffice/fab
37
7
  Project-URL: documentation, https://MetOffice.github.io/fab
38
8
  Project-URL: repository, https://github.com/MetOffice/fab
@@ -46,7 +16,7 @@ Classifier: Topic :: Scientific/Engineering
46
16
  Classifier: Topic :: Software Development :: Build Tools
47
17
  Requires-Python: <4,>=3.9
48
18
  Description-Content-Type: text/x-rst
49
- License-File: LICENSE
19
+ License-File: LICENCE
50
20
  Requires-Dist: fparser>=0.2
51
21
  Provides-Extra: c-language
52
22
  Requires-Dist: libclang; extra == "c-language"
@@ -68,10 +38,16 @@ Requires-Dist: flake8>=5.0.4; extra == "dev"
68
38
  Requires-Dist: mypy; extra == "dev"
69
39
  Dynamic: license-file
70
40
 
71
- # Fab - A Build System for Tomorrow
41
+ Fab - A Build System for Tomorrow
42
+ =================================
72
43
 
73
- [![Build](https://github.com/MetOffice/fab/actions/workflows/build.yml/badge.svg)](https://github.com/MetOffice/fab/actions/workflows/build.yml)
74
- [![Build Documentation](https://github.com/MetOffice/fab/actions/workflows/documentation.yml/badge.svg)](https://github.com/MetOffice/fab/actions/workflows/documentation.yml)
44
+ .. image:: https://github.com/MetOffice/fab/actions/workflows/build.yml/badge.svg
45
+ :target: https://github.com/MetOffice/fab/actions/workflows/build.yml
46
+ :alt: testing
47
+
48
+ .. image:: https://github.com/MetOffice/fab/actions/workflows/documentation.yml/badge.svg
49
+ :target: https://github.com/MetOffice/fab/actions/workflows/documentation.yml
50
+ :alt: documentation
75
51
 
76
52
  The "Fab" project aims to provide the means to quickly and easily compile
77
53
  software in a way tailored for scientific software development. It aims to be
@@ -83,15 +59,18 @@ application software. It targets different problems to, for instance, CMake
83
59
  derived build systems. This means that if your usage falls outside the focus
84
60
  of development you shouldn't expect high priority on your feature requests.
85
61
 
86
- ## Licence
62
+ Licence
63
+ ~~~~~~~
87
64
 
88
65
  The software is made available under a 3-clause BSD licence.
89
66
 
90
- ## Installation
67
+ Installation
68
+ ~~~~~~~~~~~~
91
69
 
92
70
  The tool is easily installed using `pip install sci-fab`.
93
71
 
94
- ## Usage
72
+ Usage
73
+ ~~~~~
95
74
 
96
75
  Fab offers two modes of operation. In "zero configuration" mode it is used
97
76
  directly as a tool by running `fab`. This examines the currently selected
@@ -1,7 +1,13 @@
1
- # Fab - A Build System for Tomorrow
1
+ Fab - A Build System for Tomorrow
2
+ =================================
2
3
 
3
- [![Build](https://github.com/MetOffice/fab/actions/workflows/build.yml/badge.svg)](https://github.com/MetOffice/fab/actions/workflows/build.yml)
4
- [![Build Documentation](https://github.com/MetOffice/fab/actions/workflows/documentation.yml/badge.svg)](https://github.com/MetOffice/fab/actions/workflows/documentation.yml)
4
+ .. image:: https://github.com/MetOffice/fab/actions/workflows/build.yml/badge.svg
5
+ :target: https://github.com/MetOffice/fab/actions/workflows/build.yml
6
+ :alt: testing
7
+
8
+ .. image:: https://github.com/MetOffice/fab/actions/workflows/documentation.yml/badge.svg
9
+ :target: https://github.com/MetOffice/fab/actions/workflows/documentation.yml
10
+ :alt: documentation
5
11
 
6
12
  The "Fab" project aims to provide the means to quickly and easily compile
7
13
  software in a way tailored for scientific software development. It aims to be
@@ -13,15 +19,18 @@ application software. It targets different problems to, for instance, CMake
13
19
  derived build systems. This means that if your usage falls outside the focus
14
20
  of development you shouldn't expect high priority on your feature requests.
15
21
 
16
- ## Licence
22
+ Licence
23
+ ~~~~~~~
17
24
 
18
25
  The software is made available under a 3-clause BSD licence.
19
26
 
20
- ## Installation
27
+ Installation
28
+ ~~~~~~~~~~~~
21
29
 
22
30
  The tool is easily installed using `pip install sci-fab`.
23
31
 
24
- ## Usage
32
+ Usage
33
+ ~~~~~
25
34
 
26
35
  Fab offers two modes of operation. In "zero configuration" mode it is used
27
36
  directly as a tool by running `fab`. This examines the currently selected
@@ -1,3 +1,7 @@
1
+ [build-system]
2
+ requires = ['setuptools']
3
+ build-backend = 'setuptools.build_meta'
4
+
1
5
  [project]
2
6
  name = "sci-fab"
3
7
  description = "Build system for scientific software"
@@ -51,13 +55,9 @@ repository = 'https://github.com/MetOffice/fab'
51
55
  where = ['source']
52
56
 
53
57
  [tool.setuptools.dynamic]
54
- readme = {file = 'README.md'}
58
+ readme = {file = 'README.rst', content-type = "text/x-rst"}
55
59
  version = {attr = 'fab.__version__'}
56
60
 
57
- [build-system]
58
- requires = ['setuptools']
59
- build-backend = 'setuptools.build_meta'
60
-
61
61
  # This is required so that pytest finds conftest.py files.
62
62
  [tool.pytest.ini_options]
63
63
  testpaths = [
@@ -10,7 +10,7 @@ Flexible build system for scientific software.
10
10
  import logging
11
11
  import sys
12
12
 
13
- __version__ = '2.0'
13
+ __version__ = '2.2.0'
14
14
 
15
15
  logger = logging.getLogger(__name__)
16
16
  logger.addHandler(logging.StreamHandler(sys.stdout))
@@ -0,0 +1,95 @@
1
+ """
2
+ This module allows any application to import all required
3
+ functions from fab to be imported independent of the location of the
4
+ files using `from fab.api import ...`.
5
+ """
6
+
7
+ # TODO #518: allow versioned APIs, and make this file point to the
8
+ # current default API version.
9
+
10
+ from fab.artefacts import ArtefactSet, CollectionGetter
11
+ from fab.artefacts import SuffixFilter
12
+ from fab.build_config import AddFlags, BuildConfig
13
+ from fab.fab_base.fab_base import FabBase
14
+ from fab.steps import run_mp
15
+ from fab.steps import step
16
+ from fab.steps.analyse import analyse
17
+ from fab.steps.archive_objects import archive_objects
18
+ from fab.steps.c_pragma_injector import c_pragma_injector
19
+ from fab.steps.cleanup_prebuilds import cleanup_prebuilds
20
+ from fab.steps.compile_c import compile_c
21
+ from fab.steps.compile_fortran import compile_fortran
22
+ from fab.steps.find_source_files import Exclude, find_source_files, Include
23
+ from fab.steps.grab.fcm import fcm_export
24
+ from fab.steps.grab.folder import grab_folder
25
+ from fab.steps.grab.git import git_checkout
26
+ from fab.steps.grab.prebuild import grab_pre_build
27
+ from fab.steps.link import link_exe, link_shared_object
28
+ from fab.steps.preprocess import preprocess_c, preprocess_fortran
29
+ from fab.steps.psyclone import preprocess_x90, psyclone
30
+ from fab.steps.root_inc_files import root_inc_files
31
+ from fab.tools.category import Category
32
+ from fab.tools.compiler import Compiler, Ifort
33
+ from fab.tools.compiler_wrapper import CompilerWrapper
34
+ from fab.tools.flags import AlwaysFlags, ContainFlags, FlagList, MatchFlags
35
+ from fab.tools.linker import Linker
36
+ from fab.tools.pkg_config import PkgConfig
37
+ from fab.tools.tool import Tool
38
+ from fab.tools.tool_box import ToolBox
39
+ from fab.tools.tool_repository import ToolRepository
40
+ from fab.tools.shell import Shell
41
+ from fab.util import common_arg_parser
42
+ from fab.util import file_checksum, log_or_dot, TimerLogger
43
+ from fab.util import get_fab_workspace
44
+ from fab.util import input_to_output_fpath
45
+
46
+ __all__ = [
47
+ "AddFlags",
48
+ "AlwaysFlags",
49
+ "analyse",
50
+ "archive_objects",
51
+ "ArtefactSet",
52
+ "BuildConfig",
53
+ "Category",
54
+ "cleanup_prebuilds",
55
+ "CollectionGetter",
56
+ "common_arg_parser",
57
+ "Compiler",
58
+ "CompilerWrapper",
59
+ "compile_c",
60
+ "compile_fortran",
61
+ "ContainFlags",
62
+ "c_pragma_injector",
63
+ "Exclude",
64
+ "FabBase",
65
+ "fcm_export",
66
+ "file_checksum",
67
+ "FlagList",
68
+ "get_fab_workspace",
69
+ "git_checkout",
70
+ "grab_folder",
71
+ "grab_pre_build",
72
+ "find_source_files",
73
+ "Ifort",
74
+ "Include",
75
+ "input_to_output_fpath",
76
+ "Linker",
77
+ "link_exe",
78
+ "link_shared_object",
79
+ "log_or_dot",
80
+ "MatchFlags",
81
+ "PkgConfig",
82
+ "preprocess_c",
83
+ "preprocess_fortran",
84
+ "preprocess_x90",
85
+ "psyclone",
86
+ "root_inc_files",
87
+ "run_mp",
88
+ "Shell",
89
+ "step",
90
+ "SuffixFilter",
91
+ "TimerLogger",
92
+ "Tool",
93
+ "ToolBox",
94
+ "ToolRepository",
95
+ ]
@@ -18,7 +18,7 @@ from abc import ABC, abstractmethod
18
18
  from collections import defaultdict
19
19
  from enum import auto, Enum
20
20
  from pathlib import Path
21
- from typing import Dict, Iterable, List, Optional, Union
21
+ from typing import Iterable, Optional, Union
22
22
 
23
23
  from fab.dep_tree import filter_source_tree, AnalysedDependent
24
24
  from fab.util import suffix_filter
@@ -27,12 +27,12 @@ from fab.util import suffix_filter
27
27
  class ArtefactSet(Enum):
28
28
  '''A simple enum with the artefact types used internally in Fab.
29
29
  '''
30
- INITIAL_SOURCE = auto()
30
+ INITIAL_SOURCE_FILES = auto()
31
31
  PREPROCESSED_FORTRAN = auto()
32
32
  PREPROCESSED_C = auto()
33
- FORTRAN_BUILD_FILES = auto()
34
- C_BUILD_FILES = auto()
35
- X90_BUILD_FILES = auto()
33
+ FORTRAN_COMPILER_FILES = auto()
34
+ C_COMPILER_FILES = auto()
35
+ X90_COMPILER_FILES = auto()
36
36
  CURRENT_PREBUILDS = auto()
37
37
  PRAGMAD_C = auto()
38
38
  BUILD_TREES = auto()
@@ -98,7 +98,7 @@ class ArtefactStore(dict):
98
98
 
99
99
  def copy_artefacts(self, source: Union[str, ArtefactSet],
100
100
  dest: Union[str, ArtefactSet],
101
- suffixes: Optional[Union[str, List[str]]] = None):
101
+ suffixes: Optional[Union[str, list[str]]] = None):
102
102
  '''Copies all artefacts from `source` to `destination`. If a
103
103
  suffix_fiter is specified, only files with the given suffix
104
104
  will be copied.
@@ -115,8 +115,8 @@ class ArtefactStore(dict):
115
115
  self.add(dest, self[source])
116
116
 
117
117
  def replace(self, artefact: Union[str, ArtefactSet],
118
- remove_files: List[Union[str, Path]],
119
- add_files: Union[List[Union[str, Path]], dict]):
118
+ remove_files: list[Union[str, Path]],
119
+ add_files: Union[list[Union[str, Path]], dict]):
120
120
  '''Replaces artefacts in one artefact set with other artefacts. This
121
121
  can be used e.g to replace files that have been preprocessed
122
122
  and renamed. There is no requirement for these lists to have the
@@ -190,7 +190,7 @@ class CollectionConcat(ArtefactsGetter):
190
190
  DEFAULT_SOURCE_GETTER = CollectionConcat([
191
191
  'preprocessed_c',
192
192
  'preprocessed_fortran',
193
- SuffixFilter(ArtefactSet.INITIAL_SOURCE, '.f90'),
193
+ SuffixFilter(ArtefactSet.INITIAL_SOURCE_FILES, '.f90'),
194
194
  ])
195
195
 
196
196
  """
@@ -225,12 +225,12 @@ class SuffixFilter(ArtefactsGetter):
225
225
  Example::
226
226
 
227
227
  # The default source getter for the FortranPreProcessor step.
228
- DEFAULT_SOURCE = SuffixFilter(ArtefactSet.INITIAL_SOURCE, '.F90')
228
+ DEFAULT_SOURCE = SuffixFilter(ArtefactSet.INITIAL_SOURCE_FILES, '.F90')
229
229
 
230
230
  """
231
231
  def __init__(self,
232
232
  collection_name: Union[str, ArtefactSet],
233
- suffix: Union[str, List[str]]):
233
+ suffix: Union[str, list[str]]):
234
234
  """
235
235
  :param collection_name:
236
236
  The name of the artefact collection.
@@ -258,10 +258,10 @@ class FilterBuildTrees(ArtefactsGetter):
258
258
  DEFAULT_SOURCE_GETTER = FilterBuildTrees(suffix='.f90')
259
259
 
260
260
  :returns: one list of files to compile per build tree, of the form
261
- Dict[name, List[AnalysedDependent]]
261
+ Dict[name, list[AnalysedDependent]]
262
262
 
263
263
  """
264
- def __init__(self, suffix: Union[str, List[str]]):
264
+ def __init__(self, suffix: Union[str, list[str]]):
265
265
  """
266
266
  :param suffix:
267
267
  A suffix string, or iterable of, including the preceding dot.
@@ -273,7 +273,7 @@ class FilterBuildTrees(ArtefactsGetter):
273
273
 
274
274
  build_trees = artefact_store[ArtefactSet.BUILD_TREES]
275
275
 
276
- build_lists: Dict[str, List[AnalysedDependent]] = {}
276
+ build_lists: dict[str, list[AnalysedDependent]] = {}
277
277
  for root, tree in build_trees.items():
278
278
  build_lists[root] = filter_source_tree(source_tree=tree,
279
279
  suffixes=self.suffixes)
@@ -18,14 +18,14 @@ from logging.handlers import RotatingFileHandler
18
18
  from multiprocessing import cpu_count
19
19
  from pathlib import Path
20
20
  from string import Template
21
- from typing import List, Optional, Iterable
21
+ from typing import Optional, Iterable
22
22
 
23
23
  from fab.artefacts import ArtefactSet, ArtefactStore
24
24
  from fab.constants import BUILD_OUTPUT, SOURCE_ROOT, PREBUILD
25
25
  from fab.metrics import (send_metric, init_metrics, stop_metrics,
26
26
  metrics_summary)
27
27
  from fab.tools.category import Category
28
- from fab.tools.tool_box import ToolBox
28
+ from fab.tools.abstract_tool_box import AbstractToolBox
29
29
  from fab.steps.cleanup_prebuilds import CLEANUP_COUNT, cleanup_prebuilds
30
30
  from fab.util import TimerLogger, by_type, get_fab_workspace
31
31
 
@@ -41,7 +41,7 @@ class BuildConfig():
41
41
 
42
42
  """
43
43
  def __init__(self, project_label: str,
44
- tool_box: ToolBox,
44
+ tool_box: AbstractToolBox,
45
45
  mpi: bool = False,
46
46
  openmp: bool = False,
47
47
  profile: Optional[str] = None,
@@ -91,9 +91,9 @@ class BuildConfig():
91
91
  self._openmp = openmp
92
92
  if profile is None:
93
93
  # An empty string is used for non-profiled flags
94
- self._profile = ""
94
+ self.set_profile("")
95
95
  else:
96
- self._profile = profile
96
+ self.set_profile(profile)
97
97
  self.two_stage = two_stage
98
98
  self.verbose = verbose
99
99
  compiler = tool_box.get_tool(Category.FORTRAN_COMPILER, mpi=mpi,
@@ -186,7 +186,7 @@ class BuildConfig():
186
186
  self._finalise_logging()
187
187
 
188
188
  @property
189
- def tool_box(self) -> ToolBox:
189
+ def tool_box(self) -> AbstractToolBox:
190
190
  ''':returns: the tool box to use.'''
191
191
  return self._tool_box
192
192
 
@@ -223,6 +223,13 @@ class BuildConfig():
223
223
  ''':returns: the name of the compiler profile to use.'''
224
224
  return self._profile
225
225
 
226
+ def set_profile(self, profile: str) -> None:
227
+ """Sets the compilation profile.
228
+
229
+ :param profile: the name of the profile.
230
+ """
231
+ self._profile = profile.lower()
232
+
226
233
  def add_current_prebuilds(self, artefacts: Iterable[Path]):
227
234
  """
228
235
  Mark the given file paths as being current prebuilds, not to be
@@ -288,13 +295,19 @@ class BuildConfig():
288
295
 
289
296
 
290
297
  # todo: better name? perhaps PathFlags?
298
+ # todo: This is going to be replaced with tools.flags.MatchFlags
299
+
291
300
  class AddFlags():
292
301
  """
293
302
  Add command-line flags when our path filter matches.
294
- Generally used inside a :class:`~fab.build_config.FlagsConfig`.
303
+ This class is deprecated, use the new
304
+ :class:`~fab.tools.flags.FlagList` and
305
+ :class:`~fab.tools.flags.MatchFlag` instead.
306
+ The compile and preprocess steps will convert AddFlags into
307
+ MatchFlags
295
308
 
296
309
  """
297
- def __init__(self, match: str, flags: List[str]):
310
+ def __init__(self, match: str, flags: list[str]):
298
311
  """
299
312
  :param match:
300
313
  The string to match against each file path.
@@ -318,11 +331,11 @@ class AddFlags():
318
331
 
319
332
  """
320
333
  self.match: str = match
321
- self.flags: List[str] = flags
334
+ self.flags: list[str] = flags
322
335
 
323
336
  # todo: we don't need the project_workspace, we could just pass in the
324
337
  # output folder
325
- def run(self, fpath: Path, input_flags: List[str], config):
338
+ def run(self, fpath: Path, input_flags: list[str], config):
326
339
  """
327
340
  Check if our filter matches a given file. If it does, add our flags.
328
341
 
@@ -347,48 +360,3 @@ class AddFlags():
347
360
 
348
361
  # add our flags
349
362
  input_flags += add_flags
350
-
351
-
352
- class FlagsConfig():
353
- """
354
- Return command-line flags for a given path.
355
-
356
- Simply allows appending flags but may evolve to also replace and
357
- remove flags.
358
-
359
- """
360
- def __init__(self, common_flags: Optional[List[str]] = None,
361
- path_flags: Optional[List[AddFlags]] = None):
362
- """
363
- :param common_flags:
364
- List of flags to apply to all files. E.g `['-O2']`.
365
- :param path_flags:
366
- List of :class:`~fab.build_config.AddFlags` objects which apply
367
- flags to selected paths.
368
-
369
- """
370
- self.common_flags = common_flags or []
371
- self.path_flags = path_flags or []
372
-
373
- # todo: there's templating both in this method and the run method it calls.
374
- # make sure it's all properly documented and rationalised.
375
- def flags_for_path(self, path: Path, config):
376
- """
377
- Get all the flags for a given file, in a reproducible order.
378
-
379
- :param path:
380
- The file path for which we want command-line flags.
381
- :param config:
382
- The config contains the source root and project workspace.
383
-
384
- """
385
- # We COULD make the user pass these template params to the constructor
386
- # but we have a design requirement to minimise the config burden on
387
- # the user, so we take care of it for them here instead.
388
- params = {'source': config.source_root, 'output': config.build_output}
389
- flags = [Template(i).substitute(params) for i in self.common_flags]
390
-
391
- for flags_modifier in self.path_flags:
392
- flags_modifier.run(path, flags, config=config)
393
-
394
- return flags
@@ -9,7 +9,7 @@
9
9
 
10
10
  import sys
11
11
  from pathlib import Path
12
- from typing import Dict, Optional
12
+ from typing import Optional
13
13
 
14
14
  from fab.artefacts import ArtefactSet, CollectionGetter
15
15
  from fab.build_config import BuildConfig
@@ -22,14 +22,17 @@ from fab.steps.compile_fortran import compile_fortran
22
22
  from fab.steps.find_source_files import find_source_files
23
23
  from fab.steps.grab.folder import grab_folder
24
24
  from fab.steps.preprocess import preprocess_c, preprocess_fortran
25
- from fab.tools import Category, ToolBox, ToolRepository
25
+ from fab.tools.category import Category
26
+ from fab.tools.tool_box import ToolBox
27
+ from fab.tools.tool_repository import ToolRepository
26
28
  from fab.util import common_arg_parser
27
29
 
28
30
 
29
31
  def _generic_build_config(folder: Path, kwargs=None) -> BuildConfig:
30
32
  project_label = 'zero_config_build'
31
33
  if kwargs:
32
- project_label = kwargs.pop('project_label', 'zero_config_build') or project_label
34
+ project_label = kwargs.pop('project_label',
35
+ 'zero_config_build') or project_label
33
36
 
34
37
  # Set the default Fortran compiler as linker (otherwise e.g. the
35
38
  # C compiler might be used in linking, requiring additional flags)
@@ -43,15 +46,18 @@ def _generic_build_config(folder: Path, kwargs=None) -> BuildConfig:
43
46
  tool_box.add_tool(fc)
44
47
  tool_box.add_tool(linker)
45
48
  # Within the fab workspace, we'll create a project workspace.
46
- # Ideally we'd just use folder.name, but to avoid clashes, we'll use the full absolute path.
49
+ # Ideally we'd just use folder.name, but to avoid clashes, we'll use the
50
+ # full absolute path.
47
51
  with BuildConfig(project_label=project_label, mpi=False, openmp=False,
48
52
  tool_box=tool_box, **kwargs) as config:
49
53
  grab_folder(config, folder)
50
54
  find_source_files(config)
51
- root_inc_files(config) # JULES helper, get rid of this eventually
55
+ # JULES helper, get rid of this eventually
56
+ root_inc_files(config, suffix_list=[".inc", ".h"])
52
57
  preprocess_fortran(config)
53
58
  c_pragma_injector(config)
54
- preprocess_c(config, source=CollectionGetter(ArtefactSet.C_BUILD_FILES))
59
+ preprocess_c(config,
60
+ source=CollectionGetter(ArtefactSet.C_COMPILER_FILES))
55
61
  analyse(config, find_programs=True)
56
62
  compile_fortran(config)
57
63
  compile_c(config)
@@ -63,11 +69,11 @@ def _generic_build_config(folder: Path, kwargs=None) -> BuildConfig:
63
69
  return config
64
70
 
65
71
 
66
- def cli_fab(folder: Optional[Path] = None, kwargs: Optional[Dict] = None):
72
+ def cli_fab(folder: Optional[Path] = None, kwargs: Optional[dict] = None):
67
73
  """
68
- Running Fab from the command line will attempt to build the project in the current or
69
- given folder. The following params are used for testing. When run normally any parameters
70
- will be caught by a common_arg_parser.
74
+ Running Fab from the command line will attempt to build the project in
75
+ the current or given folder. The following params are used for testing.
76
+ When run normally any parameters will be caught by a common_arg_parser.
71
77
 
72
78
  :param folder:
73
79
  source folder (Testing Only)
@@ -77,9 +83,9 @@ def cli_fab(folder: Optional[Path] = None, kwargs: Optional[Dict] = None):
77
83
  """
78
84
  kwargs = kwargs or {}
79
85
 
80
- # We check if 'fab' was called directly. As it can be called by other things like 'pytest',
81
- # the cli arguments may not apply to 'fab' which will cause arg_parser to fail with an
82
- # invalid argument message.
86
+ # We check if 'fab' was called directly. As it can be called by other
87
+ # things like 'pytest', the cli arguments may not apply to 'fab' which
88
+ # will cause arg_parser to fail with an invalid argument message.
83
89
  if Path(sys.argv[0]).parts[-1] == 'fab':
84
90
  arg_parser = common_arg_parser()
85
91
  kwargs = vars(arg_parser.parse_args())
@@ -13,7 +13,7 @@ from importlib.util import module_from_spec, spec_from_loader
13
13
  from importlib.machinery import SourceFileLoader
14
14
  from pathlib import Path
15
15
  from types import ModuleType
16
- from typing import List, Optional
16
+ from typing import Optional
17
17
 
18
18
 
19
19
  from .arguments import FabArgumentParser
@@ -50,7 +50,7 @@ def import_from_path(module_name: str, file_path: Path) -> Optional[ModuleType]:
50
50
  return module
51
51
 
52
52
 
53
- def main(argv: Optional[List[str]] = None):
53
+ def main(argv: Optional[list[str]] = None):
54
54
  """Main function.
55
55
 
56
56
  :param argv: list of command line arguments. Use sys.argv if not specified.
@@ -58,7 +58,7 @@ def main(argv: Optional[List[str]] = None):
58
58
 
59
59
  if argv is None:
60
60
  # Use system argument if none have been provided
61
- argv = sys.argv
61
+ argv = sys.argv[1:]
62
62
 
63
63
  parser = FabArgumentParser(description=__doc__)
64
64
  file_args = parser.parse_fabfile_only(argv)