install/install_tree: glob support (#18376)

* install/install_tree: glob support

* Add unit tests

* Update existing packages

* Raise error if glob finds no files, document function raises
This commit is contained in:
Adam J. Stewart 2020-09-03 12:47:19 -05:00 committed by GitHub
parent 098beee295
commit 741bb9bafe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
48 changed files with 276 additions and 370 deletions

View File

@ -337,41 +337,63 @@ def unset_executable_mode(path):
def copy(src, dest, _permissions=False):
"""Copies the file *src* to the file or directory *dest*.
"""Copy the file(s) *src* to the file or directory *dest*.
If *dest* specifies a directory, the file will be copied into *dest*
using the base filename from *src*.
*src* may contain glob characters.
Parameters:
src (str): the file to copy
src (str): the file(s) to copy
dest (str): the destination file or directory
_permissions (bool): for internal use only
Raises:
IOError: if *src* does not match any files or directories
ValueError: if *src* matches multiple files but *dest* is
not a directory
"""
if _permissions:
tty.debug('Installing {0} to {1}'.format(src, dest))
else:
tty.debug('Copying {0} to {1}'.format(src, dest))
# Expand dest to its eventual full path if it is a directory.
if os.path.isdir(dest):
dest = join_path(dest, os.path.basename(src))
files = glob.glob(src)
if not files:
raise IOError("No such file or directory: '{0}'".format(src))
if len(files) > 1 and not os.path.isdir(dest):
raise ValueError(
"'{0}' matches multiple files but '{1}' is not a directory".format(
src, dest))
shutil.copy(src, dest)
for src in files:
# Expand dest to its eventual full path if it is a directory.
dst = dest
if os.path.isdir(dest):
dst = join_path(dest, os.path.basename(src))
if _permissions:
set_install_permissions(dest)
copy_mode(src, dest)
shutil.copy(src, dst)
if _permissions:
set_install_permissions(dst)
copy_mode(src, dst)
def install(src, dest):
"""Installs the file *src* to the file or directory *dest*.
"""Install the file(s) *src* to the file or directory *dest*.
Same as :py:func:`copy` with the addition of setting proper
permissions on the installed file.
Parameters:
src (str): the file to install
src (str): the file(s) to install
dest (str): the destination file or directory
Raises:
IOError: if *src* does not match any files or directories
ValueError: if *src* matches multiple files but *dest* is
not a directory
"""
copy(src, dest, _permissions=True)
@ -396,6 +418,8 @@ def copy_tree(src, dest, symlinks=True, ignore=None, _permissions=False):
If the destination directory *dest* does not already exist, it will
be created as well as missing parent directories.
*src* may contain glob characters.
If *symlinks* is true, symbolic links in the source tree are represented
as symbolic links in the new tree and the metadata of the original links
will be copied as far as the platform allows; if false, the contents and
@ -410,56 +434,66 @@ def copy_tree(src, dest, symlinks=True, ignore=None, _permissions=False):
symlinks (bool): whether or not to preserve symlinks
ignore (function): function indicating which files to ignore
_permissions (bool): for internal use only
Raises:
IOError: if *src* does not match any files or directories
ValueError: if *src* is a parent directory of *dest*
"""
if _permissions:
tty.debug('Installing {0} to {1}'.format(src, dest))
else:
tty.debug('Copying {0} to {1}'.format(src, dest))
abs_src = os.path.abspath(src)
if not abs_src.endswith(os.path.sep):
abs_src += os.path.sep
abs_dest = os.path.abspath(dest)
if not abs_dest.endswith(os.path.sep):
abs_dest += os.path.sep
# Stop early to avoid unnecessary recursion if being asked to copy from a
# parent directory.
if abs_dest.startswith(abs_src):
raise ValueError('Cannot copy ancestor directory {0} into {1}'.
format(abs_src, abs_dest))
files = glob.glob(src)
if not files:
raise IOError("No such file or directory: '{0}'".format(src))
mkdirp(dest)
for src in files:
abs_src = os.path.abspath(src)
if not abs_src.endswith(os.path.sep):
abs_src += os.path.sep
for s, d in traverse_tree(abs_src, abs_dest, order='pre',
follow_symlinks=not symlinks,
ignore=ignore,
follow_nonexisting=True):
if os.path.islink(s):
link_target = resolve_link_target_relative_to_the_link(s)
if symlinks:
target = os.readlink(s)
if os.path.isabs(target):
new_target = re.sub(abs_src, abs_dest, target)
if new_target != target:
tty.debug("Redirecting link {0} to {1}"
.format(target, new_target))
target = new_target
# Stop early to avoid unnecessary recursion if being asked to copy
# from a parent directory.
if abs_dest.startswith(abs_src):
raise ValueError('Cannot copy ancestor directory {0} into {1}'.
format(abs_src, abs_dest))
os.symlink(target, d)
elif os.path.isdir(link_target):
mkdirp(d)
mkdirp(abs_dest)
for s, d in traverse_tree(abs_src, abs_dest, order='pre',
follow_symlinks=not symlinks,
ignore=ignore,
follow_nonexisting=True):
if os.path.islink(s):
link_target = resolve_link_target_relative_to_the_link(s)
if symlinks:
target = os.readlink(s)
if os.path.isabs(target):
new_target = re.sub(abs_src, abs_dest, target)
if new_target != target:
tty.debug("Redirecting link {0} to {1}"
.format(target, new_target))
target = new_target
os.symlink(target, d)
elif os.path.isdir(link_target):
mkdirp(d)
else:
shutil.copyfile(s, d)
else:
shutil.copyfile(s, d)
else:
if os.path.isdir(s):
mkdirp(d)
else:
shutil.copy2(s, d)
if os.path.isdir(s):
mkdirp(d)
else:
shutil.copy2(s, d)
if _permissions:
set_install_permissions(d)
copy_mode(s, d)
if _permissions:
set_install_permissions(d)
copy_mode(s, d)
def install_tree(src, dest, symlinks=True, ignore=None):
@ -473,6 +507,10 @@ def install_tree(src, dest, symlinks=True, ignore=None):
dest (str): the destination directory
symlinks (bool): whether or not to preserve symlinks
ignore (function): function indicating which files to ignore
Raises:
IOError: if *src* does not match any files or directories
ValueError: if *src* is a parent directory of *dest*
"""
copy_tree(src, dest, symlinks=symlinks, ignore=ignore, _permissions=True)

View File

@ -30,6 +30,9 @@ def stage(tmpdir_factory):
fs.touchp('source/c/d/5')
fs.touchp('source/c/d/6')
fs.touchp('source/c/d/e/7')
fs.touchp('source/g/h/i/8')
fs.touchp('source/g/h/i/9')
fs.touchp('source/g/i/j/10')
# Create symlinks
os.symlink(os.path.abspath('source/1'), 'source/2')
@ -61,6 +64,31 @@ def test_dir_dest(self, stage):
assert os.path.exists('dest/1')
def test_glob_src(self, stage):
"""Test using a glob as the source."""
with fs.working_dir(str(stage)):
fs.copy('source/a/*/*', 'dest')
assert os.path.exists('dest/2')
assert os.path.exists('dest/3')
def test_non_existing_src(self, stage):
"""Test using a non-existing source."""
with fs.working_dir(str(stage)):
with pytest.raises(IOError, match='No such file or directory'):
fs.copy('source/none', 'dest')
def test_multiple_src_file_dest(self, stage):
"""Test a glob that matches multiple source files and a dest
that is not a directory."""
with fs.working_dir(str(stage)):
match = '.* matches multiple files but .* is not a directory'
with pytest.raises(ValueError, match=match):
fs.copy('source/a/*/*', 'dest/1')
def check_added_exe_permissions(src, dst):
src_mode = os.stat(src).st_mode
@ -91,6 +119,33 @@ def test_dir_dest(self, stage):
assert os.path.exists('dest/1')
check_added_exe_permissions('source/1', 'dest/1')
def test_glob_src(self, stage):
"""Test using a glob as the source."""
with fs.working_dir(str(stage)):
fs.install('source/a/*/*', 'dest')
assert os.path.exists('dest/2')
assert os.path.exists('dest/3')
check_added_exe_permissions('source/a/b/2', 'dest/2')
check_added_exe_permissions('source/a/b/3', 'dest/3')
def test_non_existing_src(self, stage):
"""Test using a non-existing source."""
with fs.working_dir(str(stage)):
with pytest.raises(IOError, match='No such file or directory'):
fs.install('source/none', 'dest')
def test_multiple_src_file_dest(self, stage):
"""Test a glob that matches multiple source files and a dest
that is not a directory."""
with fs.working_dir(str(stage)):
match = '.* matches multiple files but .* is not a directory'
with pytest.raises(ValueError, match=match):
fs.install('source/a/*/*', 'dest/1')
class TestCopyTree:
"""Tests for ``filesystem.copy_tree``"""
@ -111,21 +166,6 @@ def test_non_existing_dir(self, stage):
assert os.path.exists('dest/sub/directory/a/b/2')
def test_parent_dir(self, stage):
"""Test copying to from a parent directory."""
# Make sure we get the right error if we try to copy a parent into
# a descendent directory.
with pytest.raises(ValueError, match="Cannot copy"):
with fs.working_dir(str(stage)):
fs.copy_tree('source', 'source/sub/directory')
# Only point with this check is to make sure we don't try to perform
# the copy.
with pytest.raises(IOError, match="No such file or directory"):
with fs.working_dir(str(stage)):
fs.copy_tree('foo/ba', 'foo/bar')
def test_symlinks_true(self, stage):
"""Test copying with symlink preservation."""
@ -162,6 +202,31 @@ def test_symlinks_false(self, stage):
assert os.path.exists('dest/2')
assert not os.path.islink('dest/2')
def test_glob_src(self, stage):
"""Test using a glob as the source."""
with fs.working_dir(str(stage)):
fs.copy_tree('source/g/*', 'dest')
assert os.path.exists('dest/i/8')
assert os.path.exists('dest/i/9')
assert os.path.exists('dest/j/10')
def test_non_existing_src(self, stage):
"""Test using a non-existing source."""
with fs.working_dir(str(stage)):
with pytest.raises(IOError, match='No such file or directory'):
fs.copy_tree('source/none', 'dest')
def test_parent_dir(self, stage):
"""Test source as a parent directory of destination."""
with fs.working_dir(str(stage)):
match = 'Cannot copy ancestor directory'
with pytest.raises(ValueError, match=match):
fs.copy_tree('source', 'source/sub/directory')
class TestInstallTree:
"""Tests for ``filesystem.install_tree``"""
@ -173,6 +238,7 @@ def test_existing_dir(self, stage):
fs.install_tree('source', 'dest')
assert os.path.exists('dest/a/b/2')
check_added_exe_permissions('source/a/b/2', 'dest/a/b/2')
def test_non_existing_dir(self, stage):
"""Test installing to a non-existing directory."""
@ -181,6 +247,8 @@ def test_non_existing_dir(self, stage):
fs.install_tree('source', 'dest/sub/directory')
assert os.path.exists('dest/sub/directory/a/b/2')
check_added_exe_permissions(
'source/a/b/2', 'dest/sub/directory/a/b/2')
def test_symlinks_true(self, stage):
"""Test installing with symlink preservation."""
@ -190,6 +258,7 @@ def test_symlinks_true(self, stage):
assert os.path.exists('dest/2')
assert os.path.islink('dest/2')
check_added_exe_permissions('source/2', 'dest/2')
def test_symlinks_false(self, stage):
"""Test installing without symlink preservation."""
@ -199,6 +268,35 @@ def test_symlinks_false(self, stage):
assert os.path.exists('dest/2')
assert not os.path.islink('dest/2')
check_added_exe_permissions('source/2', 'dest/2')
def test_glob_src(self, stage):
"""Test using a glob as the source."""
with fs.working_dir(str(stage)):
fs.install_tree('source/g/*', 'dest')
assert os.path.exists('dest/i/8')
assert os.path.exists('dest/i/9')
assert os.path.exists('dest/j/10')
check_added_exe_permissions('source/g/h/i/8', 'dest/i/8')
check_added_exe_permissions('source/g/h/i/9', 'dest/i/9')
check_added_exe_permissions('source/g/i/j/10', 'dest/j/10')
def test_non_existing_src(self, stage):
"""Test using a non-existing source."""
with fs.working_dir(str(stage)):
with pytest.raises(IOError, match='No such file or directory'):
fs.install_tree('source/none', 'dest')
def test_parent_dir(self, stage):
"""Test source as a parent directory of destination."""
with fs.working_dir(str(stage)):
match = 'Cannot copy ancestor directory'
with pytest.raises(ValueError, match=match):
fs.install_tree('source', 'source/sub/directory')
def test_paths_containing_libs(dirs_with_libfiles):

View File

@ -3,8 +3,6 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
import glob
import os
import sys
@ -34,9 +32,7 @@ def install(self, spec, prefix):
mkdirp(prefix.lib)
install(name, prefix.lib)
mkdirp(prefix.include)
headers = glob.glob('*.h')
for h in headers:
install(h, prefix.include)
install('*.h', prefix.include)
@run_after('install')
def fix_darwin_install(self):

View File

@ -3,9 +3,6 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
import glob
class Amrvis(MakefilePackage):
"""Amrvis is a visualization package specifically designed to
@ -198,6 +195,4 @@ def setup_build_environment(self, env):
def install(self, spec, prefix):
# Install exe manually
mkdirp(prefix.bin)
exes = glob.iglob('*.ex')
for exe in exes:
install(exe, prefix.bin)
install('*.ex', prefix.bin)

View File

@ -3,9 +3,6 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
import glob
class Aspa(MakefilePackage):
"""A fundamental premise in ExMatEx is that scale-bridging performed in
@ -52,5 +49,4 @@ def install(self, spec, prefix):
install('exec/kriging_model_centers.txt', prefix.input)
install('exec/point_data.txt', prefix.input)
install('exec/value_data.txt', prefix.input)
for files in glob.glob('doc/*.*'):
install(files, prefix.doc)
install('doc/*.*', prefix.doc)

View File

@ -3,9 +3,6 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
import glob
class Bcftools(AutotoolsPackage):
"""BCFtools is a set of utilities that manipulate variant calls in the
@ -99,8 +96,7 @@ def install(self, spec, prefix):
if spec.satisfies('@1.2'):
mkdirp(self.prefix.libexec.bcftools)
for files in glob.glob('plugins/*.so'):
install(files, self.prefix.libexec.bcftools)
install('plugins/*.so', self.prefix.libexec.bcftools)
@when('@1.2')
def setup_run_environment(self, env):

View File

@ -3,9 +3,6 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
from glob import glob
class Bib2xhtml(Package):
"""bib2xhtml is a program that converts BibTeX files into HTML."""
@ -18,8 +15,7 @@ def install(self, spec, prefix):
# Add the bst include files to the install directory
bst_include = join_path(prefix.share, 'bib2xhtml')
mkdirp(bst_include)
for bstfile in glob('html-*bst'):
install(bstfile, bst_include)
install('html-*bst', bst_include)
# Install the script and point it at the user's favorite perl
# and the bst include directory.

View File

@ -3,8 +3,6 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
import glob
import sys
@ -115,9 +113,8 @@ def install_headers(self):
# grab the full binutils set of headers
install_tree('include', extradir)
# also grab the headers from the bfd directory
for current_file in glob.glob(join_path(self.build_directory,
'bfd', '*.h')):
install(current_file, extradir)
install(join_path(self.build_directory, 'bfd', '*.h'),
extradir)
def flag_handler(self, name, flags):
# To ignore the errors of narrowing conversions for

View File

@ -3,9 +3,6 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
from glob import glob
class Bowtie2(Package):
"""Bowtie 2 is an ultrafast and memory-efficient tool for aligning
@ -71,14 +68,4 @@ def install(self, spec, prefix):
make_arg.append('POPCNT_CAPABILITY=0')
make(*make_arg)
mkdirp(prefix.bin)
for bow in glob("bowtie2*"):
install(bow, prefix.bin)
# install('bowtie2',prefix.bin)
# install('bowtie2-align-l',prefix.bin)
# install('bowtie2-align-s',prefix.bin)
# install('bowtie2-build',prefix.bin)
# install('bowtie2-build-l',prefix.bin)
# install('bowtie2-build-s',prefix.bin)
# install('bowtie2-inspect',prefix.bin)
# install('bowtie2-inspect-l',prefix.bin)
# install('bowtie2-inspect-s',prefix.bin)
install('bowtie2*', prefix.bin)

View File

@ -3,8 +3,6 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
import os
import glob
@ -48,10 +46,7 @@ def install(self, spec, prefix):
install_tree('example', prefix.example)
with working_dir('scripts'):
install('helpMod.pm', prefix.lib)
files = glob.iglob('*.pl')
for file in files:
if os.path.isfile(file):
install(file, prefix.bin)
install('*.pl', prefix.bin)
@run_after('install')
def filter_sbang(self):

View File

@ -3,9 +3,6 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
import glob
class Chombo(MakefilePackage):
"""The Chombo package provides a set of tools for implementing finite
@ -109,9 +106,7 @@ def build(self, spec, prefix):
def install(self, spec, prefix):
with working_dir('lib'):
install_tree('include', prefix.include)
libfiles = glob.glob('lib*.a')
libfiles += glob.glob('lib*.so')
libfiles += glob.glob('lib*.dylib')
mkdirp(prefix.lib)
for lib in libfiles:
install(lib, prefix.lib)
install('lib*.a', prefix.lib)
install('lib*.so', prefix.lib)
install('lib*.dylib', prefix.lib)

View File

@ -4,11 +4,6 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import glob
from spack import *
class Cloverleaf(MakefilePackage):
"""Proxy Application. CloverLeaf is a miniapp that solves the
compressible Euler equations on a Cartesian grid,
@ -95,7 +90,5 @@ def install(self, spec, prefix):
prefix.bin)
install('CloverLeaf_{0}/clover.in'.format(self.type_of_build),
prefix.bin)
for f in glob.glob(
'CloverLeaf_{0}/*.in'.format(self.type_of_build)):
install(f, prefix.doc.tests)
install('CloverLeaf_{0}/*.in'.format(self.type_of_build),
prefix.doc.tests)

