summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorNed Deily <nad@acm.org>2013-10-25 00:34:44 -0700
committerNed Deily <nad@acm.org>2013-10-25 00:34:44 -0700
commit31037c71001ab76e0fb6e436df733e194aced644 (patch)
tree65fe22894889a91fcfe08e2e8b822a265ddbac3f /setup.py
parentb82bb3b55cdf97abc402188585e2da727d692b92 (diff)
downloadcpython-31037c71001ab76e0fb6e436df733e194aced644.tar.gz
Issue #1584: Provide options to override default search paths for Tcl and Tk
when building _tkinter. configure has two new options; if used, both must be specified: ./configure \ --with-tcltk-includes="-I/opt/local/include" \ --with-tcltk-libs="-L/opt/local/lib -ltcl8.5 -ltk8.5" In addition, the options can be overridden with make: make \ TCLTK_INCLUDES="-I/opt/local/include" \ TCLTK_LIBS="-L/opt/local/lib -ltcl8.6 -ltk8.6"
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py43
1 files changed, 42 insertions, 1 deletions
diff --git a/setup.py b/setup.py
index fe2dd6e6d1..19a7b291e1 100644
--- a/setup.py
+++ b/setup.py
@@ -1538,6 +1538,41 @@ class PyBuildExt(build_ext):
return missing
+ def detect_tkinter_explicitly(self):
+ # Build _tkinter using explicit locations for Tcl/Tk.
+ #
+ # This is enabled when both arguments are given to ./configure:
+ #
+ # --with-tcltk-includes="-I/path/to/tclincludes \
+ # -I/path/to/tkincludes"
+ # --with-tcltk-libs="-L/path/to/tcllibs -ltclm.n \
+ # -L/path/to/tklibs -ltkm.n"
+ #
+ # These values can also be specified or overriden via make:
+ # make TCLTK_INCLUDES="..." TCLTK_LIBS="..."
+ #
+ # This can be useful for building and testing tkinter with multiple
+ # versions of Tcl/Tk. Note that a build of Tk depends on a particular
+ # build of Tcl so you need to specify both arguments and use care when
+ # overriding.
+
+ # The _TCLTK variables are created in the Makefile sharedmods target.
+ tcltk_includes = os.environ.get('_TCLTK_INCLUDES')
+ tcltk_libs = os.environ.get('_TCLTK_LIBS')
+ if not (tcltk_includes and tcltk_libs):
+ # Resume default configuration search.
+ return 0
+
+ extra_compile_args = tcltk_includes.split()
+ extra_link_args = tcltk_libs.split()
+ ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'],
+ define_macros=[('WITH_APPINIT', 1)],
+ extra_compile_args = extra_compile_args,
+ extra_link_args = extra_link_args,
+ )
+ self.extensions.append(ext)
+ return 1
+
def detect_tkinter_darwin(self, inc_dirs, lib_dirs):
# The _tkinter module, using frameworks. Since frameworks are quite
# different the UNIX search logic is not sharable.
@@ -1627,10 +1662,16 @@ class PyBuildExt(build_ext):
self.extensions.append(ext)
return 1
-
def detect_tkinter(self, inc_dirs, lib_dirs):
# The _tkinter module.
+ # Check whether --with-tcltk-includes and --with-tcltk-libs were
+ # configured or passed into the make target. If so, use these values
+ # to build tkinter and bypass the searches for Tcl and TK in standard
+ # locations.
+ if self.detect_tkinter_explicitly():
+ return
+
# Rather than complicate the code below, detecting and building
# AquaTk is a separate method. Only one Tkinter will be built on
# Darwin - either AquaTk, if it is found, or X11 based Tk.