From 45bea7cef706fb1bb1d8c55601558515e736068e Mon Sep 17 00:00:00 2001 From: kwryankrattiger <80296582+kwryankrattiger@users.noreply.github.com> Date: Wed, 20 Oct 2021 10:22:07 -0500 Subject: [PATCH] Update ECP dav helper for propagating variants (#26175) --- .../packages/ecp-data-vis-sdk/package.py | 102 +++++++++--------- 1 file changed, 52 insertions(+), 50 deletions(-) diff --git a/var/spack/repos/builtin/packages/ecp-data-vis-sdk/package.py b/var/spack/repos/builtin/packages/ecp-data-vis-sdk/package.py index 65fe5b173e..d8d4afa15f 100644 --- a/var/spack/repos/builtin/packages/ecp-data-vis-sdk/package.py +++ b/var/spack/repos/builtin/packages/ecp-data-vis-sdk/package.py @@ -45,74 +45,76 @@ class EcpDataVisSdk(BundlePackage): variant('visit', default=False, description="Enable VisIt") conflicts('+visit') - ############################################################ - # This is a messy workaround until the clingo concretizer can be required. - # The intent is to map package variants to dependency variants: - # Package variants a, and b, mapping to dependency variants A and B - # produce the following set of dependencies: - # depends_on('foo+A+B', when='+a+b') - # depends_on('foo+A~B', when='+a~b') - # depends_on('foo~A+B', when='~a+b') - # depends_on('foo~A~B', when='~a~b') - # The clingo concretizer will allow that to be expressed much simpler by - # only considering defaults once everything else is resolved: - # depends_on('foo') - # depends_on('foo+A', when='+a') - # depends_on('foo+B', when='+b') - ############################################################ + # Wrapper around depends_on to propagate dependency variants + def dav_sdk_depends_on(spec, when=None, propagate=None): + # Do the basic depends_on + depends_on(spec, when=when) - # Helper function to generate dependencies on the Cartesian product of - # variants. If a dictionary is passed then it provides a mapping of - # package variant name to dependency variant name. Otherwise assume they - # are the same variant name in both the package and dependency - def variants2deps(dep_spec, pkg_spec, variants): - if not type(variants) is dict: - variants = dict([(v, v) for v in variants]) - n = len(variants) - for i in range(0, pow(2, n)): - state = ['+' if d == '1' else '~' for d in format(i, '0' + str(n) + 'b')] - [pkg_vars, dep_vars] = [''.join(v) for v in zip( - *[(s + pv, s + dv) for s, (pv, dv) in zip(state, variants.items())])] - dependency = ' '.join((dep_spec, dep_vars)) - predicate = ' '.join((pkg_spec, pkg_vars)) - depends_on(dependency, when=predicate) + # Skip if there is nothing to propagate + if not propagate: + return + + # Map the propagated variants to the dependency variant + if not type(propagate) is dict: + propagate = dict([(v, v) for v in propagate]) + + # Strip spec string to just the base spec name + # ie. A +c ~b -> A + spec = Spec(spec).name + + # Determine the base variant + base_variant = '' + if when: + base_variant = when + + # Propagate variants to dependecy + for v_when, v_then in propagate.items(): + depends_on('{0} +{1}'.format(spec, v_then), + when='{0} +{1}'.format(base_variant, v_when)) + depends_on('{0} ~{1}'.format(spec, v_then), + when='{0} ~{1}'.format(base_variant, v_when)) ############################################################ # Dependencies ############################################################ - variants2deps('adios2+shared+mpi+fortran+python+blosc+sst+ssc+dataman', - '+adios2', ['hdf5', 'sz', 'zfp']) + dav_sdk_depends_on('adios2+shared+mpi+fortran+python+blosc+sst+ssc+dataman', + when='+adios2', + propagate=['hdf5', 'sz', 'zfp']) - depends_on('darshan-runtime+mpi', when='+darshan') - depends_on('darshan-util', when='+darshan') + dav_sdk_depends_on('darshan-runtime+mpi', when='+darshan') + dav_sdk_depends_on('darshan-util', when='+darshan') - variants2deps('faodel+shared+mpi network=libfabric', '+faodel', ['hdf5']) + dav_sdk_depends_on('faodel+shared+mpi network=libfabric', + when='+faodel', + propagate=['hdf5']) - depends_on('hdf5 +shared+mpi', when='+hdf5') - # +fortran breaks the concretizer... Needs new concretizer - # depends_on('hdf5 +shared+mpi+fortran', when='+hdf5') + dav_sdk_depends_on('hdf5 +shared+mpi+fortran', when='+hdf5') - depends_on('parallel-netcdf+shared+fortran', when='+pnetcdf') + dav_sdk_depends_on('parallel-netcdf+shared+fortran', when='+pnetcdf') - variants2deps('unifyfs', '+unifyfs ', ['hdf5']) + dav_sdk_depends_on('unifyfs', when='+unifyfs ', propagate=['hdf5']) - depends_on('veloc', when='+veloc') + dav_sdk_depends_on('veloc', when='+veloc') - depends_on('ascent+shared+mpi+fortran+openmp+python+vtkh+dray', when='+ascent') - depends_on('catalyst', when='+catalyst') + dav_sdk_depends_on('ascent+shared+mpi+fortran+openmp+python+vtkh+dray', + when='+ascent') + dav_sdk_depends_on('catalyst', when='+catalyst') depends_on('py-cinemasci', when='+cinema') - variants2deps('paraview+shared+mpi+python3+kits', '+paraview', ['hdf5']) # +adios2 is not yet enabled in the paraview package - # depends_on('paraview+adios2', when='+paraview +adios2') + dav_sdk_depends_on('paraview+shared+mpi+python3+kits', + when='+paraview', + propagate=['hdf5']) - depends_on('visit', when='+visit') + dav_sdk_depends_on('visit', when='+visit') - depends_on('vtk-m+shared+mpi+openmp+rendering', when='+vtkm') + dav_sdk_depends_on('vtk-m+shared+mpi+openmp+rendering', when='+vtkm') # +python is currently broken in sz - # variants2deps('sz+shared+fortran+python+random_access', '+sz', ['hdf5']) - variants2deps('sz+shared+fortran+random_access', '+sz', ['hdf5']) + # dav_sdk_depends_on('sz+shared+fortran+python+random_access', + dav_sdk_depends_on('sz+shared+fortran+random_access', + when='+sz', + propagate=['hdf5']) - depends_on('zfp', when='+zfp') + dav_sdk_depends_on('zfp', when='+zfp')