View File

@ -4,11 +4,6 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import glob
from spack import *
class Cloverleaf3d(MakefilePackage):
"""Proxy Application. CloverLeaf3D is 3D version of the
CloverLeaf mini-app. CloverLeaf is a mini-app that solves
@ -78,7 +73,5 @@ def install(self, spec, prefix):
prefix.bin)
install('CloverLeaf3D_{0}/clover.in'.format(self.type_of_build),
prefix.bin)
for f in glob.glob(
'CloverLeaf3D_{0}/*.in'.format(self.type_of_build)):
install(f, prefix.doc.samples)
install('CloverLeaf3D_{0}/*.in'.format(self.type_of_build),
prefix.doc.samples)

View File

@ -3,9 +3,6 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
import glob
class Cohmm(MakefilePackage):
"""An anticipated important use-case for next-generation supercomputing
@ -37,5 +34,4 @@ def install(self, spec, prefix):
install('cohmm', prefix.bin)
install('README.md', prefix.doc)
install('LICENSE.md', prefix.doc)
for files in glob.glob('input/*.*'):
install(files, prefix.input)
install('input/*.*', prefix.input)

View File

@ -3,9 +3,6 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
import glob
class Efivar(MakefilePackage):
"""Tools and libraries to work with EFI variables"""
@ -22,7 +19,5 @@ class Efivar(MakefilePackage):
def install(self, spec, prefix):
with working_dir(self.build_directory):
mkdirp(prefix.lib)
files = glob.glob('*.so*')
for f in files:
install(f, prefix.lib)
install('*.so*', prefix.lib)
install_tree('include/efivar', prefix.include)

