Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 65657c2

Browse files
committed
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"
1 parent 7d6392c commit 65657c2

5 files changed

Lines changed: 126 additions & 1 deletion

File tree

Makefile.pre.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ _PYTHON_HOST_PLATFORM=@_PYTHON_HOST_PLATFORM@
208208
BUILD_GNU_TYPE= @build@
209209
HOST_GNU_TYPE= @host@
210210

211+
# Tcl and Tk config info from --with-tcltk-includes and -libs options
212+
TCLTK_INCLUDES= @TCLTK_INCLUDES@
213+
TCLTK_LIBS= @TCLTK_LIBS@
214+
211215
# The task to run while instrument when building the profile-opt target
212216
PROFILE_TASK= $(srcdir)/Tools/pybench/pybench.py -n 2 --with-gc --with-syscheck
213217
#PROFILE_TASK= $(srcdir)/Lib/test/regrtest.py
@@ -493,6 +497,7 @@ sharedmods: $(BUILDPYTHON) pybuilddir.txt
493497
*) quiet="";; \
494498
esac; \
495499
$(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \
500+
_TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \
496501
$(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build
497502

498503
# Build static library

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,9 @@ Build
592592
- Issue #15172: Document NASM 2.10+ as requirement for building OpenSSL 1.0.1
593593
on Windows.
594594

595+
- Issue #1584: Provide options to override default search paths for
596+
Tcl and Tk when building _tkinter.
597+
595598

596599
What's New in Python 3.3.2?
597600
===========================

configure

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,8 @@ LDLAST
644644
USE_THREAD_MODULE
645645
SIGNAL_OBJS
646646
USE_SIGNAL_MODULE
647+
TCLTK_LIBS
648+
TCLTK_INCLUDES
647649
LIBFFI_INCLUDEDIR
648650
PKG_CONFIG
649651
SHLIBS
@@ -793,6 +795,8 @@ with_system_expat
793795
with_system_ffi
794796
with_system_libmpdec
795797
enable_loadable_sqlite_extensions
798+
with_tcltk_includes
799+
with_tcltk_libs
796800
with_dbmliborder
797801
with_signal_module
798802
with_threads
@@ -1465,6 +1469,10 @@ Optional Packages:
14651469
--with-system-ffi build _ctypes module using an installed ffi library
14661470
--with-system-libmpdec build _decimal module using an installed libmpdec
14671471
library
1472+
--with-tcltk-includes='-I...'
1473+
override search for Tcl and Tk include files
1474+
--with-tcltk-libs='-L...'
1475+
override search for Tcl and Tk libs
14681476
--with-dbmliborder=db1:db2:...
14691477
order to check db backends for dbm. Valid value is a
14701478
colon separated string with the backend names
@@ -9222,6 +9230,46 @@ fi
92229230
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_loadable_sqlite_extensions" >&5
92239231
$as_echo "$enable_loadable_sqlite_extensions" >&6; }
92249232

9233+
# Check for --with-tcltk-includes=path and --with-tcltk-libs=path
9234+
9235+
9236+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-tcltk-includes" >&5
9237+
$as_echo_n "checking for --with-tcltk-includes... " >&6; }
9238+
9239+
# Check whether --with-tcltk-includes was given.
9240+
if test "${with_tcltk_includes+set}" = set; then :
9241+
withval=$with_tcltk_includes;
9242+
else
9243+
with_tcltk_includes="default"
9244+
fi
9245+
9246+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_tcltk_includes" >&5
9247+
$as_echo "$with_tcltk_includes" >&6; }
9248+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-tcltk-libs" >&5
9249+
$as_echo_n "checking for --with-tcltk-libs... " >&6; }
9250+
9251+
# Check whether --with-tcltk-libs was given.
9252+
if test "${with_tcltk_libs+set}" = set; then :
9253+
withval=$with_tcltk_libs;
9254+
else
9255+
with_tcltk_libs="default"
9256+
fi
9257+
9258+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_tcltk_libs" >&5
9259+
$as_echo "$with_tcltk_libs" >&6; }
9260+
if test "x$with_tcltk_includes" = xdefault || test "x$with_tcltk_libs" = xdefault
9261+
then
9262+
if test "x$with_tcltk_includes" != "x$with_tcltk_libs"
9263+
then
9264+
as_fn_error $? "use both --with-tcltk-includes='...' and --with-tcltk-libs='...' or neither" "$LINENO" 5
9265+
fi
9266+
TCLTK_INCLUDES=""
9267+
TCLTK_LIBS=""
9268+
else
9269+
TCLTK_INCLUDES="$with_tcltk_includes"
9270+
TCLTK_LIBS="$with_tcltk_libs"
9271+
fi
9272+
92259273
# Check for --with-dbmliborder
92269274
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-dbmliborder" >&5
92279275
$as_echo_n "checking for --with-dbmliborder... " >&6; }

