diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2016-07-19 09:41:12 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-19 09:41:12 -0700 |
commit | a64a2e72cf361923b8a2e00a5b3ed87cb5d59bd2 (patch) | |
tree | 56ecd6e60ae7288fdf3ad561bb1d27068fbac453 | |
parent | c4b4ce7d859a21728c5c1efbb19dffeacfa0c793 (diff) | |
parent | ea425a101a698705609698771c0542d2be70987e (diff) | |
download | spack-a64a2e72cf361923b8a2e00a5b3ed87cb5d59bd2.tar.gz spack-a64a2e72cf361923b8a2e00a5b3ed87cb5d59bd2.tar.bz2 spack-a64a2e72cf361923b8a2e00a5b3ed87cb5d59bd2.tar.xz spack-a64a2e72cf361923b8a2e00a5b3ed87cb5d59bd2.zip |
Merge pull request #1226 from adamjstewart/features/tkinter
Add Tkinter support for Python
-rw-r--r-- | var/spack/repos/builtin/packages/python/package.py | 42 | ||||
-rw-r--r-- | var/spack/repos/builtin/packages/tcl/package.py | 16 | ||||
-rw-r--r-- | var/spack/repos/builtin/packages/tk/package.py | 19 |
3 files changed, 62 insertions, 15 deletions
diff --git a/var/spack/repos/builtin/packages/python/package.py b/var/spack/repos/builtin/packages/python/package.py index 516b5c6cfe..bbb1e9c13a 100644 --- a/var/spack/repos/builtin/packages/python/package.py +++ b/var/spack/repos/builtin/packages/python/package.py @@ -53,6 +53,7 @@ class Python(Package): extendable = True + variant('tk', default=False, description='Provide support for Tkinter') variant('ucs4', default=False, description='Enable UCS4 (wide) unicode strings') # From https://docs.python.org/2/c-api/unicode.html: Python's default # builds use a 16-bit type for Py_UNICODE and store Unicode values @@ -68,6 +69,8 @@ class Python(Package): depends_on("ncurses") depends_on("sqlite") depends_on("zlib") + depends_on("tk", when="+tk") + depends_on("tcl", when="+tk") def install(self, spec, prefix): # Need this to allow python build to find the Python installation. @@ -77,24 +80,32 @@ class Python(Package): # Rest of install is pretty standard except setup.py needs to # be able to read the CPPFLAGS and LDFLAGS as it scans for the # library and headers to build - cppflags = ' -I'.join([ + include_dirs = [ spec['openssl'].prefix.include, spec['bzip2'].prefix.include, spec['readline'].prefix.include, spec['ncurses'].prefix.include, spec['sqlite'].prefix.include, spec['zlib'].prefix.include - ]) + ] - ldflags = ' -L'.join([ + library_dirs = [ spec['openssl'].prefix.lib, spec['bzip2'].prefix.lib, spec['readline'].prefix.lib, spec['ncurses'].prefix.lib, spec['sqlite'].prefix.lib, spec['zlib'].prefix.lib - ]) + ] + + if '+tk' in spec: + include_dirs.extend([ + spec['tk'].prefix.include, spec['tcl'].prefix.include + ]) + library_dirs.extend([ + spec['tk'].prefix.lib, spec['tcl'].prefix.lib + ]) config_args = [ "--prefix={0}".format(prefix), "--with-threads", "--enable-shared", - "CPPFLAGS=-I{0}".format(cppflags), - "LDFLAGS=-L{0}".format(ldflags) + "CPPFLAGS=-I{0}".format(" -I".join(include_dirs)), + "LDFLAGS=-L{0}".format(" -L".join(library_dirs)) ] if '+ucs4' in spec: @@ -116,6 +127,25 @@ class Python(Package): self.filter_compilers(spec, prefix) + # TODO: Once better testing support is integrated, add the following tests + # https://wiki.python.org/moin/TkInter + # + # if '+tk' in spec: + # env['TK_LIBRARY'] = join_path(spec['tk'].prefix.lib, + # 'tk{0}'.format(spec['tk'].version.up_to(2))) + # env['TCL_LIBRARY'] = join_path(spec['tcl'].prefix.lib, + # 'tcl{0}'.format(spec['tcl'].version.up_to(2))) + # + # $ python + # >>> import _tkinter + # + # if spec.satisfies('@3:') + # >>> import tkinter + # >>> tkinter._test() + # else: + # >>> import Tkinter + # >>> Tkinter._test() + def filter_compilers(self, spec, prefix): """Run after install to tell the configuration files and Makefiles to use the compilers that Spack built the package with. diff --git a/var/spack/repos/builtin/packages/tcl/package.py b/var/spack/repos/builtin/packages/tcl/package.py index a4d8b515bb..ef922314d8 100644 --- a/var/spack/repos/builtin/packages/tcl/package.py +++ b/var/spack/repos/builtin/packages/tcl/package.py @@ -24,6 +24,7 @@ ############################################################################## from spack import * + class Tcl(Package): """Tcl (Tool Command Language) is a very powerful but easy to learn dynamic programming language, suitable for a very wide @@ -34,9 +35,6 @@ class Tcl(Package): extensible.""" homepage = "http://www.tcl.tk" - def url_for_version(self, version): - return 'http://prdownloads.sourceforge.net/tcl/tcl%s-src.tar.gz' % version - version('8.6.5', '0e6426a4ca9401825fbc6ecf3d89a326') version('8.6.4', 'd7cbb91f1ded1919370a30edd1534304') version('8.6.3', 'db382feca91754b7f93da16dc4cdad1f') @@ -44,8 +42,18 @@ class Tcl(Package): depends_on('zlib') + def url_for_version(self, version): + base_url = 'http://prdownloads.sourceforge.net/tcl' + return '{0}/tcl{1}-src.tar.gz'.format(base_url, version) + + def setup_environment(self, spack_env, env): + # When using Tkinter from within spack provided python+tk, python + # will not be able to find Tcl/Tk unless TCL_LIBRARY is set. + 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=%s" % prefix) + configure("--prefix={0}".format(prefix)) make() make("install") diff --git a/var/spack/repos/builtin/packages/tk/package.py b/var/spack/repos/builtin/packages/tk/package.py index 330e1c77f5..894d3af6cc 100644 --- a/var/spack/repos/builtin/packages/tk/package.py +++ b/var/spack/repos/builtin/packages/tk/package.py @@ -24,6 +24,7 @@ ############################################################################## from spack import * + class Tk(Package): """Tk is a graphical user interface toolkit that takes developing desktop applications to a higher level than conventional @@ -33,16 +34,24 @@ class Tk(Package): and more.""" homepage = "http://www.tcl.tk" - def url_for_version(self, version): - return "http://prdownloads.sourceforge.net/tcl/tk%s-src.tar.gz" % version - + version('8.6.5', '11dbbd425c3e0201f20d6a51482ce6c4') version('8.6.3', '85ca4dbf4dcc19777fd456f6ee5d0221') depends_on("tcl") + 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): + # 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( + self.spec.version.up_to(2)))) + def install(self, spec, prefix): with working_dir('unix'): - configure("--prefix=%s" % prefix, - "--with-tcl=%s" % spec['tcl'].prefix.lib) + configure("--prefix={0}".format(prefix), + "--with-tcl={0}".format(spec['tcl'].prefix.lib)) make() make("install") |