View File

@ -3,9 +3,6 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
import glob
class Exasp2(MakefilePackage):
"""ExaSP2 is a reference implementation of typical linear algebra algorithms
@ -70,7 +67,6 @@ def build_targets(self):
def install(self, spec, prefix):
mkdir(prefix.bin)
mkdir(prefix.doc)
for files in glob.glob('bin/ExaSP2-*'):
install(files, prefix.bin)
install('bin/ExaSP2-*', prefix.bin)
install('LICENSE.md', prefix.doc)
install('README.md', prefix.doc)

View File

@ -4,8 +4,6 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os.path
import glob
from spack import *
class Gatk(Package):
@ -61,8 +59,7 @@ def install(self, spec, prefix):
# For ver 3.x will install "GenomeAnalysisTK.jar"
# For ver 4.x will install both "gatk-package-<ver>-local.jar"
# and "gatk-package-<ver>-spark.jar"
for file in glob.glob("*.jar"):
install(file, prefix.bin)
install("*.jar", prefix.bin)
# Skip helper script for versions >4.0
if spec.satisfies("@4.0:"):

View File

@ -3,8 +3,6 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
from glob import glob
import os
@ -39,5 +37,4 @@ def install(self, spec, prefix):
install('nanobenchmark_example', prefix.bin)
install('vector_test', prefix.bin)
install('sip_hash_test', prefix.bin)
for i in glob('highwayhash/*.h'):
install(i, prefix.include)
install('highwayhash/*.h', prefix.include)

View File

@ -3,10 +3,6 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
import glob
import os.path
class Hisat2(MakefilePackage):
"""HISAT2 is a fast and sensitive alignment program for mapping
@ -40,10 +36,7 @@ def install(self, spec, prefix):
install('hisat2-inspect', prefix.bin)
install('hisat2-inspect-s', prefix.bin)
install('hisat2-inspect-l', prefix.bin)
files = glob.iglob('*.py')
for file in files:
if os.path.isfile(file):
install(file, prefix.bin)
install('*.py', prefix.bin)
def setup_run_environment(self, env):
env.prepend_path('PATH', self.spec.prefix)

