Skip to content

Commit

Permalink
Use setup_test_env to do configuration on ci that includes things lik…
Browse files Browse the repository at this point in the history
…e coveragerc

Additional fix for case with missing compiler
Explicitly add missing CMakeLists.txt files to sdist in pyproject.toml (may also need to be done in package CMakeLists.txt)
langmm committed May 30, 2024
1 parent bb8bfda commit f485b23
Showing 6 changed files with 21 additions and 110 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/test-install.yml
Original file line number Diff line number Diff line change
@@ -500,7 +500,7 @@ jobs:
--use-mamba
- if: matrix.install-method == 'conda' || matrix.install-method == 'mamba'
name: (CONDA) Configure
run: yggconfig
run: python utils/setup_test_env.py configure --use-mamba
- if: (matrix.install-method == 'conda' || matrix.install-method == 'mamba') &&
runner.os == 'macOS'
name: (MACOS,CONDA) Set allow_multiple_omp config
@@ -901,7 +901,7 @@ jobs:
--use-mamba
- if: matrix.install-method == 'conda' || matrix.install-method == 'mamba'
name: (CONDA) Configure
run: yggconfig
run: python utils/setup_test_env.py configure --use-mamba
- if: (matrix.install-method == 'conda' || matrix.install-method == 'mamba') &&
runner.os == 'macOS'
name: (MACOS,CONDA) Set allow_multiple_omp config
@@ -1278,7 +1278,7 @@ jobs:
--use-mamba
- if: matrix.install-method == 'conda' || matrix.install-method == 'mamba'
name: (CONDA) Configure
run: yggconfig
run: python utils/setup_test_env.py configure --use-mamba
- if: (matrix.install-method == 'conda' || matrix.install-method == 'mamba') &&
runner.os == 'macOS'
name: (MACOS,CONDA) Set allow_multiple_omp config
@@ -1636,7 +1636,7 @@ jobs:
--use-mamba
- if: matrix.install-method == 'conda' || matrix.install-method == 'mamba'
name: (CONDA) Configure
run: yggconfig
run: python utils/setup_test_env.py configure --use-mamba
- if: (matrix.install-method == 'conda' || matrix.install-method == 'mamba') &&
runner.os == 'macOS'
name: (MACOS,CONDA) Set allow_multiple_omp config
@@ -1993,7 +1993,7 @@ jobs:
--use-mamba
- if: matrix.install-method == 'conda' || matrix.install-method == 'mamba'
name: (CONDA) Configure
run: yggconfig
run: python utils/setup_test_env.py configure --use-mamba
- if: (matrix.install-method == 'conda' || matrix.install-method == 'mamba') &&
runner.os == 'macOS'
name: (MACOS,CONDA) Set allow_multiple_omp config
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -87,6 +87,9 @@ sdist.include = [
"yggdrasil/demos/fspm2020/meshes/*.obj",
"yggdrasil/demos/CiS2021-hackathon/meshes/*.obj",
"yggdrasil/examples/*/src/CMakeLists.txt",
"yggdrasil/examples/backwards/src/CMakeLists.txt",
"yggdrasil/examples/gs_lesson4/src/CMakeLists.txt",
"yggdrasil/examples/model_error_with_io/src/CMakeLists.txt",
]
wheel.exclude = [
"CMakeLists.txt",
12 changes: 11 additions & 1 deletion utils/setup_test_env.py
Original file line number Diff line number Diff line change
@@ -2081,7 +2081,7 @@ def setup_biocro_osr_integration(integration_dir, param=None,
(('--without-deps', ),
{'action': 'store_true',
'help': ("Perform installation steps without installing "
"dependencies first (assuming the depdnencies "
"dependencies first (assuming the dependencies "
"were already installed).")}),
])
# Install recipe
@@ -2116,6 +2116,12 @@ def setup_biocro_osr_integration(integration_dir, param=None,
"first (assuming the package was already "
"built).")}),
])
# Configure package
parser_pkg = subparsers.add_parser(
'configure', help="Configure the package.")
SetupParam.add_parser_args(
parser_pkg, skip=['method'],
include=['allow_missing'])
# Installation verification
parser_ver = subparsers.add_parser(
'verify', help="Verify that the package was installed correctly.")
@@ -2211,6 +2217,10 @@ def setup_biocro_osr_integration(integration_dir, param=None,
param=param, dont_test=args.dont_test,
varient_config_files=args.varient_config_files,
without_build=args.without_build)
elif args.operation == 'configure':
param = SetupParam.from_args(args, install_opts)
config_pkg(param=param, python=args.python,
allow_missing=args.allow_missing)
elif args.operation == 'verify':
param = SetupParam.from_args(args, install_opts)
verify_pkg(install_opts=param.install_opts)
2 changes: 1 addition & 1 deletion utils/test-install-base.yml
Original file line number Diff line number Diff line change
@@ -295,7 +295,7 @@ jobs:
run: python utils/setup_test_env.py install ${{ matrix.install-method }} --without-build --use-mamba
- name: (CONDA) Configure
if: matrix.install-method == 'conda' || matrix.install-method == 'mamba'
run: yggconfig
run: python utils/setup_test_env.py configure --use-mamba
- name: (MACOS,CONDA) Set allow_multiple_omp config
if: (matrix.install-method == 'conda' || matrix.install-method == 'mamba') && runner.os == 'macOS'
run: |
102 changes: 0 additions & 102 deletions yggdrasil/drivers/CMakeModelDriver.py
Original file line number Diff line number Diff line change
@@ -451,108 +451,6 @@ def is_valid_buildfile(cls, fname):
contents = fd.read()
return (not contents.startswith(_invalid_buildfile_comment))

