@@ -1879,18 +1879,34 @@ def detect_modules(self):
1879
1879
self .add (Extension ('xxlimited' , ['xxlimited.c' ]))
1880
1880
self .add (Extension ('xxlimited_35' , ['xxlimited_35.c' ]))
1881
1881
1882
- def detect_tkinter_explicitly (self ):
1883
- # Build _tkinter using explicit locations for Tcl/Tk.
1882
+ def detect_tkinter_fromenv (self ):
1883
+ # Build _tkinter using the Tcl/Tk locations specified by
1884
+ # the _TCLTK_INCLUDES and _TCLTK_LIBS environment variables.
1885
+ # This method is meant to be invoked by detect_tkinter().
1884
1886
#
1885
- # This is enabled when both arguments are given to ./configure:
1887
+ # The variables can be set via one of the following ways.
1886
1888
#
1889
+ # - Automatically, at configuration time, by using pkg-config.
1890
+ # The tool is called by the configure script.
1891
+ # Additional pkg-config configuration paths can be set via the
1892
+ # PKG_CONFIG_PATH environment variable.
1893
+ #
1894
+ # PKG_CONFIG_PATH=".../lib/pkgconfig" ./configure ...
1895
+ #
1896
+ # - Explicitly, at configuration time by setting both
1897
+ # --with-tcltk-includes and --with-tcltk-libs.
1898
+ #
1899
+ # ./configure ... \
1887
1900
# --with-tcltk-includes="-I/path/to/tclincludes \
1888
1901
# -I/path/to/tkincludes"
1889
1902
# --with-tcltk-libs="-L/path/to/tcllibs -ltclm.n \
1890
1903
# -L/path/to/tklibs -ltkm.n"
1891
1904
#
1892
- # These values can also be specified or overridden via make:
1893
- # make TCLTK_INCLUDES="..." TCLTK_LIBS="..."
1905
+ # - Explicitly, at compile time, by passing TCLTK_INCLUDES and
1906
+ # TCLTK_LIBS to the make target.
1907
+ # This will override any configuration-time option.
1908
+ #
1909
+ # make TCLTK_INCLUDES="..." TCLTK_LIBS="..."
1894
1910
#
1895
1911
# This can be useful for building and testing tkinter with multiple
1896
1912
# versions of Tcl/Tk. Note that a build of Tk depends on a particular
@@ -1914,6 +1930,7 @@ def detect_tkinter_explicitly(self):
1914
1930
1915
1931
def detect_tkinter_darwin (self ):
1916
1932
# Build default _tkinter on macOS using Tcl and Tk frameworks.
1933
+ # This method is meant to be invoked by detect_tkinter().
1917
1934
#
1918
1935
# The macOS native Tk (AKA Aqua Tk) and Tcl are most commonly
1919
1936
# built and installed as macOS framework bundles. However,
@@ -1932,16 +1949,20 @@ def detect_tkinter_darwin(self):
1932
1949
# search only the SDK's /Library/Frameworks (normally empty)
1933
1950
# and /System/Library/Frameworks.
1934
1951
#
1935
- # Any other use case should be able to be handled explicitly by
1936
- # using the options described above in detect_tkinter_explicitly().
1937
- # In particular it would be good to handle here the case where
1952
+ # Any other use cases are handled either by detect_tkinter_fromenv(),
1953
+ # or detect_tkinter(). The former handles non-standard locations of
1954
+ # Tcl/Tk, defined via the _TCLTK_INCLUDES and _TCLTK_LIBS environment
1955
+ # variables. The latter handles any Tcl/Tk versions installed in
1956
+ # standard Unix directories.
1957
+ #
1958
+ # It would be desirable to also handle here the case where
1938
1959
# you want to build and link with a framework build of Tcl and Tk
1939
1960
# that is not in /Library/Frameworks, say, in your private
1940
1961
# $HOME/Library/Frameworks directory or elsewhere. It turns
1941
1962
# out to be difficult to make that work automatically here
1942
1963
# without bringing into play more tools and magic. That case
1943
1964
# can be handled using a recipe with the right arguments
1944
- # to detect_tkinter_explicitly ().
1965
+ # to detect_tkinter_fromenv ().
1945
1966
#
1946
1967
# Note also that the fallback case here is to try to use the
1947
1968
# Apple-supplied Tcl and Tk frameworks in /System/Library but
@@ -2041,12 +2062,17 @@ def detect_tkinter_darwin(self):
2041
2062
2042
2063
def detect_tkinter (self ):
2043
2064
# The _tkinter module.
2065
+ #
2066
+ # Detection of Tcl/Tk is attempted in the following order:
2067
+ # - Through environment variables.
2068
+ # - Platform specific detection of Tcl/Tk (currently only macOS).
2069
+ # - Search of various standard Unix header/library paths.
2070
+ #
2071
+ # Detection stops at the first successful method.
2044
2072
2045
- # Check whether --with-tcltk-includes and --with-tcltk-libs were
2046
- # configured or passed into the make target. If so, use these values
2047
- # to build tkinter and bypass the searches for Tcl and TK in standard
2048
- # locations.
2049
- if self .detect_tkinter_explicitly ():
2073
+ # Check for Tcl and Tk at the locations indicated by _TCLTK_INCLUDES
2074
+ # and _TCLTK_LIBS environment variables.
2075
+ if self .detect_tkinter_fromenv ():
2050
2076
return True
2051
2077
2052
2078
# Rather than complicate the code below, detecting and building
0 commit comments