View File

@ -3,10 +3,6 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
import glob
import os
class Hybpiper(Package):
"""HybPiper was designed for targeted sequence capture, in which DNA
@ -36,7 +32,4 @@ def setup_run_environment(self, env):
def install(self, spec, prefix):
mkdirp(prefix.bin)
files = glob.iglob("*.py")
for file in files:
if os.path.isfile(file):
install(file, prefix.bin)
install('*.py', prefix.bin)

View File

@ -3,9 +3,6 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
import glob
class Iniparser(MakefilePackage):
"""This modules offers parsing of ini files from the C level."""
@ -20,9 +17,6 @@ class Iniparser(MakefilePackage):
def install(self, spec, prefix):
mkdirp(prefix.include)
with working_dir('src'):
for files in glob.glob('*.h'):
install(files, prefix.include)
mkdirp(prefix.lib)
for files in glob.glob('libiniparser.*'):
install(files, prefix.lib)
install('src/*.h', prefix.include)
install('libiniparser.*', prefix.lib)

View File

@ -205,13 +205,11 @@ def install(self, spec, prefix):
for lib_name in tbb_lib_names:
# install release libs
fs = glob.glob(join_path("build", "*release", lib_name + ".*"))
for f in fs:
install(f, prefix.lib)
install(join_path("build", "*release", lib_name + ".*"),
prefix.lib)
# install debug libs if they exist
fs = glob.glob(join_path("build", "*debug", lib_name + "_debug.*"))
for f in fs:
install(f, prefix.lib)
install(join_path("build", "*debug", lib_name + "_debug.*"),
prefix.lib)
if spec.satisfies('@2017.8,2018.1:', strict=True):
# Generate and install the CMake Config file.

View File

@ -3,8 +3,6 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
import glob
import os
@ -87,23 +85,17 @@ def install(self, spec, prefix):
mkdirp(prefix.lib)
mkdirp(prefix.bin)
libs = glob.glob(join_path('obj', 'lib*.a'))
for lib in libs:
install(lib, prefix.lib)
install(join_path('obj', 'lib*.a'), prefix.lib)
# Build and install shared libxed.so and examples (to get the CLI).
mfile('--clean')
mfile('examples', '--shared', *args)
libs = glob.glob(join_path('obj', 'lib*.so'))
for lib in libs:
install(lib, prefix.lib)
install(join_path('obj', 'lib*.so'), prefix.lib)
# Install the xed program
install(join_path('obj', 'examples', 'xed'), prefix.bin)
# Install header files.
hdrs = glob.glob(join_path('include', 'public', 'xed', '*.h')) \
+ glob.glob(join_path('obj', '*.h'))
for hdr in hdrs:
install(hdr, prefix.include)
install(join_path('include', 'public', 'xed', '*.h'), prefix.include)
install(join_path('obj', '*.h'), prefix.include)

View File

@ -3,11 +3,8 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import glob
import os
from spack import *
class Ioapi(MakefilePackage):
"""Models-3/EDSS Input/Output Applications Programming Interface."""
@ -34,11 +31,7 @@ def install(self, spec, prefix):
make('install')
# Install the header files.
mkdirp(prefix.include.fixed132)
headers = glob.glob('ioapi/*.EXT')
for header in headers:
install(header, prefix.include)
install('ioapi/*.EXT', prefix.include)
# Install the header files for CMAQ and SMOKE in the
# non-standard -ffixed-line-length-132 format.
headers_fixed132 = glob.glob('ioapi/fixed_src/*.EXT')
for header in headers_fixed132:
install(header, prefix.include.fixed132)
install('ioapi/fixed_src/*.EXT', prefix.include.fixed132)

View File

@ -3,9 +3,6 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
import glob
class Keyutils(MakefilePackage):
"""These tools are used to control the key management system built
@ -22,6 +19,4 @@ class Keyutils(MakefilePackage):
def install(self, spec, prefix):
install_tree('.', prefix)
mkdirp(prefix.include)
headers = glob.glob(join_path(prefix, '*.h'))
for h in headers:
install(h, prefix.include)
install(join_path(prefix, '*.h'), prefix.include)

