@@ -34,6 +34,15 @@ def _get_tk_version(python_pkg):
3434 raise RuntimeError ('could not guess Tcl/Tk version' )
3535
3636
37+ def _get_tk_libdir (version ):
38+ try :
39+ library = system (('tclsh' + version ,), stdin = 'puts [info library]' )
40+ except SystemError :
41+ raise RuntimeError ('could not locate Tcl/Tk' + version + ' library' )
42+
43+ return os .path .dirname (library )
44+
45+
3746def tcltk_env_string (python_pkg ):
3847 '''Environment for using AppImage's TCl/Tk
3948 '''
@@ -280,22 +289,13 @@ def relocate_python(python=None, appdir=None):
280289 tcltkdir = APPDIR_SHARE + '/tcltk'
281290 if (not os .path .exists (tcltkdir + '/tcl' + tk_version )) or \
282291 (not os .path .exists (tcltkdir + '/tk' + tk_version )):
283- hostdir = '/usr/share/tcltk'
284- if os .path .exists (hostdir ):
285- make_tree (APPDIR_SHARE )
286- copy_tree (hostdir , tcltkdir )
287- else :
288- make_tree (tcltkdir )
289- tclpath = '/usr/share/tcl' + tk_version
290- if not tclpath :
291- raise ValueError ('could not find ' + tclpath )
292- copy_tree (tclpath , tcltkdir + '/tcl' + tk_version )
293-
294- tkpath = '/usr/share/tk' + tk_version
295- if not tkpath :
296- raise ValueError ('could not find ' + tkpath )
297- copy_tree (tkpath , tcltkdir + '/tk' + tk_version )
298-
292+ libdir = _get_tk_libdir (tk_version )
293+ log ('INSTALL' , 'Tcl/Tk' + tk_version )
294+ make_tree (tcltkdir )
295+ tclpath = libdir + '/tcl' + tk_version
296+ copy_tree (tclpath , tcltkdir + '/tcl' + tk_version )
297+ tkpath = libdir + '/tk' + tk_version
298+ copy_tree (tkpath , tcltkdir + '/tk' + tk_version )
299299
300300 # Copy any SSL certificate
301301 cert_file = os .getenv ('SSL_CERT_FILE' )
0 commit comments