desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'Get subset of the dependencies with certain types.'
| def dependencies_of_type(self, *deptypes):
| return dict(((name, conds) for (name, conds) in self.dependencies.items() if any(((d in self.dependency_types[name]) for d in deptypes))))
|
'Spec of the extendee of this package, or None if it is not an extension'
| @property
def extendee_spec(self):
| if (not self.extendees):
return None
name = next(iter(self.extendees))
for dep in self.spec.traverse(deptypes=('link', 'run')):
if (name == dep.name):
return dep
if self.spec._concrete:
return None
else:
(spec, kwargs) = self.extendees[name]
return... |
'Spec of the extendee of this package, or None if it is not an extension'
| @property
def extendee_args(self):
| if (not self.extendees):
return None
name = next(iter(self.extendees))
return self.extendees[name][1]
|
'True if this package provides a virtual package with the specified name'
| def provides(self, vpkg_name):
| return any(((s.name == vpkg_name) for s in self.provided))
|
'Get the prefix into which this package should be installed.'
| @property
def prefix(self):
| return self.spec.prefix
|
'Get the spack.architecture.Arch object that represents the
environment in which this package will be built.'
| @property
def architecture(self):
| if (not self.spec.concrete):
raise ValueError('Can only get the arch for concrete package.')
return spack.architecture.arch_for_spec(self.spec.architecture)
|
'Get the spack.compiler.Compiler object used to build this package'
| @property
def compiler(self):
| if (not self.spec.concrete):
raise ValueError('Can only get a compiler for a concrete package.')
return spack.compilers.compiler_for_spec(self.spec.compiler, self.spec.architecture)
|
'Given a version, this returns a string that should be substituted
into the package\'s URL to download that version.
By default, this just returns the version string. Subclasses may need
to override this, e.g. for boost versions where you need to ensure that
there are _\'s in the download URL.'
| def url_version(self, version):
| return str(version)
|
'Removes the prefix for a package along with any empty parent
directories'
| def remove_prefix(self):
| spack.store.layout.remove_install_directory(self.spec)
|
'Creates a stage directory and downloads the tarball for this package.
Working directory will be set to the stage directory.'
| def do_fetch(self, mirror_only=False):
| if (not self.spec.concrete):
raise ValueError('Can only fetch concrete packages.')
start_time = time.time()
if (spack.do_checksum and (self.version not in self.versions)):
tty.warn(('There is no checksum on file to fetch %s safely.' % self.spec.cformat(... |
'Unpacks the fetched tarball, then changes into the expanded tarball
directory.'
| def do_stage(self, mirror_only=False):
| if (not self.spec.concrete):
raise ValueError('Can only stage concrete packages.')
self.do_fetch(mirror_only)
self.stage.expand_archive()
self.stage.chdir_to_source()
|
'Calls do_stage(), then applied patches to the expanded tarball if they
haven\'t been applied already.'
| def do_patch(self):
| if (not self.spec.concrete):
raise ValueError('Can only patch concrete packages.')
self.do_stage()
has_patch_fun = (hasattr(self, 'patch') and callable(self.patch))
if ((not self.patches) and (not has_patch_fun)):
tty.msg(('No patches needed for %s' % self.name))
... |
'Make a fake install directory containing fake executables,
headers, and libraries.'
| def do_fake_install(self):
| name = self.name
library_name = ('lib' + self.name)
dso_suffix = ('.dylib' if (sys.platform == 'darwin') else '.so')
chmod = which('chmod')
mkdirp(self.prefix.bin)
touch(join_path(self.prefix.bin, name))
chmod('+x', join_path(self.prefix.bin, name))
mkdirp(self.prefix.include)
touch(... |
'Prefix lock nested in a stage.'
| @contextlib.contextmanager
def _stage_and_write_lock(self):
| with self.stage:
with spack.store.db.prefix_write_lock(self.spec):
(yield)
|
'Helper function to process external packages.
Runs post install hooks and registers the package in the DB.
Args:
explicit (bool): if the package was requested explicitly by
the user, False if it was pulled in as a dependency of an
explicit package.'
| def _process_external_package(self, explicit):
| if self.spec.external_module:
message = '{s.name}@{s.version} : has external module in {module}'
tty.msg(message.format(s=self, module=self.spec.external_module))
message = '{s.name}@{s.version} : is actually installed in {path}'
tty.msg(message.fo... |
'Called by commands to install a package and its dependencies.
Package implementations should override install() to describe
their build process.
Args:
keep_prefix (bool): Keep install prefix on failure. By default,
destroys it.
keep_stage (bool): By default, stage is destroyed only if there
are no exceptions during bu... | def do_install(self, keep_prefix=False, keep_stage=False, install_deps=True, skip_patch=False, verbose=False, make_jobs=None, run_tests=False, fake=False, explicit=False, dirty=None, **kwargs):
| if (not self.spec.concrete):
raise ValueError(('Can only install concrete packages: %s.' % self.spec.name))
if self.spec.external:
return self._process_external_package(explicit)
restage = kwargs.get('restage', False)
partial = self.check_for_unfinished_installation(keep_p... |
'Check for leftover files from partially-completed prior install to
prepare for a new install attempt. Options control whether these
files are reused (vs. destroyed). This function considers a package
fully-installed if there is a DB entry for it (in that way, it is
more strict than Package.installed). The return value... | def check_for_unfinished_installation(self, keep_prefix=False, restage=False):
| if self.spec.external:
raise ExternalPackageError(('Attempted to repair external spec %s' % self.spec.name))
with spack.store.db.prefix_write_lock(self.spec):
try:
record = spack.store.db.get_record(self.spec)
installed_in_db = (record.installed if record e... |
'Pops kwargs from do_install before starting the installation
Args:
kwargs:
\'stop_at\': last installation phase to be executed (or None)'
| def _do_install_pop_kwargs(self, kwargs):
| self.last_phase = kwargs.pop('stop_at', None)
if ((self.last_phase is not None) and (self.last_phase not in self.phases)):
tty.die("'{0}' is not an allowed phase for package {1}".format(self.last_phase, self.name))
|
'This function checks whether install succeeded.'
| def sanity_check_prefix(self):
| def check_paths(path_list, filetype, predicate):
if isinstance(path_list, string_types):
path_list = [path_list]
for path in path_list:
abs_path = os.path.join(self.prefix, path)
if (not predicate(abs_path)):
raise InstallError(('Install failed ... |
'Use this to add variables to the class\'s module\'s scope.
This lets us use custom syntax in the install method.'
| @property
def module(self):
| return __import__(self.__class__.__module__, fromlist=[self.__class__.__name__])
|
'Set up the compile and runtime environments for a package.
``spack_env`` and ``run_env`` are ``EnvironmentModifications``
objects. Package authors can call methods on them to alter
the environment within Spack and at runtime.
Both ``spack_env`` and ``run_env`` are applied within the build
process, before this package\... | def setup_environment(self, spack_env, run_env):
| pass
|
'Set up the environment of packages that depend on this one.
This is similar to ``setup_environment``, but it is used to
modify the compile and runtime environments of packages that
*depend* on this one. This gives packages like Python and
others that follow the extension model a way to implement
common environment or ... | def setup_dependent_environment(self, spack_env, run_env, dependent_spec):
| pass
|
'Set up Python module-scope variables for dependent packages.
Called before the install() method of dependents.
Default implementation does nothing, but this can be
overridden by an extendable package to set up the module of
its extensions. This is useful if there are some common steps
to installing all extensions for ... | def setup_dependent_package(self, module, dependent_spec):
| pass
|
'Uninstall this package by spec.'
| def do_uninstall(self, force=False):
| Package.uninstall_by_spec(self.spec, force)
|
'Called on an extension to invoke the extendee\'s activate method.
Commands should call this routine, and should not call
activate() directly.'
| def do_activate(self, force=False):
| self._sanity_check_extension()
spack.store.layout.check_extension_conflict(self.extendee_spec, self.spec)
if (not force):
for spec in self.dependency_activations():
if (not spec.package.activated):
spec.package.do_activate(force=force)
self.extendee_spec.package.activ... |
'Symlinks all files from the extension into extendee\'s install dir.
Package authors can override this method to support other
extension mechanisms. Spack internals (commands, hooks, etc.)
should call do_activate() method so that proper checks are
always executed.'
| def activate(self, extension, **kwargs):
| def ignore(filename):
return ((filename in spack.store.layout.hidden_file_paths) or kwargs.get('ignore', (lambda f: False))(filename))
tree = LinkTree(extension.prefix)
conflict = tree.find_conflict(self.prefix, ignore=ignore)
if conflict:
raise ExtensionConflictError(conflict)
tree.... |
'Called on the extension to invoke extendee\'s deactivate() method.'
| def do_deactivate(self, **kwargs):
| self._sanity_check_extension()
force = kwargs.get('force', False)
if (not force):
spack.store.layout.check_activated(self.extendee_spec, self.spec)
activated = spack.store.layout.extension_map(self.extendee_spec)
for (name, aspec) in activated.items():
if (aspec == self.s... |
'Unlinks all files from extension out of this package\'s install dir.
Package authors can override this method to support other
extension mechanisms. Spack internals (commands, hooks, etc.)
should call do_deactivate() method so that proper checks are
always executed.'
| def deactivate(self, extension, **kwargs):
| def ignore(filename):
return ((filename in spack.store.layout.hidden_file_paths) or kwargs.get('ignore', (lambda f: False))(filename))
tree = LinkTree(extension.prefix)
tree.unmerge(self.prefix, ignore=ignore)
|
'Reverts expanded/checked out source to a pristine state.'
| def do_restage(self):
| self.stage.restage()
|
'Removes the package\'s build stage and source tarball.'
| def do_clean(self):
| self.stage.destroy()
|
'Wrap doc string at 72 characters and format nicely'
| def format_doc(self, **kwargs):
| indent = kwargs.get('indent', 0)
if (not self.__doc__):
return ''
doc = re.sub('\\s+', ' ', self.__doc__)
lines = textwrap.wrap(doc, 72)
results = StringIO()
for line in lines:
results.write((((' ' * indent) + line) + '\n'))
return results.getvalue()
|
'Try to find remote versions of this package using the
list_url and any other URLs described in the package file.'
| def fetch_remote_versions(self):
| if (not self.all_urls):
raise VersionFetchError(self.__class__)
try:
return spack.util.web.find_versions_of_archive(self.all_urls, self.list_url, self.list_depth)
except spack.error.NoNetworkConnectionError as e:
tty.die("Package.fetch_versions couldn't connect to:", e.url, ... |
'Get the rpath this package links with, as a list of paths.'
| @property
def rpath(self):
| rpaths = [self.prefix.lib, self.prefix.lib64]
deps = self.spec.dependencies(deptype='link')
rpaths.extend((d.prefix.lib for d in deps if os.path.isdir(d.prefix.lib)))
rpaths.extend((d.prefix.lib64 for d in deps if os.path.isdir(d.prefix.lib64)))
return rpaths
|
'Get the rpath args as a string, with -Wl,-rpath, for each element'
| @property
def rpath_args(self):
| return ' '.join((('-Wl,-rpath,%s' % p) for p in self.rpath))
|
'Tries to call all the methods that are listed in the attribute
``build_time_test_callbacks`` if ``self.run_tests is True``.
If ``build_time_test_callbacks is None`` returns immediately.'
| @on_package_attributes(run_tests=True)
def _run_default_build_time_test_callbacks(self):
| if (self.build_time_test_callbacks is None):
return
for name in self.build_time_test_callbacks:
try:
fn = getattr(self, name)
tty.msg('RUN-TESTS: build-time tests [{0}]'.format(name))
fn()
except AttributeError:
msg = 'RUN-TESTS: ... |
'Tries to call all the methods that are listed in the attribute
``install_time_test_callbacks`` if ``self.run_tests is True``.
If ``install_time_test_callbacks is None`` returns immediately.'
| @on_package_attributes(run_tests=True)
def _run_default_install_time_test_callbacks(self):
| if (self.install_time_test_callbacks is None):
return
for name in self.install_time_test_callbacks:
try:
fn = getattr(self, name)
tty.msg('RUN-TESTS: install-time tests [{0}]'.format(name))
fn()
except AttributeError:
msg = 'RUN-TE... |
'Ensure RPATHs for root package are added.'
| def test_dep_rpath(self):
| self.check_cc('dump-args', test_command, ((((((((self.realcc + ' ') + '-Wl,-rpath,') + self.prefix) + '/lib ') + '-Wl,-rpath,') + self.prefix) + '/lib64 ') + ' '.join(test_command)))
|
'Ensure a single dependency include directory is added.'
| def test_dep_include(self):
| os.environ['SPACK_DEPENDENCIES'] = self.dep4
os.environ['SPACK_RPATH_DEPS'] = os.environ['SPACK_DEPENDENCIES']
os.environ['SPACK_LINK_DEPS'] = os.environ['SPACK_DEPENDENCIES']
self.check_cc('dump-args', test_command, (((((((((((self.realcc + ' ') + '-Wl,-rpath,') + self.prefix) + '/lib ') + '-Wl,-... |
'Ensure a single dependency RPATH is added.'
| def test_dep_lib(self):
| os.environ['SPACK_DEPENDENCIES'] = self.dep2
os.environ['SPACK_RPATH_DEPS'] = os.environ['SPACK_DEPENDENCIES']
os.environ['SPACK_LINK_DEPS'] = os.environ['SPACK_DEPENDENCIES']
self.check_cc('dump-args', test_command, ((((((((((((((self.realcc + ' ') + '-Wl,-rpath,') + self.prefix) + '/lib ') + '-W... |
'Ensure a single dependency link flag is added with no dep RPATH.'
| def test_dep_lib_no_rpath(self):
| os.environ['SPACK_DEPENDENCIES'] = self.dep2
os.environ['SPACK_LINK_DEPS'] = os.environ['SPACK_DEPENDENCIES']
self.check_cc('dump-args', test_command, (((((((((((self.realcc + ' ') + '-Wl,-rpath,') + self.prefix) + '/lib ') + '-Wl,-rpath,') + self.prefix) + '/lib64 ') + '-L') + self.dep2) + '/lib64... |
'Ensure a single dependency RPATH is added with no -L.'
| def test_dep_lib_no_lib(self):
| os.environ['SPACK_DEPENDENCIES'] = self.dep2
os.environ['SPACK_RPATH_DEPS'] = os.environ['SPACK_DEPENDENCIES']
self.check_cc('dump-args', test_command, (((((((((((self.realcc + ' ') + '-Wl,-rpath,') + self.prefix) + '/lib ') + '-Wl,-rpath,') + self.prefix) + '/lib64 ') + '-Wl,-rpath,') + self.dep2)... |
'Ensure includes and RPATHs for all deps are added.'
| def test_all_deps(self):
| os.environ['SPACK_DEPENDENCIES'] = ':'.join([self.dep1, self.dep2, self.dep3, self.dep4])
os.environ['SPACK_RPATH_DEPS'] = os.environ['SPACK_DEPENDENCIES']
os.environ['SPACK_LINK_DEPS'] = os.environ['SPACK_DEPENDENCIES']
self.check_cc('dump-args', test_command, (((((((((((((((((((((((((((((((((((self.re... |
'Ensure no (extra) -I args or -Wl, are passed in ld mode.'
| def test_ld_deps(self):
| os.environ['SPACK_DEPENDENCIES'] = ':'.join([self.dep1, self.dep2, self.dep3, self.dep4])
os.environ['SPACK_RPATH_DEPS'] = os.environ['SPACK_DEPENDENCIES']
os.environ['SPACK_LINK_DEPS'] = os.environ['SPACK_DEPENDENCIES']
self.check_ld('dump-args', test_command, ((((((((((((((((((((((((('ld ' + '-rpat... |
'Ensure SPACK_RPATH_DEPS controls RPATHs for ld.'
| def test_ld_deps_no_rpath(self):
| os.environ['SPACK_DEPENDENCIES'] = ':'.join([self.dep1, self.dep2, self.dep3, self.dep4])
os.environ['SPACK_LINK_DEPS'] = os.environ['SPACK_DEPENDENCIES']
self.check_ld('dump-args', test_command, (((((((((((((((('ld ' + '-rpath ') + self.prefix) + '/lib ') + '-rpath ') + self.prefix) + '/lib64 ... |
'Ensure SPACK_LINK_DEPS controls -L for ld.'
| def test_ld_deps_no_link(self):
| os.environ['SPACK_DEPENDENCIES'] = ':'.join([self.dep1, self.dep2, self.dep3, self.dep4])
os.environ['SPACK_RPATH_DEPS'] = os.environ['SPACK_DEPENDENCIES']
self.check_ld('dump-args', test_command, (((((((((((((((('ld ' + '-rpath ') + self.prefix) + '/lib ') + '-rpath ') + self.prefix) + '/lib64 ... |
'Make sure ld -r is handled correctly on OS\'s where it doesn\'t
support rpaths.'
| def test_ld_deps_reentrant(self):
| os.environ['SPACK_DEPENDENCIES'] = ':'.join([self.dep1])
os.environ['SPACK_RPATH_DEPS'] = os.environ['SPACK_DEPENDENCIES']
os.environ['SPACK_LINK_DEPS'] = os.environ['SPACK_DEPENDENCIES']
os.environ['SPACK_SHORT_SPEC'] = 'foo@1.2=linux-x86_64'
reentrant_test_command = (['-r'] + test_command)
sel... |
'Test preferred variants are applied correctly'
| def test_preferred_variants(self):
| update_packages('mpileaks', 'variants', '~debug~opt+shared+static')
assert_variant_values('mpileaks', debug=False, opt=False, shared=True, static=True)
update_packages('mpileaks', 'variants', ['+debug', '+opt', '~shared', '-static'])
assert_variant_values('mpileaks', debug=True, opt=True, shared=False, ... |
'Test preferred compilers are applied correctly'
| def test_preferred_compilers(self, refresh_builtin_mock):
| update_packages('mpileaks', 'compiler', ['clang@3.3'])
spec = concretize('mpileaks')
assert (spec.compiler == spack.spec.CompilerSpec('clang@3.3'))
update_packages('mpileaks', 'compiler', ['gcc@4.5.0'])
spec = concretize('mpileaks')
assert (spec.compiler == spack.spec.CompilerSpec('gcc@4.5.0'))
|
'Test preferred package versions are applied correctly'
| def test_preferred_versions(self):
| update_packages('mpileaks', 'version', ['2.3'])
spec = concretize('mpileaks')
assert (spec.version == spack.spec.Version('2.3'))
update_packages('mpileaks', 'version', ['2.2'])
spec = concretize('mpileaks')
assert (spec.version == spack.spec.Version('2.2'))
|
'Test preferred providers of virtual packages are
applied correctly'
| def test_preferred_providers(self):
| update_packages('all', 'providers', {'mpi': ['mpich']})
spec = concretize('mpileaks')
assert ('mpich' in spec)
update_packages('all', 'providers', {'mpi': ['zmpi']})
spec = concretize('mpileaks')
assert ('zmpi' in spec)
|
'Test concretization with develop version'
| def test_develop(self):
| spec = Spec('builtin.mock.develop-test')
spec.concretize()
assert (spec.version == spack.spec.Version('0.2.15'))
|
'Verify that virtuals are not allowed in packages.yaml.'
| def test_no_virtuals_in_packages_yaml(self):
| conf = syaml.load('mpi:\n paths:\n mpi-with-lapack@2.1: /path/to/lapack\n')
spack.config.update_config('packages', conf, 'concretize')
with pytest.raises(spack.package_prefs.VirtualInPackagesYAMLError):
spack.package_prefs.get_packages_config()
|
'Verify that `all` is allowed in packages.yaml.'
| def test_all_is_not_a_virtual(self):
| conf = syaml.load('all:\n variants: [+mpi]\n')
spack.config.update_config('packages', conf, 'concretize')
spack.package_prefs.PackagePrefs.clear_caches()
spack.package_prefs.get_packages_config()
|
'Ensure that <expected> is substituted properly for <var> in strings
containing <var> in various positions.'
| def check_canonical(self, var, expected):
| path = '/foo/bar/baz'
self.assertEqual(canonicalize_path((var + path)), (expected + path))
self.assertEqual(canonicalize_path((path + var)), ((path + '/') + expected))
self.assertEqual(canonicalize_path(((path + var) + path)), (expected + path))
|
'Make sure insufficient versions of MPI are not in providers list when
we ask for some advanced version.'
| def test_concretize_with_provides_when(self):
| repo = spack.repo
assert (not any((s.satisfies('mpich2@:1.0') for s in repo.providers_for('mpi@2.1'))))
assert (not any((s.satisfies('mpich2@:1.1') for s in repo.providers_for('mpi@2.2'))))
assert (not any((s.satisfies('mpich@:1') for s in repo.providers_for('mpi@2'))))
assert (not any((s.satisfies(... |
''
| def test_provides_handles_multiple_providers_of_same_vesrion(self):
| providers = spack.repo.providers_for('mpi@3.0')
assert (Spec('builtin.mock.multi-provider-mpi@1.10.3') in providers)
assert (Spec('builtin.mock.multi-provider-mpi@1.10.2') in providers)
assert (Spec('builtin.mock.multi-provider-mpi@1.10.1') in providers)
assert (Spec('builtin.mock.multi-provider-mpi... |
'Test a package with multiple virtual dependencies.'
| def test_concretize_two_virtuals(self):
| Spec('hypre').concretize()
|
'Test a package with multiple virtual dependencies and one preset.'
| def test_concretize_two_virtuals_with_one_bound(self, refresh_builtin_mock):
| Spec('hypre ^openblas').concretize()
|
'Test a package with multiple virtual deps and two of them preset.'
| def test_concretize_two_virtuals_with_two_bound(self):
| Spec('hypre ^openblas ^netlib-lapack').concretize()
|
'Test a package with multiple virtual dependencies and force a provider
that provides both.'
| def test_concretize_two_virtuals_with_dual_provider(self):
| Spec('hypre ^openblas-with-lapack').concretize()
|
'Test a package with multiple virtual dependencies and force a
provider that provides both, and another conflicting package that
provides one.'
| def test_concretize_two_virtuals_with_dual_provider_and_a_conflict(self):
| s = Spec('hypre ^openblas-with-lapack ^netlib-lapack')
with pytest.raises(spack.spec.MultipleProviderError):
s.concretize()
|
'Tests the spec finding logic used by concretization.'
| def test_find_spec_parents(self):
| s = Spec('a +foo', Spec('b +foo', Spec('c'), Spec('d +foo')), Spec('e +foo'))
assert ('a' == find_spec(s['b'], (lambda s: ('+foo' in s))).name)
|
'Assert that the provided spec is able to be parsed.
If this is called with one argument, it assumes that the
string is canonical (i.e., no spaces and ~ instead of - for
variants) and that it will convert back to the string it came
from.
If this is called with two arguments, the first argument is
the expected canonical... | def check_parse(self, expected, spec=None, remove_arch=True):
| if (spec is None):
spec = expected
output = sp.parse(spec)
parsed = ' '.join((str(spec) for spec in output))
assert (expected == parsed)
|
'Check that the provided spec parses to the provided token list.'
| def check_lex(self, tokens, spec):
| spec = shlex.split(spec)
lex_output = sp.SpecLexer().lex(spec)
for (tok, spec_tok) in zip(tokens, lex_output):
if ((tok.type == sp.ID) or (tok.type == sp.VAL)):
assert (tok == spec_tok)
else:
assert (tok.type == spec_tok.type)
|
'Check several ways to specify a spec by hash.'
| def _check_hash_parse(self, spec):
| self.check_parse(str(spec), ('/' + spec.dag_hash()))
self.check_parse(str(spec), ('/ ' + spec.dag_hash()[:5]))
self.check_parse(str(spec), ((spec.name + '/') + spec.dag_hash()))
self.check_parse(str(spec), ((((spec.name + '@') + str(spec.version)) + ' /') + spec.dag_hash()[:6]))
|
'Ensure we get errors for nonexistant hashes.'
| def test_nonexistent_hash(self, database):
| specs = database.mock.db.query()
no_such_hash = 'aaaaaaaaaaaaaaa'
hashes = [s._hash for s in specs]
assert (no_such_hash not in [h[:len(no_such_hash)] for h in hashes])
self._check_raises(NoSuchHashError, [('/' + no_such_hash), ('mpileaks /' + no_such_hash)])
|
'Check that redundant spec constraints raise errors.
TODO (TG): does this need to be an error? Or should concrete
specs only raise errors if constraints cause a contradiction?'
| def test_redundant_spec(self, database):
| mpileaks_zmpi = database.mock.db.query_one('mpileaks ^zmpi')
callpath_zmpi = database.mock.db.query_one('callpath ^zmpi')
dyninst = database.mock.db.query_one('dyninst')
mpileaks_mpich2 = database.mock.db.query_one('mpileaks ^mpich2')
redundant_specs = [((('/' + mpileaks_zmpi.dag_hash()) + ... |
'Make sure normalize can be run twice on the same spec,
and that it is idempotent.'
| def test_normalize_twice(self):
| spec = Spec('mpileaks')
spec.normalize()
n1 = spec.copy()
spec.normalize()
assert (n1 == spec)
|
'Ensure getting first n bits of a base32-encoded DAG hash works.'
| def test_hash_bits(self):
| b32 = dict(((j, i) for (i, j) in enumerate('abcdefghijklmnopqrstuvwxyz')))
b32.update(dict(((j, i) for (i, j) in enumerate('234567', 26))))
tests = ['35orsd4cenv743hg4i5vxha2lzayycby', '6kfqtj7dap3773rxog6kkmoweix5gpwo', 'e6h6ff3uvmjbq3azik2ckr6ckwm3depv', 'snz2juf4ij7sv77cq3vs467q6acftmur', '4eg47oedi5bbkh... |
'Make sure child and parent traversals of specs work.'
| def test_traversal_directions(self):
| d = Spec('d')
spec = Spec('a', Spec('b', Spec('c', d), Spec('e')), Spec('f', Spec('g', d)))
assert (['a', 'b', 'c', 'd', 'e', 'f', 'g'] == [s.name for s in spec.traverse(direction='children')])
assert (['g', 'f', 'a'] == [s.name for s in spec['g'].traverse(direction='parents')])
assert (['d', 'c', '... |
'Make sure child and parent traversals of specs work.'
| def test_edge_traversals(self):
| d = Spec('d')
spec = Spec('a', Spec('b', Spec('c', d), Spec('e')), Spec('f', Spec('g', d)))
assert (['a', 'b', 'c', 'd', 'e', 'f', 'g'] == [s.name for s in spec.traverse(direction='children')])
assert (['g', 'f', 'a'] == [s.name for s in spec['g'].traverse(direction='parents')])
assert (['d', 'c', '... |
'Ensure that it is possible to construct a spec with explicit
dependency types.'
| def test_construct_spec_with_deptypes(self):
| s = Spec('a', Spec('b', ['build'], Spec('c')), Spec('d', ['build', 'link'], Spec('e', ['run'], Spec('f'))))
assert (s['b']._dependencies['c'].deptypes == ('build',))
assert (s['d']._dependencies['e'].deptypes == ('build', 'link'))
assert (s['e']._dependencies['f'].deptypes == ('run',))
assert (s['b'... |
'Validate deptypes in dt-diamond spec.
This ensures that concretization works properly when two packages
depend on the same dependency in different ways.'
| def check_diamond_deptypes(self, spec):
| assert (spec['dt-diamond']._dependencies['dt-diamond-left'].deptypes == ('build', 'link'))
assert (spec['dt-diamond']._dependencies['dt-diamond-right'].deptypes == ('build', 'link'))
assert (spec['dt-diamond-left']._dependencies['dt-diamond-bottom'].deptypes == ('build',))
assert (spec['dt-diamond-right... |
'Ensure that dependency types are preserved even if the same thing is
depended on in two different ways.'
| def test_normalize_diamond_deptypes(self):
| s = Spec('dt-diamond')
s.normalize()
self.check_diamond_deptypes(s)
self.check_diamond_normalized_dag(s)
|
'Ensure that dependency types are preserved after concretization.'
| def test_concretize_deptypes(self):
| s = Spec('dt-diamond')
s.concretize()
self.check_diamond_deptypes(s)
|
'Ensure that dependency types are preserved by spec copy.'
| def test_copy_deptypes(self):
| s1 = Spec('dt-diamond')
s1.normalize()
self.check_diamond_deptypes(s1)
self.check_diamond_normalized_dag(s1)
s2 = s1.copy()
self.check_diamond_normalized_dag(s2)
self.check_diamond_deptypes(s2)
s3 = Spec('dt-diamond')
s3.concretize()
self.check_diamond_deptypes(s3)
s4 = s3.co... |
'Ensure spec from same or unspecified namespace satisfies namespace
constraint.'
| def test_satisfies_namespaced_dep(self):
| check_satisfies('mpileaks ^builtin.mock.mpich', '^mpich')
check_satisfies('mpileaks ^builtin.mock.mpich', '^mpi')
check_satisfies('mpileaks ^builtin.mock.mpich', '^builtin.mock.mpich')
check_unsatisfiable('mpileaks ^builtin.mock.mpich', '^builtin.mpich')
|
'Tests that the case reported in
https://github.com/LLNL/spack/pull/2386#issuecomment-282147639
is handled correctly.'
| def test_satisfies_single_valued_variant(self):
| a = Spec('a foobar=bar')
a.concretize()
assert a.satisfies('foobar=bar')
assert ('foobar=bar' in a)
assert ('foobar=baz' not in a)
assert ('foobar=fee' not in a)
assert ('foo=bar' in a)
assert ('^b' in a)
|
'Ensure we can satisfy virtual constraints when there are multiple
vdep providers in the specs.'
| def test_satisfies_virtual_dep_with_virtual_constraint(self):
| assert Spec('netlib-lapack ^openblas').satisfies('netlib-lapack ^openblas')
assert (not Spec('netlib-lapack ^netlib-blas').satisfies('netlib-lapack ^openblas'))
assert (not Spec('netlib-lapack ^openblas').satisfies('netlib-lapack ^netlib-blas'))
assert Spec('netlib-lapack ^netlib-bl... |
'Ensure that concrete specs are matched *exactly* by hash.'
| def test_satisfies_same_spec_with_different_hash(self):
| s1 = Spec('mpileaks').concretized()
s2 = s1.copy()
assert s1.satisfies(s2)
assert s2.satisfies(s1)
s2._hash = s1.dag_hash()[(-1)::(-1)]
assert (not s1.satisfies(s2))
assert (not s2.satisfies(s1))
|
'Write a colored edge to the output stream.'
| def _write_edge(self, string, index, sub=0):
| if (not self._frontier[index]):
return
name = self._frontier[index][sub]
edge = ('@%s{%s}' % (self._name_to_color[name], string))
self._out.write(edge)
|
'Connect dependencies to existing edges in the frontier.
``deps`` are to be inserted at position i in the
frontier. This routine determines whether other open edges
should be merged with <deps> (if there are other open edges
pointing to the same place) or whether they should just be
inserted as a completely new open ed... | def _connect_deps(self, i, deps, label=None):
| if ((len(deps) == 1) and (deps in self._frontier)):
j = self._frontier.index(deps)
if (i < j):
self._frontier.pop(j)
self._frontier.insert(i, deps)
return self._connect_deps(j, deps, label)
collapse = True
if (self._prev_state == EXPAND_RIGHT):
... |
'Write part of a backwards edge in the graph.
Writes single- or multi-line backward edges in an ascii graph.
For example, a single line edge::
| | | | o |
| | | |/ / <-- single-line edge connects two nodes.
| | | o |
Or a multi-line edge (requires two calls to back_edge)::
| | | | o |
| |_|_|/ / <-- multi-line edge ... | def _back_edge_line(self, prev_ends, end, start, collapse, label=None):
| def advance(to_pos, edges):
'Write edges up to <to_pos>.'
for i in range(self._pos, to_pos):
for e in edges():
self._write_edge(*e)
self._pos += 1
flen = len(self._frontier)
self._pos = 0
self._indent()
for p in prev_ends:
a... |
'Writes a line with a node at index.'
| def _node_line(self, index, name):
| self._indent()
for c in range(index):
self._write_edge('| ', c)
self._out.write(('%s ' % self.node_character))
for c in range((index + 1), len(self._frontier)):
self._write_edge('| ', c)
self._out.write((' %s' % name))
self._set_state(NODE, index)
self._out.write(... |
'Write a collapsing line after a node was added at index.'
| def _collapse_line(self, index):
| self._indent()
for c in range(index):
self._write_edge('| ', c)
for c in range(index, len(self._frontier)):
self._write_edge(' /', c)
self._set_state(COLLAPSE, index)
self._out.write('\n')
|
'Edge at index is same as edge to right. Merge directly with \'\''
| def _merge_right_line(self, index):
| self._indent()
for c in range(index):
self._write_edge('| ', c)
self._write_edge('|', index)
self._write_edge('\\', (index + 1))
for c in range((index + 1), len(self._frontier)):
self._write_edge('| ', c)
self._set_state(MERGE_RIGHT, index)
self._out.write('\n')
|
'Write out an ascii graph of the provided spec.
Arguments:
spec -- spec to graph. This only handles one spec at a time.
Optional arguments:
out -- file object to write out to (default is sys.stdout)
color -- whether to write in color. Default is to autodetect
based on output file.'
| def write(self, spec, color=None, out=None):
| if (out is None):
out = sys.stdout
if (color is None):
color = out.isatty()
self._out = ColorStream(out, color=color)
topo_order = topological_sort(spec, reverse=True, deptype=self.deptype)
spec = spec.copy()
self._nodes = spec.index()
self._name_to_color = dict(((name, self.... |
'Initializes a new instance, copying commands from other if not None
Args:
other: another instance of EnvironmentModifications (optional)'
| def __init__(self, other=None):
| self.env_modifications = []
if (other is not None):
self.extend(other)
|
'Stores in the current object a request to set an environment variable
Args:
name: name of the environment variable to be set
value: value of the environment variable'
| def set(self, name, value, **kwargs):
| kwargs.update(self._get_outside_caller_attributes())
item = SetEnv(name, value, **kwargs)
self.env_modifications.append(item)
|
'Stores in the current object a request to append to an env variable
Args:
name: name of the environment variable to be appended to
value: value to append to the environment variable
Appends with spaces separating different additions to the variable'
| def append_flags(self, name, value, sep=' ', **kwargs):
| kwargs.update(self._get_outside_caller_attributes())
kwargs.update({'separator': sep})
item = AppendFlagsEnv(name, value, **kwargs)
self.env_modifications.append(item)
|
'Stores in the current object a request to unset an environment variable
Args:
name: name of the environment variable to be set'
| def unset(self, name, **kwargs):
| kwargs.update(self._get_outside_caller_attributes())
item = UnsetEnv(name, **kwargs)
self.env_modifications.append(item)
|
'Stores a request to set a path generated from a list.
Args:
name: name o the environment variable to be set.
elts: elements of the path to set.'
| def set_path(self, name, elts, **kwargs):
| kwargs.update(self._get_outside_caller_attributes())
item = SetPath(name, elts, **kwargs)
self.env_modifications.append(item)
|
'Stores in the current object a request to append a path to a path list
Args:
name: name of the path list in the environment
path: path to be appended'
| def append_path(self, name, path, **kwargs):
| kwargs.update(self._get_outside_caller_attributes())
item = AppendPath(name, path, **kwargs)
self.env_modifications.append(item)
|
'Same as `append_path`, but the path is pre-pended
Args:
name: name of the path list in the environment
path: path to be pre-pended'
| def prepend_path(self, name, path, **kwargs):
| kwargs.update(self._get_outside_caller_attributes())
item = PrependPath(name, path, **kwargs)
self.env_modifications.append(item)
|
'Stores in the current object a request to remove a path from a path
list
Args:
name: name of the path list in the environment
path: path to be removed'
| def remove_path(self, name, path, **kwargs):
| kwargs.update(self._get_outside_caller_attributes())
item = RemovePath(name, path, **kwargs)
self.env_modifications.append(item)
|
'Returns a dict of the modifications grouped by variable name
Returns:
dict mapping the environment variable name to the modifications to
be done on it'
| def group_by_name(self):
| modifications = collections.defaultdict(list)
for item in self:
modifications[item.name].append(item)
return modifications
|
'Clears the current list of modifications'
| def clear(self):
| self.env_modifications.clear()
|
'Applies the modifications and clears the list'
| def apply_modifications(self):
| modifications = self.group_by_name()
for (name, actions) in sorted(modifications.items()):
for x in actions:
x.execute()
|
'Returns modifications that would be made by sourcing files.
Args:
*args (list of str): list of files to be sourced
Returns:
EnvironmentModifications: an object that, if executed, has
the same effect on the environment as sourcing the files
passed as parameters'
| @staticmethod
def from_sourcing_files(*args, **kwargs):
| env = EnvironmentModifications()
files = [line.split(' ')[0] for line in args]
non_existing = [file for file in files if (not os.path.isfile(file))]
if non_existing:
message = 'trying to source non-existing files\n'
message += '\n'.join(non_existing)
raise RuntimeE... |
'Writes the new package file.'
| def write(self, pkg_path):
| with open(pkg_path, 'w') as pkg_file:
pkg_file.write(package_template.format(name=self.name, class_name=self.class_name, base_class_name=self.base_class_name, url=self.url, versions=self.versions, dependencies=self.dependencies, body=self.body))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.