diff --git a/easybuild/easyblocks/p/python.py b/easybuild/easyblocks/p/python.py index 700c726cd77..c436eb05a38 100644 --- a/easybuild/easyblocks/p/python.py +++ b/easybuild/easyblocks/p/python.py @@ -180,7 +180,7 @@ def _get_pip_ext_version(self): def prepare_step(self, *args, **kwargs): super(EB_Python, self).prepare_step(*args, **kwargs) - if self.cfg['ebpythonprefixes']: + if self.cfg.get('ebpythonprefixes'): easybuild_subdir = log_path() self.pythonpath = os.path.join(easybuild_subdir, 'python') else: @@ -459,7 +459,7 @@ def install_step(self): if not os.path.isfile(pip_binary_path): symlink('pip' + self.pyshortver, pip_binary_path, use_abspath_source=False) - if self.cfg['ebpythonprefixes']: + if self.cfg.get('ebpythonprefixes'): write_file(os.path.join(self.installdir, self.pythonpath, 'sitecustomize.py'), SITECUSTOMIZE) # symlink lib/python*/lib-dynload to lib64/python*/lib-dynload if it doesn't exist; @@ -535,7 +535,7 @@ def sanity_check_step(self): else: self.log.info("No errors found in output of %s: %s", cmd, out) - if self.cfg['ebpythonprefixes']: + if self.cfg.get('ebpythonprefixes'): self._sanity_check_ebpythonprefixes() pyver = 'python' + self.pyshortver @@ -587,7 +587,7 @@ def make_module_extra(self, *args, **kwargs): """Add path to sitecustomize.py to $PYTHONPATH""" txt = super(EB_Python, self).make_module_extra() - if self.cfg['ebpythonprefixes']: + if self.cfg.get('ebpythonprefixes'): txt += self.module_generator.prepend_paths('PYTHONPATH', self.pythonpath) return txt diff --git a/easybuild/easyblocks/t/tkinter.py b/easybuild/easyblocks/t/tkinter.py index 5a9088ea210..c8a5a4e7702 100644 --- a/easybuild/easyblocks/t/tkinter.py +++ b/easybuild/easyblocks/t/tkinter.py @@ -55,10 +55,15 @@ def extra_options(): """Disable EBPYTHONPREFIXES.""" extra_vars = EB_Python.extra_options() # Not used for Tkinter - extra_vars['ebpythonprefixes'][0] = False + del extra_vars['ebpythonprefixes'] return extra_vars + def __init__(self, *args, **kwargs): + """Initialize Tkinter-specific variables.""" + super(EB_Tkinter, self).__init__(*args, **kwargs) + self.tkinter_so_basename = None + def configure_step(self): """Check for Tk before configuring""" tk = get_software_root('Tk') @@ -78,11 +83,11 @@ def install_step(self): tmpdir = tempfile.mkdtemp(dir=self.builddir) - tkinter_so_basename = self.get_tkinter_so_basename(False) + self.tkinter_so_basename = self.get_tkinter_so_basename(False) if LooseVersion(self.version) >= LooseVersion('3'): - tkparts = ["tkinter", os.path.join("lib-dynload", tkinter_so_basename)] + tkparts = ["tkinter", os.path.join("lib-dynload", self.tkinter_so_basename)] else: - tkparts = ["lib-tk", os.path.join("lib-dynload", tkinter_so_basename)] + tkparts = ["lib-tk", os.path.join("lib-dynload", self.tkinter_so_basename)] pylibdir = os.path.join(self.installdir, det_pylibdir()) copy([os.path.join(os.path.dirname(pylibdir), x) for x in tkparts], tmpdir) @@ -90,7 +95,7 @@ def install_step(self): remove_dir(self.installdir) move_file(os.path.join(tmpdir, tkparts[0]), os.path.join(pylibdir, tkparts[0])) - move_file(os.path.join(tmpdir, tkinter_so_basename), os.path.join(pylibdir, tkinter_so_basename)) + move_file(os.path.join(tmpdir, self.tkinter_so_basename), os.path.join(pylibdir, self.tkinter_so_basename)) def get_tkinter_so_basename(self, in_final_dir): pylibdir = os.path.join(self.installdir, det_pylibdir()) @@ -115,10 +120,11 @@ def sanity_check_step(self): tkinter = 'Tkinter' custom_commands = ["python -c 'import %s'" % tkinter] - tkinter_so_basename = self.get_tkinter_so_basename(True) + if not self.tkinter_so_basename: + self.tkinter_so_basename = self.get_tkinter_so_basename(True) custom_paths = { - 'files': [os.path.join(det_pylibdir(), tkinter_so_basename)], + 'files': [os.path.join(det_pylibdir(), self.tkinter_so_basename)], 'dirs': ['lib'] } super(EB_Python, self).sanity_check_step(custom_commands=custom_commands, custom_paths=custom_paths)