From 5a5da817a1041b57cc4ae0f2ee16ee0d75701c57 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Sun, 10 Aug 2014 11:52:17 -0700 Subject: Fix SPACK-27 & remove dependence on check_output - subprocess.check_output is python 2.7 only - Spack checks for existence of requested prefix, creates it if it does not exist. --- lib/spack/spack/cmd/bootstrap.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/cmd/bootstrap.py b/lib/spack/spack/cmd/bootstrap.py index 31c908d42b..f75b68b00a 100644 --- a/lib/spack/spack/cmd/bootstrap.py +++ b/lib/spack/spack/cmd/bootstrap.py @@ -23,12 +23,13 @@ # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ############################################################################## import os -from subprocess import check_call, check_output +from subprocess import check_call import llnl.util.tty as tty -from llnl.util.filesystem import join_path +from llnl.util.filesystem import join_path, mkdirp import spack +from spack.util.executable import which description = "Create a new installation of spack in another prefix" @@ -38,8 +39,10 @@ def setup_parser(subparser): def get_origin_url(): git_dir = join_path(spack.prefix, '.git') - origin_url = check_output( - ['git', '--git-dir=%s' % git_dir, 'config', '--get', 'remote.origin.url']) + git = which('git', required=True) + origin_url = git( + '--git-dir=%s' % git_dir, 'config', '--get', 'remote.origin.url', + return_output=True) return origin_url.strip() @@ -49,6 +52,11 @@ def bootstrap(parser, args): tty.msg("Fetching spack from origin: %s" % origin_url) + if os.path.isfile(prefix): + tty.die("There is already a file at %s" % prefix) + + mkdirp(prefix) + if os.path.exists(join_path(prefix, '.git')): tty.die("There already seems to be a git repository in %s" % prefix) @@ -62,10 +70,11 @@ def bootstrap(parser, args): "%s/lib/spack/..." % prefix) os.chdir(prefix) - check_call(['git', 'init', '--shared', '-q']) - check_call(['git', 'remote', 'add', 'origin', origin_url]) - check_call(['git', 'fetch', 'origin', 'master:refs/remotes/origin/master', '-n', '-q']) - check_call(['git', 'reset', '--hard', 'origin/master', '-q']) + git = which('git', required=True) + git('init', '--shared', '-q') + git('remote', 'add', 'origin', origin_url) + git('fetch', 'origin', 'master:refs/remotes/origin/master', '-n', '-q') + git('reset', '--hard', 'origin/master', '-q') tty.msg("Successfully created a new spack in %s" % prefix, "Run %s/bin/spack to use this installation." % prefix) -- cgit v1.2.3-70-g09d2