summaryrefslogtreecommitdiff
path: root/var
diff options
context:
space:
mode:
Diffstat (limited to 'var')
-rw-r--r--var/spack/repos/builtin/packages/python/package.py42
-rw-r--r--var/spack/repos/builtin/packages/tcl/package.py6
-rw-r--r--var/spack/repos/builtin/packages/tk/package.py6
3 files changed, 48 insertions, 6 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..4a957fd9de 100644
--- a/var/spack/repos/builtin/packages/tcl/package.py
+++ b/var/spack/repos/builtin/packages/tcl/package.py
@@ -44,6 +44,12 @@ class Tcl(Package):
depends_on('zlib')
+ 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)
diff --git a/var/spack/repos/builtin/packages/tk/package.py b/var/spack/repos/builtin/packages/tk/package.py
index 330e1c77f5..097cd411f1 100644
--- a/var/spack/repos/builtin/packages/tk/package.py
+++ b/var/spack/repos/builtin/packages/tk/package.py
@@ -40,6 +40,12 @@ class Tk(Package):
depends_on("tcl")
+ 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,