configure.ac

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2270,6 +2270,34 @@ AC_ARG_ENABLE(loadable-sqlite-extensions,
22702270

22712271
AC_MSG_RESULT($enable_loadable_sqlite_extensions)
22722272

2273+
# Check for --with-tcltk-includes=path and --with-tcltk-libs=path
2274+
AC_SUBST(TCLTK_INCLUDES)
2275+
AC_SUBST(TCLTK_LIBS)
2276+
AC_MSG_CHECKING(for --with-tcltk-includes)
2277+
AC_ARG_WITH(tcltk-includes,
2278+
AS_HELP_STRING([--with-tcltk-includes='-I...'], [override search for Tcl and Tk include files]),
2279+
[],
2280+
[with_tcltk_includes="default"])
2281+
AC_MSG_RESULT($with_tcltk_includes)
2282+
AC_MSG_CHECKING(for --with-tcltk-libs)
2283+
AC_ARG_WITH(tcltk-libs,
2284+
AS_HELP_STRING([--with-tcltk-libs='-L...'], [override search for Tcl and Tk libs]),
2285+
[],
2286+
[with_tcltk_libs="default"])
2287+
AC_MSG_RESULT($with_tcltk_libs)
2288+
if test "x$with_tcltk_includes" = xdefault || test "x$with_tcltk_libs" = xdefault
2289+
then
2290+
if test "x$with_tcltk_includes" != "x$with_tcltk_libs"
2291+
then
2292+
AC_MSG_ERROR([use both --with-tcltk-includes='...' and --with-tcltk-libs='...' or neither])
2293+
fi
2294+
TCLTK_INCLUDES=""
2295+
TCLTK_LIBS=""
2296+
else
2297+
TCLTK_INCLUDES="$with_tcltk_includes"
2298+
TCLTK_LIBS="$with_tcltk_libs"
2299+
fi
2300+
22732301
# Check for --with-dbmliborder
22742302
AC_MSG_CHECKING(for --with-dbmliborder)
22752303
AC_ARG_WITH(dbmliborder,

setup.py

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1538,6 +1538,41 @@ class db_found(Exception): pass
15381538

15391539
return missing
15401540

1541+
def detect_tkinter_explicitly(self):
1542+
# Build _tkinter using explicit locations for Tcl/Tk.
1543+
#
1544+
# This is enabled when both arguments are given to ./configure:
1545+
#
1546+
# --with-tcltk-includes="-I/path/to/tclincludes \
1547+
# -I/path/to/tkincludes"
1548+
# --with-tcltk-libs="-L/path/to/tcllibs -ltclm.n \
1549+
# -L/path/to/tklibs -ltkm.n"
1550+
#
1551+
# These values can also be specified or overriden via make:
1552+
# make TCLTK_INCLUDES="..." TCLTK_LIBS="..."
1553+
#
1554+
# This can be useful for building and testing tkinter with multiple
1555+
# versions of Tcl/Tk. Note that a build of Tk depends on a particular
1556+
# build of Tcl so you need to specify both arguments and use care when
1557+
# overriding.
1558+
1559+
# The _TCLTK variables are created in the Makefile sharedmods target.
1560+
tcltk_includes = os.environ.get('_TCLTK_INCLUDES')
1561+
tcltk_libs = os.environ.get('_TCLTK_LIBS')
1562+
if not (tcltk_includes and tcltk_libs):
1563+
# Resume default configuration search.
1564+
return 0
1565+
1566+
extra_compile_args = tcltk_includes.split()
1567+
extra_link_args = tcltk_libs.split()
1568+
ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'],
1569+
define_macros=[('WITH_APPINIT', 1)],
1570+
extra_compile_args = extra_compile_args,
1571+
extra_link_args = extra_link_args,
1572+
)
1573+
self.extensions.append(ext)
1574+
return 1
1575+
15411576
def detect_tkinter_darwin(self, inc_dirs, lib_dirs):
15421577
# The _tkinter module, using frameworks. Since frameworks are quite
15431578
# different the UNIX search logic is not sharable.
@@ -1627,10 +1662,16 @@ def detect_tkinter_darwin(self, inc_dirs, lib_dirs):
16271662
self.extensions.append(ext)
16281663
return 1
16291664

1630-
16311665
def detect_tkinter(self, inc_dirs, lib_dirs):
16321666
# The _tkinter module.
16331667

1668+
# Check whether --with-tcltk-includes and --with-tcltk-libs were
1669+
# configured or passed into the make target. If so, use these values
1670+
# to build tkinter and bypass the searches for Tcl and TK in standard
1671+
# locations.
1672+
if self.detect_tkinter_explicitly():
1673+
return
1674+
16341675
# Rather than complicate the code below, detecting and building
16351676
# AquaTk is a separate method. Only one Tkinter will be built on
16361677
# Darwin - either AquaTk, if it is found, or X11 based Tk.

0 commit comments

Comments
 (0)