From 782d8b909c2ed85dab44a2ba244626e1acdd9453 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Sun, 8 Jan 2017 12:47:56 -0600 Subject: [PATCH] Allow configure to be located in different directory --- lib/spack/spack/build_systems/autotools.py | 20 +++++++++++++----- .../repos/builtin/packages/tcl/package.py | 17 ++++++++------- .../repos/builtin/packages/tk/package.py | 21 +++++++++++-------- .../repos/builtin/packages/zlib/package.py | 12 ++++------- 4 files changed, 41 insertions(+), 29 deletions(-) diff --git a/lib/spack/spack/build_systems/autotools.py b/lib/spack/spack/build_systems/autotools.py index 5225f4e7173085..10df92e6b05226 100644 --- a/lib/spack/spack/build_systems/autotools.py +++ b/lib/spack/spack/build_systems/autotools.py @@ -31,7 +31,8 @@ from subprocess import check_call import llnl.util.tty as tty -from llnl.util.filesystem import working_dir +from spack.util.executable import Executable +from llnl.util.filesystem import working_dir, join_path from spack.package import PackageBase @@ -125,6 +126,10 @@ def do_patch_config_guess(self): return False + def root_configure_dir(self): + """Directory containing configure script""" + return self.stage.source_path + def build_directory(self): """Override to provide another place to build the package""" return self.stage.source_path @@ -145,9 +150,10 @@ def autoreconf(self, spec, prefix): def is_configure_or_die(self): """Checks the presence of a ``configure`` file after the autoreconf phase""" - if not os.path.exists('configure'): - raise RuntimeError( - 'configure script not found in {0}'.format(os.getcwd())) + with working_dir(self.root_configure_dir()): + if not os.path.exists('configure'): + raise RuntimeError( + 'configure script not found in {0}'.format(os.getcwd())) def configure_args(self): """Method to be overridden. Should return an iterable containing @@ -160,8 +166,12 @@ def configure(self, spec, prefix): and an appropriately set prefix """ options = ['--prefix={0}'.format(prefix)] + self.configure_args() + + configure_path = join_path(self.root_configure_dir(), 'configure') + configure = Executable(os.path.abspath(configure_path)) + with working_dir(self.build_directory(), create=True): - inspect.getmodule(self).configure(*options) + configure(*options) def build(self, spec, prefix): """Make the build targets""" diff --git a/var/spack/repos/builtin/packages/tcl/package.py b/var/spack/repos/builtin/packages/tcl/package.py index 16d896acc6c0ae..ab1061212cebbc 100644 --- a/var/spack/repos/builtin/packages/tcl/package.py +++ b/var/spack/repos/builtin/packages/tcl/package.py @@ -25,7 +25,7 @@ from spack import * -class Tcl(Package): +class Tcl(AutotoolsPackage): """Tcl (Tool Command Language) is a very powerful but easy to learn dynamic programming language, suitable for a very wide range of uses, including web and desktop applications, @@ -52,10 +52,13 @@ def setup_environment(self, spack_env, env): env.set('TCL_LIBRARY', join_path(self.prefix.lib, 'tcl{0}'.format( self.spec.version.up_to(2)))) - def install(self, spec, prefix): - with working_dir('unix'): - configure("--prefix={0}".format(prefix)) - make() - make("install") - with working_dir(prefix.bin): + def root_configure_dir(self): + return 'unix' + + def build_directory(self): + return 'unix' + + @AutotoolsPackage.sanity_check('install') + def symlink_tclsh(self): + with working_dir(self.prefix.bin): symlink('tclsh{0}'.format(self.version.up_to(2)), 'tclsh') diff --git a/var/spack/repos/builtin/packages/tk/package.py b/var/spack/repos/builtin/packages/tk/package.py index 1abcd26a240754..b369bee5ba9931 100644 --- a/var/spack/repos/builtin/packages/tk/package.py +++ b/var/spack/repos/builtin/packages/tk/package.py @@ -25,7 +25,7 @@ from spack import * -class Tk(Package): +class Tk(AutotoolsPackage): """Tk is a graphical user interface toolkit that takes developing desktop applications to a higher level than conventional approaches. Tk is the standard GUI not only for Tcl, but for @@ -46,15 +46,18 @@ def url_for_version(self, version): base_url = "http://prdownloads.sourceforge.net/tcl" return "{0}/tk{1}-src.tar.gz".format(base_url, version) - def setup_environment(self, spack_env, env): + def setup_environment(self, spack_env, run_env): # When using Tkinter from within spack provided python+tk, python # will not be able to find Tcl/Tk unless TK_LIBRARY is set. - env.set('TK_LIBRARY', join_path(self.prefix.lib, 'tk{0}'.format( + run_env.set('TK_LIBRARY', join_path(self.prefix.lib, 'tk{0}'.format( self.spec.version.up_to(2)))) - def install(self, spec, prefix): - with working_dir('unix'): - configure("--prefix={0}".format(prefix), - "--with-tcl={0}".format(spec['tcl'].prefix.lib)) - make() - make("install") + def root_configure_dir(self): + return 'unix' + + def build_directory(self): + return 'unix' + + def configure_args(self): + spec = self.spec + return ['--with-tcl={0}'.format(spec['tcl'].prefix.lib)] diff --git a/var/spack/repos/builtin/packages/zlib/package.py b/var/spack/repos/builtin/packages/zlib/package.py index a20f6ff802b0ad..bd824c70f4238e 100644 --- a/var/spack/repos/builtin/packages/zlib/package.py +++ b/var/spack/repos/builtin/packages/zlib/package.py @@ -35,17 +35,13 @@ class Zlib(AutotoolsPackage): version('1.2.10', 'd9794246f853d15ce0fcbf79b9a3cf13') # author had this to say about 1.2.9.... - # Due to the bug fixes, any installations of 1.2.9 should be immediately + # Due to the bug fixes, any installations of 1.2.9 should be immediately # replaced with 1.2.10. version('1.2.8', '44d667c142d7cda120332623eab69f40') variant('pic', default=True, description='Produce position-independent code (for shared libs)') - def configure(self, spec, prefix): - - if '+pic' in spec: - environ['CFLAGS'] = self.compiler.pic_flag - - config_args = ['--prefix', prefix] - configure(*config_args) + def setup_environment(self, spack_env, run_env): + if '+pic' in self.spec: + spack_env.set('CFLAGS', self.compiler.pic_flag)