Skip to content

Commit c75e740

Browse files
Merge pull request #3867 from Thyre/20250804011203_new_pr_python
enhance Python easyblock to handle Tcl/Tk 9.0+ with external libtommath
2 parents ad2b59c + 9cc0335 commit c75e740

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

easybuild/easyblocks/p/python.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -578,21 +578,37 @@ def configure_step(self):
578578
tclver = get_software_version('Tcl')
579579
tkver = get_software_version('Tk')
580580
tcltk_maj_min_ver = '.'.join(tclver.split('.')[:2])
581+
tcltk_maj_ver = tkver.split('.')[0]
581582
if tcltk_maj_min_ver != '.'.join(tkver.split('.')[:2]):
582583
raise EasyBuildError("Tcl and Tk major/minor versions don't match: %s vs %s", tclver, tkver)
583584

584585
tcl_libdir = os.path.join(tcl, get_software_libdir('Tcl'))
585586
tk_libdir = os.path.join(tk, get_software_libdir('Tk'))
586-
tcltk_libs = "-L%(tcl_libdir)s -L%(tk_libdir)s -ltcl%(maj_min_ver)s -ltk%(maj_min_ver)s" % {
587+
if LooseVersion(tkver) > '9.0':
588+
tk_libname = f'tcl{tcltk_maj_ver}tk{tcltk_maj_min_ver}'
589+
else:
590+
tk_libname = f'tk{tcltk_maj_min_ver}'
591+
tcltk_libs = f"-L%(tcl_libdir)s -L%(tk_libdir)s -ltcl%(maj_min_ver)s -l{tk_libname}" % {
587592
'tcl_libdir': tcl_libdir,
588593
'tk_libdir': tk_libdir,
589594
'maj_min_ver': tcltk_maj_min_ver,
590595
}
596+
# Determine if we need to pass -DTCL_WITH_EXTERNAL_TOMMATH
597+
# by checking if libtommath has a software root. If we don't,
598+
# loading Tkinter will fail, causing the module to be deleted
599+
# before installation. This would typically be handled by
600+
# pkg-config.
601+
libtommath = get_software_root('libtommath')
602+
libtommath_define = ''
603+
if libtommath:
604+
libtommath_define += '-DTCL_WITH_EXTERNAL_TOMMATH'
605+
591606
if LooseVersion(self.version) < '3.11':
592-
self.cfg.update('configopts', "--with-tcltk-includes='-I%s/include -I%s/include'" % (tcl, tk))
607+
self.cfg.update('configopts',
608+
"--with-tcltk-includes='-I%s/include -I%s/include %s'" % (tcl, tk, libtommath_define))
593609
self.cfg.update('configopts', "--with-tcltk-libs='%s'" % tcltk_libs)
594610
else:
595-
env.setvar('TCLTK_CFLAGS', '-I%s/include -I%s/include' % (tcl, tk))
611+
env.setvar('TCLTK_CFLAGS', '-I%s/include -I%s/include %s' % (tcl, tk, libtommath_define))
596612
env.setvar('TCLTK_LIBS', tcltk_libs)
597613

598614
# This matters e.g. when python installs the bundled pip & setuptools (for >= 3.4)

0 commit comments

Comments
 (0)