Skip to content

Commit

Permalink
Avoid tautologic sanity check and fully clean ebpythonprefixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Flamefire committed Jul 7, 2021
1 parent c3136ae commit 16eabfa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
8 changes: 4 additions & 4 deletions easybuild/easyblocks/p/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
20 changes: 13 additions & 7 deletions easybuild/easyblocks/t/tkinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -78,19 +83,19 @@ 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)

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())
Expand All @@ -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)
Expand Down

0 comments on commit 16eabfa

Please sign in to comment.