summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/spack/spack/cmd/setup.py92
-rw-r--r--lib/spack/spack/package.py110
2 files changed, 82 insertions, 120 deletions
diff --git a/lib/spack/spack/cmd/setup.py b/lib/spack/spack/cmd/setup.py
index 04f3d663df..8cf05b5c8b 100644
--- a/lib/spack/spack/cmd/setup.py
+++ b/lib/spack/spack/cmd/setup.py
@@ -22,19 +22,22 @@
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
-import sys
-import os
import argparse
+import os
+import string
+import sys
import llnl.util.tty as tty
-
import spack
import spack.cmd
+from spack import which
from spack.cmd.edit import edit_package
from spack.stage import DIYStage
+from llnl.util.filesystem import set_executable
description = "Create a configuration script and module, but don't build."
+
def setup_parser(subparser):
subparser.add_argument(
'-i', '--ignore-dependencies', action='store_true', dest='ignore_deps',
@@ -47,6 +50,75 @@ def setup_parser(subparser):
help="specs to use for install. Must contain package AND version.")
+def spack_transitive_include_path():
+ return ';'.join(
+ os.path.join(dep, 'include')
+ for dep in os.environ['SPACK_DEPENDENCIES'].split(os.pathsep)
+ )
+
+
+def write_spconfig(package):
+ spec = package.spec
+ prefix = spec.prefix
+ # Set-up the environment
+ spack.build_environment.setup_package(package)
+
+ cmd = [str(which('cmake'))] + package.std_cmake_args + package.cmake_args()
+
+ env = dict()
+
+ paths = os.environ['PATH'].split(':')
+ paths = [item for item in paths if 'spack/env' not in item]
+ env['PATH'] = ':'.join(paths)
+ env['SPACK_TRANSITIVE_INCLUDE_PATH'] = spack_transitive_include_path()
+ env['CMAKE_PREFIX_PATH'] = os.environ['CMAKE_PREFIX_PATH']
+ env['CC'] = os.environ['SPACK_CC']
+ env['CXX'] = os.environ['SPACK_CXX']
+ env['FC'] = os.environ['SPACK_FC']
+
+ setup_fname = 'spconfig.py'
+ with open(setup_fname, 'w') as fout:
+ fout.write(
+r"""#!%s
+#
+
+import sys
+import os
+import subprocess
+
+def cmdlist(str):
+ return list(x.strip().replace("'",'') for x in str.split('\n') if x)
+env = dict(os.environ)
+""" % sys.executable)
+
+ env_vars = sorted(list(env.keys()))
+ for name in env_vars:
+ val = env[name]
+ if string.find(name, 'PATH') < 0:
+ fout.write('env[%s] = %s\n' % (repr(name), repr(val)))
+ else:
+ if name == 'SPACK_TRANSITIVE_INCLUDE_PATH':
+ sep = ';'
+ else:
+ sep = ':'
+
+ fout.write(
+ 'env[%s] = "%s".join(cmdlist("""\n' % (repr(name), sep))
+ for part in string.split(val, sep):
+ fout.write(' %s\n' % part)
+ fout.write('"""))\n')
+
+ fout.write(
+ "env['CMAKE_TRANSITIVE_INCLUDE_PATH'] = env['SPACK_TRANSITIVE_INCLUDE_PATH'] # Deprecated\n")
+ fout.write('\ncmd = cmdlist("""\n')
+ fout.write('%s\n' % cmd[0])
+ for arg in cmd[1:]:
+ fout.write(' %s\n' % arg)
+ fout.write('""") + sys.argv[1:]\n')
+ fout.write('\nproc = subprocess.Popen(cmd, env=env)\nproc.wait()\n')
+ set_executable(setup_fname)
+
+
def setup(self, args):
if not args.spec:
tty.die("spack setup requires a package spec argument.")
@@ -70,7 +142,8 @@ def setup(self, args):
return
if not spec.versions.concrete:
- tty.die("spack setup spec must have a single, concrete version. Did you forget a package version number?")
+ tty.die(
+ "spack setup spec must have a single, concrete version. Did you forget a package version number?")
spec.concretize()
package = spack.repo.get(spec)
@@ -83,9 +156,8 @@ def setup(self, args):
# TODO: make this an argument, not a global.
spack.do_checksum = False
- package.do_install(
- keep_prefix=True, # Don't remove install directory, even if you think you should
- ignore_deps=args.ignore_deps,
- verbose=args.verbose,
- keep_stage=True, # don't remove source dir for SETUP.
- install_phases = set(['setup', 'provenance']))
+ if not isinstance(package, spack.CMakePackage):
+ raise RuntimeError(
+ 'Support for {0} not yet implemented'.format(type(package)))
+
+ write_spconfig(package)
diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py
index 68360ec532..ea798e8eaa 100644
--- a/lib/spack/spack/package.py
+++ b/lib/spack/spack/package.py
@@ -1822,116 +1822,6 @@ def _hms(seconds):
parts.append("%.2fs" % s)
return ' '.join(parts)
-# FIXME : remove this after checking that set_executable works the same way
-# stackoverflow.com/questions/12791997/how-do-you-do-a-simple-chmod-x-from-within-python
-#def make_executable(path):
-# mode = os.stat(path).st_mode
-# mode |= (mode & 0o444) >> 2 # copy R bits to X
-# os.chmod(path, mode)
-
-
-# class CMakePackage(PackageBase):
-# phases = ['configure', 'build', 'install', 'provenance']
-#
-# def make_make(self):
-# import multiprocessing
-# # number of jobs spack will to build with.
-# jobs = multiprocessing.cpu_count()
-# if not self.parallel:
-# jobs = 1
-# elif self.make_jobs:
-# jobs = self.make_jobs
-#
-# make = spack.build_environment.MakeExecutable('make', jobs)
-# return make
-#
-# def configure_args(self):
-# """Returns package-specific arguments to be provided to the configure command."""
-# return list()
-#
-# def configure_env(self):
-# """Returns package-specific environment under which the configure command should be run."""
-# # FIXME : Why not EnvironmentModules and the hooks that PackageBase already provides ?
-# return dict()
-#
-# def spack_transitive_include_path(self):
-# return ';'.join(
-# os.path.join(dep, 'include')
-# for dep in os.environ['SPACK_DEPENDENCIES'].split(os.pathsep)
-# )
-#
-# def setup(self, spec, prefix):
-# cmd = [str(which('cmake'))] + \
-# spack.build_environment.get_std_cmake_args(self) + \
-# ['-DCMAKE_INSTALL_PREFIX=%s' % os.environ['SPACK_PREFIX'],
-# '-DCMAKE_C_COMPILER=%s' % os.environ['SPACK_CC'],
-# '-DCMAKE_CXX_COMPILER=%s' % os.environ['SPACK_CXX'],
-# '-DCMAKE_Fortran_COMPILER=%s' % os.environ['SPACK_FC']] + \
-# self.configure_args()
-#
-# env = dict()
-# env['PATH'] = os.environ['PATH']
-# env['SPACK_TRANSITIVE_INCLUDE_PATH'] = self.spack_transitive_include_path()
-# env['CMAKE_PREFIX_PATH'] = os.environ['CMAKE_PREFIX_PATH']
-#
-# setup_fname = 'spconfig.py'
-# with open(setup_fname, 'w') as fout:
-# fout.write(\
-# r"""#!%s
-# #
-#
-# import sys
-# import os
-# import subprocess
-#
-# def cmdlist(str):
-# return list(x.strip().replace("'",'') for x in str.split('\n') if x)
-# env = dict(os.environ)
-# """ % sys.executable)
-#
-# env_vars = sorted(list(env.keys()))
-# for name in env_vars:
-# val = env[name]
-# if string.find(name, 'PATH') < 0:
-# fout.write('env[%s] = %s\n' % (repr(name),repr(val)))
-# else:
-# if name == 'SPACK_TRANSITIVE_INCLUDE_PATH':
-# sep = ';'
-# else:
-# sep = ':'
-#
-# fout.write('env[%s] = "%s".join(cmdlist("""\n' % (repr(name),sep))
-# for part in string.split(val, sep):
-# fout.write(' %s\n' % part)
-# fout.write('"""))\n')
-#
-# fout.write("env['CMAKE_TRANSITIVE_INCLUDE_PATH'] = env['SPACK_TRANSITIVE_INCLUDE_PATH'] # Deprecated\n")
-# fout.write('\ncmd = cmdlist("""\n')
-# fout.write('%s\n' % cmd[0])
-# for arg in cmd[1:]:
-# fout.write(' %s\n' % arg)
-# fout.write('""") + sys.argv[1:]\n')
-# fout.write('\nproc = subprocess.Popen(cmd, env=env)\nproc.wait()\n')
-# set_executable(setup_fname)
-#
-# def configure(self, spec, prefix):
-# cmake = which('cmake')
-# with working_dir(self.build_directory, create=True):
-# os.environ.update(self.configure_env())
-# os.environ['SPACK_TRANSITIVE_INCLUDE_PATH'] = self.spack_transitive_include_path()
-# options = self.configure_args() + spack.build_environment.get_std_cmake_args(self)
-# cmake(self.source_directory, *options)
-#
-# def build(self, spec, prefix):
-# make = self.make_make()
-# with working_dir(self.build_directory, create=False):
-# make()
-#
-# def install(self, spec, prefix):
-# make = self.make_make()
-# with working_dir(self.build_directory, create=False):
-# make('install')
-
class FetchError(spack.error.SpackError):
"""Raised when something goes wrong during fetch."""