Skip to content

Commit

Permalink
Force shell use for package configuration to get conda environment ac…
Browse files Browse the repository at this point in the history
…tivation

Fix other location that incorrect MSVC was being used
Added -fPIC to compilation flags for c_wrappers.c on linux
Print output of test that should fail
Remove deprecated test
Fix bug where target environment updates where not being performed for build tools
Added debug messages for bugs in findall test, create_imports, and generate_windows_import
Fix bug where shared dependencies for static libraries were not exported
Allow list of flags for flag_options
Disable cmake default flags for debug and release builds as well
Fix bug where full path was used for library search for python
Fix bug where absence of a compiler caused an error
  • Loading branch information
langmm committed May 28, 2024
1 parent 1db6074 commit 3aab877
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 40 deletions.
10 changes: 0 additions & 10 deletions .github/workflows/test-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,6 @@ jobs:
runner.os == 'Windows' && env.INSTALLC == 1
name: (WINDOWS,CONDA) Set up MSVC Compiler
uses: ilammy/msvc-dev-cmd@v1
with:
toolset: 14.0
- continue-on-error: true
id: conda_build
if: matrix.install-method == 'conda' || matrix.install-method == 'mamba'
Expand Down Expand Up @@ -861,8 +859,6 @@ jobs:
runner.os == 'Windows' && env.INSTALLC == 1
name: (WINDOWS,CONDA) Set up MSVC Compiler
uses: ilammy/msvc-dev-cmd@v1
with:
toolset: 14.0
- continue-on-error: true
id: conda_build
if: matrix.install-method == 'conda' || matrix.install-method == 'mamba'
Expand Down Expand Up @@ -1237,8 +1233,6 @@ jobs:
runner.os == 'Windows' && env.INSTALLC == 1
name: (WINDOWS,CONDA) Set up MSVC Compiler
uses: ilammy/msvc-dev-cmd@v1
with:
toolset: 14.0
- continue-on-error: true
id: conda_build
if: matrix.install-method == 'conda' || matrix.install-method == 'mamba'
Expand Down Expand Up @@ -1594,8 +1588,6 @@ jobs:
runner.os == 'Windows' && env.INSTALLC == 1
name: (WINDOWS,CONDA) Set up MSVC Compiler
uses: ilammy/msvc-dev-cmd@v1
with:
toolset: 14.0
- continue-on-error: true
id: conda_build
if: matrix.install-method == 'conda' || matrix.install-method == 'mamba'
Expand Down Expand Up @@ -1950,8 +1942,6 @@ jobs:
runner.os == 'Windows' && env.INSTALLC == 1
name: (WINDOWS,CONDA) Set up MSVC Compiler
uses: ilammy/msvc-dev-cmd@v1
with:
toolset: 14.0
- continue-on-error: true
id: conda_build
if: matrix.install-method == 'conda' || matrix.install-method == 'mamba'
Expand Down
18 changes: 1 addition & 17 deletions tests/drivers/test_CModelDriver.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import pytest
import os
from yggdrasil import platform
from yggdrasil.drivers.CModelDriver import CModelDriver, LDLinker
from yggdrasil.drivers.CModelDriver import LDLinker


def test_LDLinker_tool_version():
Expand All @@ -10,16 +7,3 @@ def test_LDLinker_tool_version():
LDLinker.tool_version()
LDLinker.get_search_path()
LDLinker.get_env_flags()


