aboutsummaryrefslogtreecommitdiff
path: root/gnu/packages/patches/matplotlib-setupext-tk.patch
blob: 37c3d686e0d02c6a166864b6887214d1c00a8195 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Use 'pkg-config' instead of heuristics to find 'tk' flags.

--- matplotlib-1.4.3/setupext.py.orig	2015-12-01 14:21:19.554417453 +0100
+++ matplotlib-1.4.3/setupext.py	2015-12-02 10:39:47.282363530 +0100
@@ -1457,7 +1457,7 @@
             p = subprocess.Popen(
                 '. %s ; eval echo ${%s}' % (file, varname),
                 shell=True,
-                executable="/bin/sh",
+                executable="sh",
                 stdout=subprocess.PIPE)
             result = p.communicate()[0]
             return result.decode('ascii')
@@ -1601,8 +1601,19 @@
             #      of distros.
 
             # Query Tcl/Tk system for library paths and version string
+            def getoutput(s):
+                ret = os.popen(s).read().strip()
+                return ret
             try:
-                tcl_lib_dir, tk_lib_dir, tk_ver = self.query_tcltk()
+                pkg_config_libs = getoutput('pkg-config --libs-only-L tk').split()
+                # drop '-L' part of strings
+                pkg_config_libs = [s[2:] for s in pkg_config_libs]
+                pkg_config_ver = getoutput('pkg-config --modversion tk')
+                tk_ver = re.match(r"(\d+.\d+)[\d.]*", pkg_config_ver).group(1)
+                tcl_lib_dir = next(s for s in pkg_config_libs
+                                   if re.match(r".*-tcl-.*", s)) + '/tcl' + tk_ver
+                tk_lib_dir = next(s for s in pkg_config_libs
+                                  if re.match(r".*-tk-.*", s)) + '/tk' + tk_ver
             except:
                 tk_ver = ''
                 result = self.hardcoded_tcl_config()