View File

@ -3,9 +3,6 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import glob
from spack import *
class Leveldb(CMakePackage):
"""LevelDB is a fast key-value storage library written at Google
@ -52,13 +49,10 @@ def install(self, spec, prefix):
mkdirp(prefix.lib)
# Needed for version 1.20
libraries = glob.glob('out-shared/libleveldb.*')
libraries += glob.glob('out-static/libleveldb.*')
install('out-shared/libleveldb.*', prefix.lib)
install('out-static/libleveldb.*', prefix.lib)
# Needed for version 1.18
libraries += glob.glob('libleveldb.*')
for library in libraries:
install(library, prefix.lib)
install('libleveldb.*', prefix.lib)
install_tree('include', prefix.include)

View File

@ -3,9 +3,6 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
import glob
class Librom(AutotoolsPackage):
"""libROM: library for computing large-scale reduced order models"""
@ -42,16 +39,15 @@ def configure_args(self):
# TODO(oxberry1@llnl.gov): Submit PR upstream that implements
# install phase in autotools
def install(self, spec, prefix):
mkdirp(self.spec.prefix.lib)
install('libROM.a', join_path(self.spec.prefix.lib, 'libROM.a'))
mkdirp(prefix.lib)
install('libROM.a', join_path(prefix.lib, 'libROM.a'))
mkdirp(self.spec.prefix.include)
for f in glob.glob('*.h'):
install(f, join_path(self.spec.prefix.include, f))
mkdirp(prefix.include)
install('*.h', prefix.include)
mkdirp(self.spec.prefix.share)
mkdirp(prefix.share)
install('libROM_Design_and_Theory.pdf',
join_path(self.spec.prefix.share,
join_path(prefix.share,
'libROM_Design_and_Theory.pdf'))
install_tree('docs', self.spec.prefix.share.docs)
install_tree('docs', prefix.share.docs)

View File

@ -113,10 +113,8 @@ def install(self, spec, prefix):
install_tree('bin', prefix.bin)
mkdirp(prefix.doc)
for doc_file in glob(join_path('documentation', '*.md')):
install(doc_file, prefix.doc)
for doc_file in glob(join_path('documentation', '*.pdf')):
install(doc_file, prefix.doc)
install(join_path('documentation', '*.md'), prefix.doc)
install(join_path('documentation', '*.pdf'), prefix.doc)
if '@1.8.2:' in spec:
install('LICENSE.md', prefix.doc)
else:

View File

@ -5,7 +5,6 @@
from spack import *
import glob
import sys
import os
@ -101,8 +100,7 @@ def install(self, spec, prefix):
install('libmetis.a', prefix.lib)
mkdir(prefix.include)
for h in glob.glob(join_path('Lib', '*.h')):
install(h, prefix.include)
install(join_path('Lib', '*.h'), prefix.include)
mkdir(prefix.share)
sharefiles = (('Graphs', '4elt.graph'), ('Graphs', 'metis.mesh'),
@ -203,9 +201,7 @@ def install(self, spec, prefix):
# install GKlib headers, which will be needed for ParMETIS
gklib_dist = join_path(prefix.include, 'GKlib')
mkdirp(gklib_dist)
hfiles = glob.glob(join_path(source_directory, 'GKlib', '*.h'))
for hfile in hfiles:
install(hfile, gklib_dist)
install(join_path(source_directory, 'GKlib', '*.h'), gklib_dist)
if self.run_tests:
# FIXME: On some systems, the installed binaries for METIS cannot

View File

@ -3,9 +3,6 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
import glob
class Minigmg(Package):
"""miniGMG is a compact benchmark for understanding the performance
@ -43,6 +40,4 @@ def install(self, spec, prefix):
mkdir(prefix.bin)
install('run.miniGMG', prefix.bin)
mkdir(prefix.jobs)
files = glob.glob('job*')
for f in files:
install(f, prefix.jobs)
install('job*', prefix.jobs)

