Use a locally built Tk for Python?

Ned Deily nad at acm.org
Mon Jun 4 15:56:08 EDT 2012


In article 
<900b402d-c6b0-4e00-beea-a18417764ee8 at b26g2000vbt.googlegroups.com>,
> I have multiple Pythons locally installed so that I can test against
> different versions. (On a 64-bit Debian stable system.)
> 
> All of them use the system's Tcl/Tk installation. However, I want to
> make some of them use a locally build Tcl/Tk that has a small
> customization.
> 
> There doesn't seem to be any --with-tk or --with-tcl options for
> configure that would allow me to say where my local Tcl/Tk is.
> 
> So I ran ./configure --prefix=/home/mark/opt/py32tkmod
> 
> And then I tried editing Modules/Setup: I just uncommented and edited
> the _tkinter line as follows:
> 
> _tkinter _tkinter.c tkappinit.c -DWITH_APPINIT \
>     -L/home/mark/opt/tcltk85/lib \
>     -I/home/mark/opt/tcltk85/include \
>     -I/usr/X11R6/include \
>     -ltk8.5 -ltcl8.5 \
>     -L/usr/X11R6/lib \
>     -lX11
> 
> But when I run ~/opt/py32tkmod/bin/python3 tkinter-test.pyw the system
> tk is being used not my customized one.

AFAIK, on Unix-y systems Modules/Setup isn't normally used to configure 
the building of _tkinter anymore.  The relevant code is in Python's 
setup.py.  Search there for "_tkinter" and "detect_tkinter".  You'll 
find a lot of platform-specific hacks but you should be able to 
substitute your own version of Tcl/Tk through the use of ./configure 
arguments, most likely by adding your Tcl/Tk directories to the 
INCLUDEDIR and LIBDIR variables; see the beginning of detect_modules() 
in setup.py.

-- 
 Ned Deily,
 nad at acm.org




More information about the Python-list mailing list