summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/sbang23
-rwxr-xr-xbin/spack199
-rwxr-xr-xbin/spack-python6
3 files changed, 53 insertions, 175 deletions
diff --git a/bin/sbang b/bin/sbang
index e71074b330..f7182c0f23 100755
--- a/bin/sbang
+++ b/bin/sbang
@@ -1,14 +1,14 @@
#!/bin/bash
##############################################################################
-# Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC.
+# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC.
# Produced at the Lawrence Livermore National Laboratory.
#
# This file is part of Spack.
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
# LLNL-CODE-647188
#
-# For details, see https://github.com/llnl/spack
-# Please also see the LICENSE file for our notice and the LGPL.
+# For details, see https://github.com/spack/spack
+# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License (as
@@ -104,18 +104,27 @@ lines=0
while read line && ((lines < 2)) ; do
if [[ "$line" = '#!'* ]]; then
interpreter="${line#\#!}"
+ elif [[ "$line" = '//!'*node* ]]; then
+ interpreter="${line#//!}"
elif [[ "$line" = '--!'*lua* ]]; then
interpreter="${line#--!}"
fi
lines=$((lines+1))
done < "$script"
+# this is ineeded for scripts with sbang parameter
+# like ones in intltool
+# #!/<spack-long-path>/perl -w
+# this is the interpreter line with all the parameters as a vector
+interpreter_v=(${interpreter})
+# this is the single interpreter path
+interpreter_f="${interpreter_v[0]}"
# Invoke any interpreter found, or raise an error if none was found.
-if [[ -n "$interpreter" ]]; then
- if [[ "${interpreter##*/}" = "perl" ]]; then
- exec $interpreter -x "$@"
+if [[ -n "$interpreter_f" ]]; then
+ if [[ "${interpreter_f##*/}" = "perl" ]]; then
+ exec $interpreter_v -x "$@"
else
- exec $interpreter "$@"
+ exec $interpreter_v "$@"
fi
else
echo "error: sbang found no interpreter in $script"
diff --git a/bin/spack b/bin/spack
index 66bebe57e7..51dbce695b 100755
--- a/bin/spack
+++ b/bin/spack
@@ -1,15 +1,14 @@
#!/usr/bin/env python
-# flake8: noqa
##############################################################################
-# Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC.
+# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC.
# Produced at the Lawrence Livermore National Laboratory.
#
# This file is part of Spack.
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
# LLNL-CODE-647188
#
-# For details, see https://github.com/llnl/spack
-# Please also see the LICENSE file for our notice and the LGPL.
+# For details, see https://github.com/spack/spack
+# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License (as
@@ -24,27 +23,34 @@
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
+from __future__ import print_function
+
+import os
import sys
-if (sys.version_info[0] > 2) or (sys.version_info[:2] < (2, 6)):
+
+if sys.version_info[:2] < (2, 6):
v_info = sys.version_info[:3]
- sys.exit("Spack requires Python 2.6 or 2.7. "
+ sys.exit("Spack requires Python 2.6 or higher."
"This is Python %d.%d.%d." % v_info)
-import os
-import inspect
-
# Find spack's location and its prefix.
-SPACK_FILE = os.path.realpath(os.path.expanduser(__file__))
-os.environ["SPACK_FILE"] = SPACK_FILE
-SPACK_PREFIX = os.path.dirname(os.path.dirname(SPACK_FILE))
+spack_file = os.path.realpath(os.path.expanduser(__file__))
+spack_prefix = os.path.dirname(os.path.dirname(spack_file))
# Allow spack libs to be imported in our scripts
-SPACK_LIB_PATH = os.path.join(SPACK_PREFIX, "lib", "spack")
-sys.path.insert(0, SPACK_LIB_PATH)
+spack_lib_path = os.path.join(spack_prefix, "lib", "spack")
+sys.path.insert(0, spack_lib_path)
# Add external libs
-SPACK_EXTERNAL_LIBS = os.path.join(SPACK_LIB_PATH, "external")
-sys.path.insert(0, SPACK_EXTERNAL_LIBS)
+spack_external_libs = os.path.join(spack_lib_path, "external")
+sys.path.insert(0, spack_external_libs)
+
+# Handle vendoring of YAML specially, as it has two versions.
+if sys.version_info[0] == 2:
+ spack_yaml_libs = os.path.join(spack_external_libs, "yaml/lib")
+else:
+ spack_yaml_libs = os.path.join(spack_external_libs, "yaml/lib3")
+sys.path.insert(0, spack_yaml_libs)
# Quick and dirty check to clean orphaned .pyc files left over from
# previous revisions. These files were present in earlier versions of
@@ -52,13 +58,13 @@ sys.path.insert(0, SPACK_EXTERNAL_LIBS)
# imports. If we leave them, Spack will fail in mysterious ways.
# TODO: more elegant solution for orphaned pyc files.
orphaned_pyc_files = [
- os.path.join(SPACK_EXTERNAL_LIBS, 'functools.pyc'),
- os.path.join(SPACK_EXTERNAL_LIBS, 'ordereddict.pyc'),
- os.path.join(SPACK_LIB_PATH, 'spack', 'platforms', 'cray_xc.pyc'),
- os.path.join(SPACK_LIB_PATH, 'spack', 'cmd', 'package-list.pyc'),
- os.path.join(SPACK_LIB_PATH, 'spack', 'cmd', 'test-install.pyc'),
- os.path.join(SPACK_LIB_PATH, 'spack', 'cmd', 'url-parse.pyc'),
- os.path.join(SPACK_LIB_PATH, 'spack', 'test', 'yaml.pyc')
+ os.path.join(spack_external_libs, 'functools.pyc'),
+ os.path.join(spack_external_libs, 'ordereddict.pyc'),
+ os.path.join(spack_lib_path, 'spack', 'platforms', 'cray_xc.pyc'),
+ os.path.join(spack_lib_path, 'spack', 'cmd', 'package-list.pyc'),
+ os.path.join(spack_lib_path, 'spack', 'cmd', 'test-install.pyc'),
+ os.path.join(spack_lib_path, 'spack', 'cmd', 'url-parse.pyc'),
+ os.path.join(spack_lib_path, 'spack', 'test', 'yaml.pyc')
]
for pyc_file in orphaned_pyc_files:
@@ -67,146 +73,9 @@ for pyc_file in orphaned_pyc_files:
try:
os.remove(pyc_file)
except OSError as e:
- print ("WARNING: Spack may fail mysteriously. "
- "Couldn't remove orphaned .pyc file: %s" % pyc_file)
-
-# If there is no working directory, use the spack prefix.
-try:
- working_dir = os.getcwd()
-except OSError:
- os.chdir(SPACK_PREFIX)
- working_dir = SPACK_PREFIX
-
-# clean up the scope and start using spack package instead.
-del SPACK_FILE, SPACK_PREFIX, SPACK_LIB_PATH
-import llnl.util.tty as tty
-from llnl.util.tty.color import *
-import spack
-from spack.error import SpackError
-import argparse
-
-# Command parsing
-parser = argparse.ArgumentParser(
- formatter_class=argparse.RawTextHelpFormatter,
- description="Spack: the Supercomputing PACKage Manager." + colorize("""
-
-spec expressions:
- PACKAGE [CONSTRAINTS]
-
- CONSTRAINTS:
- @c{@version}
- @g{%compiler @compiler_version}
- @B{+variant}
- @r{-variant} or @r{~variant}
- @m{=architecture}
- [^DEPENDENCY [CONSTRAINTS] ...]"""))
-
-parser.add_argument('-d', '--debug', action='store_true',
- help="Write out debug logs during compile")
-parser.add_argument('-D', '--pdb', action='store_true',
- help="Run spack under the pdb debugger")
-parser.add_argument('-k', '--insecure', action='store_true',
- help="Do not check ssl certificates when downloading.")
-parser.add_argument('-m', '--mock', action='store_true',
- help="Use mock packages instead of real ones.")
-parser.add_argument('-p', '--profile', action='store_true',
- help="Profile execution using cProfile.")
-parser.add_argument('-v', '--verbose', action='store_true',
- help="Print additional output during builds")
-parser.add_argument('-s', '--stacktrace', action='store_true',
- help="Add stacktrace information to all printed statements")
-parser.add_argument('-V', '--version', action='version',
- version="%s" % spack.spack_version)
-
-# each command module implements a parser() function, to which we pass its
-# subparser for setup.
-subparsers = parser.add_subparsers(metavar='SUBCOMMAND', dest="command")
-
-
-import spack.cmd
-for cmd in spack.cmd.commands:
- module = spack.cmd.get_module(cmd)
- cmd_name = cmd.replace('_', '-')
- subparser = subparsers.add_parser(cmd_name, help=module.description)
- module.setup_parser(subparser)
-
-
-def _main(args, unknown_args):
- # Set up environment based on args.
- tty.set_verbose(args.verbose)
- tty.set_debug(args.debug)
- tty.set_stacktrace(args.stacktrace)
- spack.debug = args.debug
-
- if spack.debug:
- import spack.util.debug as debug
- debug.register_interrupt_handler()
-
- # Run any available pre-run hooks
- spack.hooks.pre_run()
-
- spack.spack_working_dir = working_dir
- if args.mock:
- from spack.repository import RepoPath
- spack.repo.swap(RepoPath(spack.mock_packages_path))
-
- # If the user asked for it, don't check ssl certs.
- if args.insecure:
- tty.warn("You asked for --insecure. Will NOT check SSL certificates.")
- spack.insecure = True
-
- # Try to load the particular command asked for and run it
- command = spack.cmd.get_command(args.command.replace('-', '_'))
-
- # Allow commands to inject an optional argument and get unknown args
- # if they want to handle them.
- info = dict(inspect.getmembers(command))
- varnames = info['__code__'].co_varnames
- argcount = info['__code__'].co_argcount
-
- # Actually execute the command
- try:
- if argcount == 3 and varnames[2] == 'unknown_args':
- return_val = command(parser, args, unknown_args)
- else:
- if unknown_args:
- tty.die('unrecognized arguments: %s' % ' '.join(unknown_args))
- return_val = command(parser, args)
- except SpackError as e:
- e.die()
- except KeyboardInterrupt:
- sys.stderr.write('\n')
- tty.die("Keyboard interrupt.")
-
- # Allow commands to return values if they want to exit with some other code.
- if return_val is None:
- sys.exit(0)
- elif isinstance(return_val, int):
- sys.exit(return_val)
- else:
- tty.die("Bad return value from command %s: %s"
- % (args.command, return_val))
-
-
-def main(args):
- # Just print help and exit if run with no arguments at all
- if len(args) == 1:
- parser.print_help()
- sys.exit(1)
-
- # actually parse the args.
- args, unknown = parser.parse_known_args()
-
- if args.profile:
- import cProfile
- cProfile.runctx('_main(args, unknown)', globals(), locals(),
- sort='time')
- elif args.pdb:
- import pdb
- pdb.runctx('_main(args, unknown)', globals(), locals())
- else:
- _main(args, unknown)
-
+ print("WARNING: Spack may fail mysteriously. "
+ "Couldn't remove orphaned .pyc file: %s" % pyc_file)
-if __name__ == '__main__':
- main(sys.argv)
+# Once we've set up the system path, run the spack main method
+import spack.main # noqa
+sys.exit(spack.main.main())
diff --git a/bin/spack-python b/bin/spack-python
index 96bc367866..2a717025bf 100755
--- a/bin/spack-python
+++ b/bin/spack-python
@@ -1,14 +1,14 @@
#!/bin/sh
##############################################################################
-# Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC.
+# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC.
# Produced at the Lawrence Livermore National Laboratory.
#
# This file is part of Spack.
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
# LLNL-CODE-647188
#
-# For details, see https://github.com/llnl/spack
-# Please also see the LICENSE file for our notice and the LGPL.
+# For details, see https://github.com/spack/spack
+# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License (as