View File

@ -3,12 +3,8 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import glob
import tarfile
from spack import *
class Minimd(MakefilePackage):
"""Proxy Application. A simple proxy for the force computations
@ -52,6 +48,4 @@ def install(self, spec, prefix):
install('miniMD_ref/miniMD_mpi', prefix.bin)
install('miniMD_ref/in.lj.miniMD', prefix.bin)
install('miniMD_ref/README', prefix.doc)
for f in glob.glob('miniMD_ref/in.*'):
install(f, prefix.doc)
install('miniMD_ref/in.*', prefix.doc)

View File

@ -3,9 +3,6 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
from glob import glob
class Motioncor2(Package):
"""MotionCor2 is a multi-GPU program that corrects beam-induced sample
@ -34,7 +31,6 @@ class Motioncor2(Package):
def install(self, spec, prefix):
mkdirp(prefix.bin)
for files in glob("MotionCor2_*"):
install(files, prefix.bin)
install('MotionCor2_*', prefix.bin)
with working_dir(prefix.bin):
symlink('MotionCor2_{0}'.format(spec.version), 'MotionCor2')

View File

@ -3,10 +3,8 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
import os
import sys
import glob
class Mumps(Package):
@ -277,8 +275,7 @@ def install(self, spec, prefix):
lib_dsuffix = '.dylib' if sys.platform == 'darwin' else '.so'
lib_suffix = lib_dsuffix if '+shared' in spec else '.a'
install('libseq/libmpiseq%s' % lib_suffix, prefix.lib)
for f in glob.glob(join_path('libseq', '*.h')):
install(f, prefix.include)
install(join_path('libseq', '*.h'), prefix.include)
# FIXME: extend the tests to mpirun -np 2 when build with MPI
# FIXME: use something like numdiff to compare output files

