Skip to content

Commit

Permalink
py-icon4py: Remove 0.0.11 and 0.0.12
Browse files Browse the repository at this point in the history
  • Loading branch information
dominichofer committed Aug 9, 2024
1 parent e85cd77 commit 9b2c7b8
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 85 deletions.
121 changes: 39 additions & 82 deletions repo/packages/py-icon4py/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,115 +13,76 @@


class PyIcon4py(PythonPackage):
"""ICON4Py contains Python (GT4Py) implementations of ICON (inspired)
"""ICON4Py contains Python (GT4Py) implementations of ICON (inspired)
components for weather and climate models."""

git = '[email protected]:C2SM/icon4py.git'
git = "[email protected]:C2SM/icon4py.git"
homepage = "https://github.com/C2SM/icon4py"
maintainers = ['agopal', 'samkellerhals']
maintainers = ["agopal", "samkellerhals"]

version('main', branch='main')
version('0.0.12', tag='v0.0.12')
version('0.0.11', tag='v0.0.11')
version('0.0.10', tag='v0.0.10')
version("main", branch="main")
version("0.0.12", tag="v0.0.12")

depends_on('py-wheel', type='build')
depends_on('py-setuptools', type='build')
depends_on("py-wheel", type="build")
depends_on("py-setuptools", type="build")

depends_on('[email protected]:', type=('build', 'run'))
depends_on('[email protected]:', type=('build', 'run'))
depends_on("[email protected]:", type=("build", "run"))
depends_on("[email protected]:", type=("build", "run"))
# TODO: push new version to Spack official
depends_on('[email protected]:', type=('build', 'run'))
depends_on('py-gt4py', type=('build', 'run'))
depends_on('py-pytest', type=('build', 'run'))
depends_on('[email protected]:', type=('build', 'run'))
depends_on("[email protected]:", type=("build", "run"))
depends_on("py-gt4py", type=("build", "run"))
depends_on("py-pytest", type=("build", "run"))
depends_on("[email protected]:", type=("build", "run"))

def patch(self):
spack_pytest_ini = 'jenkins/spack/pytest.ini'
spack_pytest_ini = "jenkins/spack/pytest.ini"
if os.path.exists(spack_pytest_ini):
fs.install(spack_pytest_ini, '.')
fs.install(spack_pytest_ini, ".")

# cmake in unit-tests needs this path
def setup_build_environment(self, env):
env.set("CMAKE_INCLUDE_PATH", self.spec['boost'].prefix.include)
env.set("CMAKE_INCLUDE_PATH", self.spec["boost"].prefix.include)

def test(self):
# check if all installed module can be imported
super().test()
# unit tests

python('-m', 'pytest', '-v', '-s', '-n', 'auto', '-m',
'not slow_tests')
python("-m", "pytest", "-v", "-s", "-n", "auto", "-m", "not slow_tests")

@property
def headers(self):
'''Workaround to hide the details of the installation path,
"""Workaround to hide the details of the installation path,
i.e "lib/python3.10/site-packages/icon4py/atm_dyn_iconam"
from upstream packages. It needs to be part of the "Spec" object,
therefore choose the headers-function
'''
"""
query_parameters = self.spec.last_query.extra_parameters
version = self.spec.version

folder_mapping = {
ver('=0.0.3.1'): {
'atm_dyn_iconam': 'atm_dyn_iconam',
'utils':
'liskov' #utils will eventually map to parent directory of liskov
},
ver('=0.0.9'): {
'atm_dyn_iconam': 'dycore',
'tools': 'icon4pytools',
'diffusion': 'diffusion/stencils',
'interpolation': 'interpolation/stencils',
'advection': 'advection',
},
ver('=0.0.10'): {
'atm_dyn_iconam': 'dycore',
'tools': 'icon4pytools',
'diffusion': 'diffusion/stencils',
'interpolation': 'interpolation/stencils',
'advection': 'advection',
},
ver('=0.0.11'): {
'atm_dyn_iconam': 'dycore',
'tools': 'icon4pytools',
'diffusion': 'diffusion/stencils',
'interpolation': 'interpolation/stencils',
'advection': 'advection',
},
ver('=main'): {
'atm_dyn_iconam': 'dycore',
'tools': 'icon4pytools',
'diffusion': 'diffusion/stencils',
'interpolation': 'interpolation/stencils',
'advection': 'advection',
},
}

if len(query_parameters) > 1:
raise ValueError('Only one query parameter allowed')

folder_name = folder_mapping.get(version, {})

if not folder_name:
return HeaderList([])
raise ValueError("Only one query parameter allowed")

folder_name = {
"atm_dyn_iconam": "dycore",
"tools": "icon4pytools",
"diffusion": "diffusion/stencils",
"interpolation": "interpolation/stencils",
"advection": "advection",
}

for param, folder in folder_name.items():
if param in query_parameters:
return self._find_folder_and_add_dummy_header(
self.prefix, folder)
return self._find_folder_and_add_dummy_header(self.prefix, folder)

return HeaderList([])

def _find_folder_and_add_dummy_header(self, prefix, name):
folder = find(prefix, name)
headerlist = HeaderList(f'{folder[0]}/dummy.h')
headerlist = HeaderList(f"{folder[0]}/dummy.h")
return headerlist


class PythonPipBuilder(PythonPipBuilder):

def install(self, pkg, spec, prefix):
"""Install everything from build directory."""

Expand All @@ -132,8 +93,8 @@ def install(self, pkg, spec, prefix):
raise SpecError(
"'{}' package uses 'config_settings' which is only supported by "
"pip 22.1+. Add the following line to the package to fix this:\n\n"
' depends_on("[email protected]:", type="build")'.format(
spec.name))
' depends_on("[email protected]:", type="build")'.format(spec.name)
)

args.append("--config-settings={}={}".format(key, value))

Expand All @@ -148,17 +109,13 @@ def install(self, pkg, spec, prefix):
args.append(".")

pip = inspect.getmodule(pkg).pip

if self.spec.version == ver('=0.0.3.1'):
build_dirs = [
'common', 'pyutils', 'testutils', 'liskov', 'atm_dyn_iconam'
]
else:
build_dirs = [
'tools', 'model/atmosphere/dycore',
'model/atmosphere/diffusion', 'model/atmosphere/advection',
'model/common/'
]
build_dirs = [
"tools",
"model/atmosphere/dycore",
"model/atmosphere/diffusion",
"model/atmosphere/advection",
"model/common/",
]

for dir in build_dirs:
with fs.working_dir(os.path.join(self.build_directory, dir)):
Expand Down
5 changes: 2 additions & 3 deletions test/system_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,8 @@ def test_install_py_gt4py_for_version(version, ):
spack_install(f'py-gt4py @{version}')


@pytest.mark.parametrize("version", ['0.0.10', '0.0.11', '0.0.12'])
def test_install_py_icon4py_version_0_0_10(version, ):
spack_install(f'py-icon4py @{version}')
def test_install_py_icon4py():
spack_install('py-icon4py')


def test_install_py_hatchling_default():
Expand Down

0 comments on commit 9b2c7b8

Please sign in to comment.