@pytest.mark.skipif(not platform._is_linux, reason="OS is not Linux")
def test_update_ld_library_path():
r"""Test update_ld_library_path method."""
lang_dir = CModelDriver.get_language_dir()
total = os.pathsep.join(['test', lang_dir])
env = {'LD_LIBRARY_PATH': 'test'}
env = CModelDriver.update_ld_library_path(env)
assert(env['LD_LIBRARY_PATH'] == total)
# Second time to ensure that path not added twice
env = CModelDriver.update_ld_library_path(env)
assert(env['LD_LIBRARY_PATH'] == total)
2 changes: 1 addition & 1 deletion tests/drivers/test_ModelDriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def test_ModelDriver_implementation():
with pytest.raises(NotImplementedError):
ModelDriver.is_library_installed(None)
with pytest.raises(InvalidCompilationTool):
CompiledModelDriver.get_tool('compiler')
print(CompiledModelDriver.get_tool('compiler'))
with pytest.raises(NotImplementedError):
CompiledModelDriver.language_executable()
with pytest.raises(NotImplementedError):
Expand Down
2 changes: 2 additions & 0 deletions tests/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ def test_find_all():
# Multiple files
mdir, mpat, mans = make_temp_multiple()
mout = tools.find_all(mpat, mdir)
print(mout)
print(mans)
assert isinstance(mout, list)
assert mout == mans