# TODO: Remove this once exports working
# def write_wrappers(self, **kwargs):
# r"""Write any wrappers needed to compile and/or run a model.

# Args:
# **kwargs: Keyword arguments are passed to the parent class's
# method.

# Returns:
# list: Full paths to any created wrappers.

# """
# kwargs['verbose'] = True
# out = super(CMakeModelDriver, self).write_wrappers(**kwargs)
# # Create cmake files that can be included
# if self.target is None:
# include_base = 'ygg_cmake.txt'
# else:
# include_base = f'ygg_cmake_{self.target}.txt'
# include_file = os.path.join(self.sourcedir, include_base)
# target_dep = self.model_dep.get('target_dep')
# kws = dict(compiler=target_dep.tool('compiler'),
# linker=target_dep.tool('linker'),
# driver=target_dep.driver,
# configuration=self.configuration,
# verbose=kwargs.get('verbose', False))
# if not self.target_flags_in_env:
# library_flags = []
# internal_library_flags = []
# external_library_flags = []
# kws.update(
# compiler_flags=target_dep.get(
# 'compiler_flags', no_additional_stages=True,
# skip_no_additional_stages_flag=True
# ),
# linker_flags=target_dep.get(
# 'linker_flags', library_flags=library_flags,
# internal_library_flags=internal_library_flags,
# external_library_flags=external_library_flags,
# use_library_path_internal='internal_library_flags',
# use_library_path='external_library_flags',
# skip_library_libs=True),
# internal_library_flags=internal_library_flags)
# kws['library_flags'] = (library_flags
# + internal_library_flags
# + external_library_flags)
# newlines_before = self.model_dep.tool('basetool').create_include(
# include_file, self.target, products=self.products, **kws)
# # Create copy of cmakelists and modify
# newlines_after = []
# abs_buildfile = self.buildfile
# if not os.path.isabs(abs_buildfile):
# abs_buildfile = os.path.join(self.sourcedir, abs_buildfile)
# self.products.append_generated(
# abs_buildfile, [], replaces=True, tag='compile_time',
# verbose=kwargs.get('verbose', False))
# build_product = self.products.last
# orig_buildfile = build_product.name
# if os.path.isfile(build_product.replaces):
# orig_buildfile = build_product.replaces
# if os.path.isfile(orig_buildfile):
# with open(orig_buildfile, 'r') as fd:
# contents = fd.read().splitlines()
# # Prevent error when cross compiling by building static lib
# # as test
# newlines_before.append(
# 'set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")')
# # Add env prefix as first line so that env installed C
# # libraries are used
# for iprefix in self.model_dep.tool('basetool').get_env_prefixes():
# if platform._is_win: # pragma: windows
# env_lib = os.path.join(iprefix, 'libs').replace(
# '\\', '\\\\')
# else:
# env_lib = os.path.join(iprefix, 'lib')
# newlines_before.append(f'LINK_DIRECTORIES({env_lib})')
# # Explicitly set Release/Debug directories to builddir on
# # windows
# if platform._is_win: # pragma: windows
# for artifact in ['runtime', 'library', 'archive']:
# for conf in ['release', 'debug']:
# newlines_before.append(
# f'SET( CMAKE_{artifact.upper()}_'
# f'OUTPUT_DIRECTORY_{conf.upper()} '
# f'"${{OUTPUT_DIRECTORY}}")')
# # Add yggdrasil created include if not already in the file
# include_rel = os.path.relpath(
# include_file, os.path.dirname(build_product.name))
# newlines_after.append(f'INCLUDE({include_rel})')
# # Consolidate lines, checking for lines that already exist
# lines = []
# for newline in newlines_before:
# if newline not in contents:
# lines.append(newline)
# lines += contents
# for newline in newlines_after:
# if newline not in contents:
# lines.append(newline)
# # Append to product list
# build_product.lines = lines
# return out

@classmethod
def get_language_for_buildfile(cls, buildfile, target=None):
r"""Determine the target language based on the contents of a
2 changes: 1 addition & 1 deletion yggdrasil/drivers/CompiledModelDriver.py
Original file line number Diff line number Diff line change
@@ -2724,7 +2724,7 @@ def generate(self, filetype=None, overwrite=False, **kwargs):
DependencySpecialization.tooltypes)]:
tooltype = filetype.rsplit('_', 1)[0]
out = None
tool = self.get(tooltype, **kwargs)
tool = self.get(tooltype, None, **kwargs)
if tool:
out = tool.get_executable(full_path=True)
elif filetype in [f'{k}_env' for k in

0 comments on commit f485b23

Please sign in to comment.