View File

@ -3,9 +3,6 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
import glob
class Openmx(MakefilePackage):
"""OpenMX (Open source package for Material eXplorer) is a software
@ -36,10 +33,7 @@ class Openmx(MakefilePackage):
def edit(self, spec, prefix):
# Move contents to source/
# http://www.openmx-square.org/bugfixed/18June12/README.txt
patch_files = []
patch_files = glob.glob('./patch/*')
for f in patch_files:
copy(f, './source')
copy_tree('patch', 'source')
makefile = FileFilter('./source/makefile')
makefile.filter('^DESTDIR.*$', 'DESTDIR = {0}/bin'.format(prefix))

View File

@ -3,9 +3,6 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
import glob
class Opennurbs(Package):
"""OpenNURBS is an open-source NURBS-based geometric modeling library
@ -49,6 +46,4 @@ def install(self, spec, prefix):
mkdir(prefix.include)
install('libopenNURBS.a', prefix.lib)
install_tree('zlib', join_path(prefix.include, 'zlib'))
headers = glob.glob(join_path('.', '*.h'))
for h in headers:
install(h, prefix.include)
install('*.h', prefix.include)

View File

@ -3,9 +3,6 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
from glob import glob
class PerlStarFusion(Package):
"""STAR-Fusion is a component of the Trinity Cancer Transcriptome Analysis
@ -29,12 +26,7 @@ class PerlStarFusion(Package):
depends_on('perl-uri', type=('build', 'run'))
def install(self, spec, prefix):
mkdirp(prefix.bin)
install('STAR-Fusion', prefix.bin)
mkdirp(perl_lib_dir)
with working_dir('PerlLib'):
for pm in glob("*.pm"):
install(pm, perl_lib_dir)
with working_dir('util'):
for files in glob("*"):
install(files, prefix.bin)
install(join_path('PerlLib', '*.pm'), perl_lib_dir)
install_tree('util', prefix.bin)
install('STAR-Fusion', prefix.bin)

View File

@ -4,11 +4,6 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
# adapted from official quantum espresso package
import glob
import os.path
from spack import *
class QESirius(Package):
"""SIRIUS enabled fork of QuantumESPRESSO. """
@ -266,7 +261,7 @@ def install(self, spec, prefix):
# Compute the include directory from there: versions
# of espresso prior to 6.1 requires -I in front of the directory
elpa_include = '' if '@6.1:' in spec else '-I'
elpa_include += os.path.join(
elpa_include += join_path(
elpa.headers.directories[0],
'modules'
)
@ -310,7 +305,6 @@ def install(self, spec, prefix):
if 'platform=darwin' in spec:
mkdirp(prefix.bin)
for filename in glob.glob("bin/*.x"):
install(filename, prefix.bin)
install('bin/*.x', prefix.bin)
else:
make('install')

View File

@ -3,11 +3,6 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import glob
import os.path
from spack import *
class QuantumEspresso(Package):
"""Quantum ESPRESSO is an integrated suite of Open-Source computer codes
@ -325,7 +320,7 @@ def install(self, spec, prefix):
# Compute the include directory from there: versions
# of espresso prior to 6.1 requires -I in front of the directory
elpa_include = '' if '@6.1:' in spec else '-I'
elpa_include += os.path.join(
elpa_include += join_path(
elpa.headers.directories[0],
'modules'
)
@ -369,7 +364,6 @@ def install(self, spec, prefix):
if 'platform=darwin' in spec:
mkdirp(prefix.bin)
for filename in glob.glob("bin/*.x"):
install(filename, prefix.bin)
install('bin/*.x', prefix.bin)
else:
make('install')

View File

@ -3,9 +3,6 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
import glob
class Redundans(Package):
"""Redundans pipeline assists an assembly of heterozygous genomes."""
@ -38,7 +35,6 @@ def install(self, spec, prefix):
'redundans.py')
binfiles = ['redundans.py', 'bin/filterReads.py']
binfiles.extend(glob.glob('bin/fast?2*.py'))
# new internal dep with 0.14a
if spec.satisfies('@0.14a:'):
@ -47,3 +43,5 @@ def install(self, spec, prefix):
mkdirp(prefix.bin)
for f in binfiles:
install(f, prefix.bin)
install('bin/fast?2*.py', prefix.bin)