Expand Down
2 changes: 1 addition & 1 deletion utils/setup_test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -1742,7 +1742,7 @@ def install_pkg(method, param=None, without_build=False,
# allow_missing=False)
return cmds
call_script(cmds, param=param)
config_pkg(param=param, allow_missing=False)
config_pkg(param=param, allow_missing=False, use_shell=True)


def verify_pkg(install_opts=None):
Expand Down
4 changes: 2 additions & 2 deletions utils/test-install-base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ jobs:
- name: (WINDOWS,CONDA) Set up MSVC Compiler
uses: ilammy/msvc-dev-cmd@v1
if: (matrix.install-method == 'conda' || matrix.install-method == 'mamba') && runner.os == 'Windows' && env.INSTALLC == 1
with:
toolset: 14.0
# with:
# toolset: 14.0
# - name: (UNIX,CONDA) Add miniconda bin to path
# if: (matrix.install-method == 'conda' || matrix.install-method == 'mamba') && runner.os != 'Windows'
# run: |
Expand Down
18 changes: 15 additions & 3 deletions yggdrasil/drivers/CMakeModelDriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,18 @@ class CMakeConfigure(ConfigurerBase):
('target_fortran_compiler_path',
'-DCMAKE_Fortran_COMPILER:FILEPATH=%s'),
('target_linker_path', '-DCMAKE_LINKER=%s'),
('ignore_default_c_flags', '-DCMAKE_C_FLAGS='),
('ignore_default_c++_flags', '-DCMAKE_CXX_FLAGS='),
('ignore_default_fortran_flags', '-DCMAKE_Fortran_FLAGS='),
('ignore_default_c_flags',
['-DCMAKE_C_FLAGS=',
'-DCMAKE_C_FLAGS_DEBUG=',
'-DCMAKE_C_FLAGS_RELEASE=']),
('ignore_default_c++_flags',
['-DCMAKE_CXX_FLAGS=',
'-DCMAKE_CXX_FLAGS_DEBUG=',
'-DCMAKE_CXX_FLAGS_RELEASE=']),
('ignore_default_fortran_flags',
['-DCMAKE_Fortran_FLAGS=',
'-DCMAKE_Fortran_FLAGS_DEBUG=',
'-DCMAKE_Fortran_FLAGS_RELEASE=']),
('osx_sysroot', '-DCMAKE_OSX_SYSROOT=%s'),
('osx_deployment_target', '-DCMAKE_OSX_DEPLOYMENT_TARGET=%s'),
('sourcedir', '-S'),
Expand Down Expand Up @@ -815,6 +824,9 @@ def create_imports(cls, dep, imp, products=None, overwrite=False,
"""
logger.debug(f"CREATE_IMPORTS {dep} {imp}")
buildfile = dep['buildfile']
if not os.path.isabs(buildfile):
buildfile = dep._relative_to_directory(buildfile)
logger.info(f"CREATE_IMPORTS {dep}: {buildfile}")
target = dep.get('target', '${PROJECT_NAME}')
if products is None:
products = tools.IntegrationPathSet(overwrite=overwrite)
Expand Down
18 changes: 13 additions & 5 deletions yggdrasil/drivers/CompiledModelDriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
_all_toolsets = [
'gnu', 'msvc', 'llvm',
]
_default_libtype = 'static' # TODO: retry static'
_default_libtype = 'static'
_conda_prefix = tools.get_conda_prefix()
_venv_prefix = tools.get_venv_prefix()
_system_suffix = ""
Expand Down Expand Up @@ -2193,7 +2193,7 @@ def locate_tool(self, tooltype, toolname):
tooltype0, language=language,
driver=self.parent_driver,
compatible_with=toolname,
only_installed=True)
only_installed=True, default=None)
self._updated_tools[tooltype][toolname] = out
if out and out.toolname not in self._updated_tools[tooltype]:
self._updated_tools[tooltype][out.toolname] = out
Expand Down Expand Up @@ -2940,6 +2940,9 @@ def _result(self, **kwargs):
def _generated_windows_import(self, previous=None, **kwargs):
out = None
dll = self.get('shared', **kwargs)
# TODO: temp
logger.info(f"GENERATED_WINDOWS_IMPORT [{self.name}]: {dll} "
f"(previous = {previous}")
if dll:
directory = self.parent_driver.get_language_dir()
out = create_windows_import(
Expand Down Expand Up @@ -3471,8 +3474,7 @@ def _dep_libtool_kwargs(self, key, to_update=None, dep_libtype=None,
if not os.path.isfile(dep_lib):
raise RuntimeError(f"Library for {self.name} dependency "
f"does not exist: '{dep_lib}'.")
if ((self['libtype'] in self.library_files
and dep_libtype != 'static')):
if self['libtype'] in self.library_files:
libkey = 'libraries'
if use_library_path_internal and self.origin == 'internal':
if to_update.get('skip_library_libs', False):
Expand Down Expand Up @@ -3595,6 +3597,7 @@ def _generic_env(self, key, to_update=None, for_build=False,
if ((self.parent_driver.is_build_tool
and self.parameters.get('target_dep', False))):
target_dep = self.parameters['target_dep']
out.update(target_dep.get(key, **kws))
for k in target_dep.active_tools():
out.update(
target_dep.get(f'{k}_env', for_build=for_build, **kws))
Expand Down Expand Up @@ -3730,6 +3733,7 @@ def _search_brute(self, fname, libtype=None, verbose=False,
fname_ext = expected_ext[0]
if os.path.isfile(fname):
return fname
fname_base = os.path.basename(fname_base)
# use_regex = (not platform._is_win)
fname_try = [fname_base]
if platform._is_win and libtype in self.library_files:
Expand Down Expand Up @@ -4414,14 +4418,18 @@ def create_flag(cls, key, value):
list: Items representing the flag.
"""
if (not isinstance(key, dict)) and (key in cls.flag_options):
if (not isinstance(key, (dict, list))) and (key in cls.flag_options):
key = cls.flag_options[key]
if isinstance(key, dict):
key = key['key']
if isinstance(value, list):
out = []
for v in value:
out += cls.create_flag(key, v)
elif isinstance(key, list):
out = []
for k in key:
out += cls.create_flag(k, value)
elif value is None:
out = []
elif len(key) == 0:
Expand Down
7 changes: 6 additions & 1 deletion yggdrasil/drivers/FortranModelDriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,12 @@ class FortranModelDriver(CompiledModelDriver):
'source': 'c_wrappers.c',
'language': 'c',
'libtype': 'object',
'internal_dependencies': [('c', 'ygg')]}}
'internal_dependencies': [('c', 'ygg')],
'platform_specifics': {
'Linux': {
'compiler_flags': ['-fPIC'],
}
}}}
type_map = {
'comm': 'yggcomm',
'dtype': 'yggdtype',
Expand Down

0 comments on commit 3aab877

Please sign in to comment.