def main(): parser = get_parser() args = parser.parse_args() env = find_environment(args) if env is None: sys.stderr.write("No environment\n") sys.exit(1) reslist = [] for spec in env.user_specs: s = str(spec) if s.startswith(args.packagename + '@'): # reslist.insert(0, s) pass else: reslist.append("^" + s) print(" ".join(reslist))
def main(argv=None): """This is the entry point for the Spack command. Args: argv (list of str or None): command line arguments, NOT including the executable name. If None, parses from sys.argv. """ # Create a parser with a simple positional argument first. We'll # lazily load the subcommand(s) we need later. This allows us to # avoid loading all the modules from spack.cmd when we don't need # them, which reduces startup latency. parser = make_argument_parser() parser.add_argument('command', nargs=argparse.REMAINDER) args, unknown = parser.parse_known_args(argv) # Recover stored LD_LIBRARY_PATH variables from spack shell function # This is necessary because MacOS System Integrity Protection clears # (DY?)LD_LIBRARY_PATH variables on process start. # Spack clears these variables before building and installing packages, # but needs to know the prior state for commands like `spack load` and # `spack env activate that modify the user environment. recovered_vars = ('LD_LIBRARY_PATH', 'DYLD_LIBRARY_PATH', 'DYLD_FALLBACK_LIBRARY_PATH') for var in recovered_vars: stored_var_name = 'SPACK_%s' % var if stored_var_name in os.environ: os.environ[var] = os.environ[stored_var_name] # make spack.config aware of any command line configuration scopes if args.config_scopes: spack.config.command_line_scopes = args.config_scopes # activate an environment if one was specified on the command line if not args.no_env: env = ev.find_environment(args) if env: ev.activate(env, args.use_env_repo, add_view=False) if args.print_shell_vars: print_setup_info(*args.print_shell_vars.split(',')) return 0 # Just print help and exit if run with no arguments at all no_args = (len(sys.argv) == 1) if argv is None else (len(argv) == 0) if no_args: parser.print_help() return 1 # -h, -H, and -V are special as they do not require a command, but # all the other options do nothing without a command. if args.version: print(get_version()) return 0 elif args.help: sys.stdout.write(parser.format_help(level=args.help)) return 0 elif not args.command: parser.print_help() return 1 try: # ensure options on spack command come before everything setup_main_options(args) # Try to load the particular command the caller asked for. cmd_name = args.command[0] cmd_name = aliases.get(cmd_name, cmd_name) command = parser.add_command(cmd_name) # Re-parse with the proper sub-parser added. args, unknown = parser.parse_known_args() # many operations will fail without a working directory. set_working_dir() # now we can actually execute the command. if args.spack_profile or args.sorted_profile: _profile_wrapper(command, parser, args, unknown) elif args.pdb: import pdb pdb.runctx('_invoke_command(command, parser, args, unknown)', globals(), locals()) return 0 else: return _invoke_command(command, parser, args, unknown) except SpackError as e: tty.debug(e) e.die() # gracefully die on any SpackErrors except Exception as e: if spack.config.get('config:debug'): raise tty.die(e) except KeyboardInterrupt: if spack.config.get('config:debug'): raise sys.stderr.write('\n') tty.die("Keyboard interrupt.") except SystemExit as e: if spack.config.get('config:debug'): traceback.print_exc() return e.code
def main(argv=None): """This is the entry point for the Spack command. Args: argv (list of str or None): command line arguments, NOT including the executable name. If None, parses from sys.argv. """ # Create a parser with a simple positional argument first. We'll # lazily load the subcommand(s) we need later. This allows us to # avoid loading all the modules from spack.cmd when we don't need # them, which reduces startup latency. parser = make_argument_parser() parser.add_argument('command', nargs=argparse.REMAINDER) args, unknown = parser.parse_known_args(argv) # activate an environment if one was specified on the command line if not args.no_env: env = ev.find_environment(args) if env: ev.activate(env, args.use_env_repo) # make spack.config aware of any command line configuration scopes if args.config_scopes: spack.config.command_line_scopes = args.config_scopes if args.print_shell_vars: print_setup_info(*args.print_shell_vars.split(',')) return 0 # Just print help and exit if run with no arguments at all no_args = (len(sys.argv) == 1) if argv is None else (len(argv) == 0) if no_args: parser.print_help() return 1 # -h, -H, and -V are special as they do not require a command, but # all the other options do nothing without a command. if args.version: print(spack.spack_version) return 0 elif args.help: sys.stdout.write(parser.format_help(level=args.help)) return 0 elif not args.command: parser.print_help() return 1 try: # ensure options on spack command come before everything setup_main_options(args) # Try to load the particular command the caller asked for. If there # is no module for it, just die. cmd_name = args.command[0] cmd_name = aliases.get(cmd_name, cmd_name) command = parser.add_command(cmd_name) # Re-parse with the proper sub-parser added. args, unknown = parser.parse_known_args() # many operations will fail without a working directory. set_working_dir() # pre-run hooks happen after we know we have a valid working dir spack.hooks.pre_run() # now we can actually execute the command. if args.spack_profile or args.sorted_profile: _profile_wrapper(command, parser, args, unknown) elif args.pdb: import pdb pdb.runctx('_invoke_command(command, parser, args, unknown)', globals(), locals()) return 0 else: return _invoke_command(command, parser, args, unknown) except SpackError as e: tty.debug(e) e.die() # gracefully die on any SpackErrors except Exception as e: if spack.config.get('config:debug'): raise tty.die(e) except KeyboardInterrupt: if spack.config.get('config:debug'): raise sys.stderr.write('\n') tty.die("Keyboard interrupt.") except SystemExit as e: if spack.config.get('config:debug'): traceback.print_exc() return e.code
def main(argv=None): """This is the entry point for the Spack command. Args: argv (list of str or None): command line arguments, NOT including the executable name. If None, parses from sys.argv. """ # Create a parser with a simple positional argument first. We'll # lazily load the subcommand(s) we need later. This allows us to # avoid loading all the modules from spack.cmd when we don't need # them, which reduces startup latency. parser = make_argument_parser() parser.add_argument('command', nargs=argparse.REMAINDER) args, unknown = parser.parse_known_args(argv) # activate an environment if one was specified on the command line if not args.no_env: env = ev.find_environment(args) if env: ev.activate(env, args.use_env_repo) # make spack.config aware of any command line configuration scopes if args.config_scopes: spack.config.command_line_scopes = args.config_scopes if args.print_shell_vars: print_setup_info(*args.print_shell_vars.split(',')) return 0 # from spack.spec import Spec # #import llnl.util.tty as tty # import time # import llnl.util.lock as lk # # tty.set_verbose(args.verbose) # tty.set_debug(args.debug) # # def use_llnl_lock(path='/tmp/lockfile', start=10000, len=100): # mylk = lk.Lock(path, start, len) # mylk.acquire_write() # tty.warn('ENTERED LOCK') # time.sleep(1) # tty.warn('EXITING LOCK') # mylk.release_write() # # # def use_db_lock(): # s = Spec('m4') # s.concretize() # #tty.warn('Locking phase...\n') # time.sleep(0.1) # with spack.store.db.prefix_write_lock(s): # tty.warn('ENTERED LOCK') # time.sleep(1) # tty.warn('EXITING LOCK') # # #use_db_lock() # use_llnl_lock( # '/home/sknigh/code/github/spack/opt/spack/.spack-db/prefix_lock', # 4651886554793840719, 1) # exit() # Just print help and exit if run with no arguments at all no_args = (len(sys.argv) == 1) if argv is None else (len(argv) == 0) if no_args: parser.print_help() return 1 # -h, -H, and -V are special as they do not require a command, but # all the other options do nothing without a command. if args.version: print(spack.spack_version) return 0 elif args.help: sys.stdout.write(parser.format_help(level=args.help)) return 0 elif not args.command: parser.print_help() return 1 try: # ensure options on spack command come before everything setup_main_options(args) # Try to load the particular command the caller asked for. If there # is no module for it, just die. cmd_name = args.command[0] cmd_name = aliases.get(cmd_name, cmd_name) try: command = parser.add_command(cmd_name) except ImportError: if spack.config.get('config:debug'): raise tty.die("Unknown command: %s" % args.command[0]) # Re-parse with the proper sub-parser added. args, unknown = parser.parse_known_args() # many operations will fail without a working directory. set_working_dir() # pre-run hooks happen after we know we have a valid working dir spack.hooks.pre_run() # now we can actually execute the command. if args.spack_profile or args.sorted_profile: _profile_wrapper(command, parser, args, unknown) elif args.pdb: import pdb pdb.runctx('_invoke_command(command, parser, args, unknown)', globals(), locals()) return 0 else: return _invoke_command(command, parser, args, unknown) except SpackError as e: e.die() # gracefully die on any SpackErrors except Exception as e: if spack.config.get('config:debug'): raise tty.die(str(e)) except KeyboardInterrupt: sys.stderr.write('\n') tty.die("Keyboard interrupt.") except SystemExit as e: return e.code
def main(argv=None): """This is the entry point for the Spack command. Args: argv (list of str or None): command line arguments, NOT including the executable name. If None, parses from sys.argv. """ # Create a parser with a simple positional argument first. We'll # lazily load the subcommand(s) we need later. This allows us to # avoid loading all the modules from spack.cmd when we don't need # them, which reduces startup latency. parser = make_argument_parser() parser.add_argument('command', nargs=argparse.REMAINDER) args, unknown = parser.parse_known_args(argv) # activate an environment if one was specified on the command line if not args.no_env: env = ev.find_environment(args) if env: ev.activate(env, args.use_env_repo) # make spack.config aware of any command line configuration scopes if args.config_scopes: spack.config.command_line_scopes = args.config_scopes if args.print_shell_vars: print_setup_info(*args.print_shell_vars.split(',')) return 0 # Just print help and exit if run with no arguments at all no_args = (len(sys.argv) == 1) if argv is None else (len(argv) == 0) if no_args: parser.print_help() return 1 # -h, -H, and -V are special as they do not require a command, but # all the other options do nothing without a command. if args.version: print(spack.spack_version) return 0 elif args.help: sys.stdout.write(parser.format_help(level=args.help)) return 0 elif not args.command: parser.print_help() return 1 try: # ensure options on spack command come before everything setup_main_options(args) # Try to load the particular command the caller asked for. If there # is no module for it, just die. cmd_name = args.command[0] cmd_name = aliases.get(cmd_name, cmd_name) try: command = parser.add_command(cmd_name) except ImportError: if spack.config.get('config:debug'): raise tty.die("Unknown command: %s" % args.command[0]) # Re-parse with the proper sub-parser added. args, unknown = parser.parse_known_args() # many operations will fail without a working directory. set_working_dir() # pre-run hooks happen after we know we have a valid working dir spack.hooks.pre_run() # now we can actually execute the command. if args.spack_profile or args.sorted_profile: _profile_wrapper(command, parser, args, unknown) elif args.pdb: import pdb pdb.runctx('_invoke_command(command, parser, args, unknown)', globals(), locals()) return 0 else: return _invoke_command(command, parser, args, unknown) except SpackError as e: e.die() # gracefully die on any SpackErrors except Exception as e: if spack.config.get('config:debug'): raise tty.die(str(e)) except KeyboardInterrupt: sys.stderr.write('\n') tty.die("Keyboard interrupt.") except SystemExit as e: return e.code