View File

@ -3,9 +3,6 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import glob
from spack import *
class Rhash(MakefilePackage):
"""RHash is a console utility for computing and verifying hash sums of
@ -52,8 +49,6 @@ def install(self, spec, prefix):
make('install-lib-static', 'DESTDIR={0}'.format(prefix), 'PREFIX=')
if spec.satisfies('platform=darwin'):
libs = glob.glob('librhash/*.dylib')
for lib in libs:
install(lib, prefix.lib)
install('librhash/*.dylib', prefix.lib)
else:
make('install-lib-shared', 'DESTDIR={0}'.format(prefix), 'PREFIX=')

View File

@ -3,9 +3,6 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
import glob
class SnapKorf(MakefilePackage):
"""SNAP is a general purpose gene finding program suitable for both
@ -30,9 +27,7 @@ def install(self, spec, prefix):
for p in progs:
install(p, prefix.bin)
files = glob.iglob('*.pl')
for file in files:
install(file, prefix.bin)
install('*.pl', prefix.bin)
install_tree('Zoe', prefix.Zoe)
install_tree('HMM', prefix.HMM)

View File

@ -2,8 +2,6 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
import glob
class Sparse(MakefilePackage):
@ -36,9 +34,7 @@ def build(self, spec, prefix):
make()
def install(self, spec, prefix):
headers = glob.glob('src/*.h')
mkdir(prefix.include)
install_tree('lib', prefix.lib)
install_tree('bin', prefix.bin)
mkdir(prefix.include)
for h in headers:
install(h, prefix.include)
install('src/*.h', prefix.include)

View File

@ -3,9 +3,6 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
import glob
class Sse2neon(Package):
"""A C/C++ header file that converts Intel SSE intrinsics to ARN NEON
@ -18,6 +15,4 @@ class Sse2neon(Package):
def install(self, spec, prefix):
mkdirp(prefix.include)
headers = glob.glob('*.h')
for f in headers:
install(f, prefix.include)
install('*.h', prefix.include)

View File

@ -3,10 +3,6 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
import glob
import os
class Superlu(Package):
"""SuperLU is a general purpose library for the direct solution of large,
@ -64,9 +60,9 @@ def install(self, spec, prefix):
'ARCH = ar',
'ARCHFLAGS = cr',
'RANLIB = {0}'.format('ranlib' if which('ranlib') else 'echo'),
'CC = {0}'.format(os.environ['CC']),
'FORTRAN = {0}'.format(os.environ['FC']),
'LOADER = {0}'.format(os.environ['CC']),
'CC = {0}'.format(env['CC']),
'FORTRAN = {0}'.format(env['FC']),
'LOADER = {0}'.format(env['CC']),
'CDEFS = -DAdd_'
])
@ -95,7 +91,5 @@ def install(self, spec, prefix):
# Install manually
install_tree('lib', prefix.lib)
headers = glob.glob(join_path('SRC', '*.h'))
mkdir(prefix.include)
for h in headers:
install(h, prefix.include)
install(join_path('SRC', '*.h'), prefix.include)

View File

@ -3,9 +3,6 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
import glob
class Sw4lite(MakefilePackage):
"""Sw4lite is a bare bone version of SW4 intended for testing
@ -75,6 +72,5 @@ def build_targets(self):
def install(self, spec, prefix):
mkdir(prefix.bin)
exe_name = glob.glob('*/sw4lite')[0]
install(exe_name, prefix.bin)
install('*/sw4lite', prefix.bin)
install_tree('tests', prefix.tests)

View File

@ -3,10 +3,8 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
import os
import platform
import glob
class Texlive(AutotoolsPackage):
@ -152,8 +150,7 @@ def configure_args(self):
def setup_texlive(self):
if not self.spec.satisfies('@live'):
mkdirp(self.prefix.tlpkg.TeXLive)
for files in glob.glob('texk/tests/TeXLive/*'):
install(files, self.prefix.tlpkg.TeXLive)
install('texk/tests/TeXLive/*', self.prefix.tlpkg.TeXLive)
with working_dir('spack-build'):
make('texlinks')

View File

@ -3,9 +3,6 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
import glob
class Vardictjava(Package):
"""VarDictJava is a variant discovery program written in Java.
@ -23,6 +20,4 @@ def install(self, spec, prefix):
install('bin/VarDict', prefix.bin)
mkdirp(prefix.lib)
files = [x for x in glob.glob("lib/*jar")]
for f in files:
install(f, prefix.lib)
install('lib/*.jar', prefix.lib)

View File

@ -3,9 +3,6 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
import glob
class Wireshark(CMakePackage):
"""Graphical network analyzer and capture tool"""
@ -99,6 +96,5 @@ def install_headers(self):
folders = ['.', 'epan/crypt', 'epan/dfilter', 'epan/dissectors',
'epan/ftypes', 'epan/wmem', 'wiretap', 'wsutil']
for folder in folders:
headers = glob.glob(join_path(folder, '*.h'))
for h in headers:
install(h, join_path(prefix.include, 'wireshark', folder))
install(join_path(folder, '*.h'),
join_path(prefix.include.wireshark, folder))