diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2014-08-01 08:33:00 -0700 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2014-08-04 07:54:22 -0700 |
commit | c55041e9d47cba97fc461c088c4b935b3355e340 (patch) | |
tree | adbb61f3ad986ff9832c4ddc98433bedaef150aa /lib | |
parent | 8738a3a88c48fd9ed2a9c6182e71e94e6e2d5c3f (diff) | |
download | spack-c55041e9d47cba97fc461c088c4b935b3355e340.tar.gz spack-c55041e9d47cba97fc461c088c4b935b3355e340.tar.bz2 spack-c55041e9d47cba97fc461c088c4b935b3355e340.tar.xz spack-c55041e9d47cba97fc461c088c4b935b3355e340.zip |
Partial commit of more packages.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/llnl/util/filesystem.py | 21 | ||||
-rw-r--r-- | lib/spack/spack/build_environment.py | 5 | ||||
-rw-r--r-- | lib/spack/spack/cmd/create.py | 30 | ||||
-rw-r--r-- | lib/spack/spack/package.py | 2 | ||||
-rw-r--r-- | lib/spack/spack/util/executable.py | 2 |
5 files changed, 33 insertions, 27 deletions
diff --git a/lib/spack/llnl/util/filesystem.py b/lib/spack/llnl/util/filesystem.py index 11c3dee604..3782aefcce 100644 --- a/lib/spack/llnl/util/filesystem.py +++ b/lib/spack/llnl/util/filesystem.py @@ -124,8 +124,19 @@ def expand_user(path): return path.replace('%u', username) +def mkdirp(*paths): + for path in paths: + if not os.path.exists(path): + os.makedirs(path) + elif not os.path.isdir(path): + raise OSError(errno.EEXIST, "File alredy exists", path) + + @contextmanager -def working_dir(dirname): +def working_dir(dirname, **kwargs): + if kwargs.get('create', False): + mkdirp(dirname) + orig_dir = os.getcwd() os.chdir(dirname) yield @@ -137,14 +148,6 @@ def touch(path): os.utime(path, None) -def mkdirp(*paths): - for path in paths: - if not os.path.exists(path): - os.makedirs(path) - elif not os.path.isdir(path): - raise OSError(errno.EEXIST, "File alredy exists", path) - - def join_path(prefix, *args): path = str(prefix) for elt in args: diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py index 38d5f70282..f72c724420 100644 --- a/lib/spack/spack/build_environment.py +++ b/lib/spack/spack/build_environment.py @@ -153,6 +153,9 @@ def set_module_variables_for_package(pkg): m.make = MakeExecutable('make', pkg.parallel) m.gmake = MakeExecutable('gmake', pkg.parallel) + # easy shortcut to os.environ + m.env = os.environ + # number of jobs spack prefers to build with. m.make_jobs = multiprocessing.cpu_count() @@ -168,7 +171,7 @@ def set_module_variables_for_package(pkg): # standard CMake arguments m.std_cmake_args = ['-DCMAKE_INSTALL_PREFIX=%s' % pkg.prefix, - '-DCMAKE_BUILD_TYPE=None'] + '-DCMAKE_BUILD_TYPE=RelWithDebInfo'] if platform.mac_ver()[0]: m.std_cmake_args.append('-DCMAKE_FIND_FRAMEWORK=LAST') diff --git a/lib/spack/spack/cmd/create.py b/lib/spack/spack/cmd/create.py index 1a1a19a4b6..c98162aca7 100644 --- a/lib/spack/spack/cmd/create.py +++ b/lib/spack/spack/cmd/create.py @@ -88,6 +88,9 @@ def setup_parser(subparser): '--keep-stage', action='store_true', dest='keep_stage', help="Don't clean up staging area when command completes.") subparser.add_argument( + '-n', '--name', dest='alternate_name', default=None, + help="Override the autodetected name for the created package.") + subparser.add_argument( '-f', '--force', action='store_true', dest='force', help="Overwrite any existing package file with the same name.") @@ -121,30 +124,27 @@ def make_version_calls(ver_hash_tuples): return '\n'.join(format % ("'%s'" % v, h) for v, h in ver_hash_tuples) -def get_name(): - """Prompt user to input a package name.""" - name = "" - while not name: - new_name = raw_input("Name: ") - if spack.db.valid_name(name): - name = new_name - else: - print "Package name can only contain A-Z, a-z, 0-9, '_' and '-'" - return name - - def create(parser, args): url = args.url # Try to deduce name and version of the new package from the URL name, version = spack.url.parse_name_and_version(url) - if not name: - tty.msg("Couldn't guess a name for this package.") - name = get_name() + + # Use a user-supplied name if one is present + name = kwargs.get(args, 'alternate_name', False) + if args.name: + name = args.name if not version: tty.die("Couldn't guess a version string from %s." % url) + if not name: + tty.die("Couldn't guess a name for this package. Try running:", "", + "spack create --name <name> <url>") + + if not spack.db.valid_name(name): + tty.die("Package name can only contain A-Z, a-z, 0-9, '_' and '-'") + tty.msg("This looks like a URL for %s version %s." % (name, version)) tty.msg("Creating template for package %s" % name) diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py index 8df658e660..0375df7dac 100644 --- a/lib/spack/spack/package.py +++ b/lib/spack/spack/package.py @@ -57,7 +57,7 @@ from spack.util.web import get_pages from spack.util.compression import allowed_archive, extension """Allowed URL schemes for spack packages.""" -_ALLOWED_URL_SCHEMES = ["http", "https", "ftp", "file"] +_ALLOWED_URL_SCHEMES = ["http", "https", "ftp", "file", "git"] class Package(object): diff --git a/lib/spack/spack/util/executable.py b/lib/spack/spack/util/executable.py index bc27b25889..923c7c19a5 100644 --- a/lib/spack/spack/util/executable.py +++ b/lib/spack/spack/util/executable.py @@ -121,7 +121,7 @@ def which(name, **kwargs): for dir in path: exe = os.path.join(dir, name) - if os.access(exe, os.X_OK): + if os.path.isfile(exe) and os.access(exe, os.X_OK): return Executable(exe) if required: |