diff --git a/easybuild/easyblocks/generic/pythonpackage.py b/easybuild/easyblocks/generic/pythonpackage.py index de4bd0b7bc1..3766ff61fe2 100644 --- a/easybuild/easyblocks/generic/pythonpackage.py +++ b/easybuild/easyblocks/generic/pythonpackage.py @@ -422,6 +422,14 @@ def __init__(self, *args, **kwargs): self.use_setup_py = False self.determine_install_command() + # avoid that pip (ab)uses $HOME/.cache/pip + # cfr. https://pip.pypa.io/en/stable/reference/pip_install/#caching + env.setvar('XDG_CACHE_HOME', os.path.join(self.builddir, 'xdg-cache-home')) + self.log.info("Using %s as pip cache directory", os.environ['XDG_CACHE_HOME']) + # Users or sites may require using a virtualenv for user installations + # We need to disable this to be able to install into the modules + env.setvar('PIP_REQUIRE_VIRTUALENV', 'false') + def determine_install_command(self): """ Determine install command to use. @@ -452,11 +460,6 @@ def determine_install_command(self): if pip_no_index or (pip_no_index is None and self.cfg.get('download_dep_fail')): self.cfg.update('installopts', '--no-index') - # avoid that pip (ab)uses $HOME/.cache/pip - # cfr. https://pip.pypa.io/en/stable/reference/pip_install/#caching - env.setvar('XDG_CACHE_HOME', tempfile.gettempdir()) - self.log.info("Using %s as pip cache directory", os.environ['XDG_CACHE_HOME']) - else: self.use_setup_py = True self.install_cmd = SETUP_PY_INSTALL_CMD