From 819c0a191e42fce9f3c15209bc9497789ceebfe6 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Thu, 27 Jun 2024 13:20:25 +0200 Subject: [PATCH 1/3] make PythonPackage use the build dir for $XDG_CACHE_HOME Using the tempdir usually works but the contents of that folder are usually build artifacts. As they might become rather large use the builddir instead. As an alternative `os.path.abspath(build_path())` could be used but that might clash with parallel installations. --- easybuild/easyblocks/generic/pythonpackage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easybuild/easyblocks/generic/pythonpackage.py b/easybuild/easyblocks/generic/pythonpackage.py index de4bd0b7bc1..05f48879ee0 100644 --- a/easybuild/easyblocks/generic/pythonpackage.py +++ b/easybuild/easyblocks/generic/pythonpackage.py @@ -454,7 +454,7 @@ def determine_install_command(self): # 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()) + 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']) else: From 0c44bb6e8ecfa085b9cd10b75bf72a0da500c6d7 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Thu, 27 Jun 2024 13:27:08 +0200 Subject: [PATCH 2/3] Move XDG_CACHE_HOME to init --- easybuild/easyblocks/generic/pythonpackage.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/easybuild/easyblocks/generic/pythonpackage.py b/easybuild/easyblocks/generic/pythonpackage.py index 05f48879ee0..01c8e8598e5 100644 --- a/easybuild/easyblocks/generic/pythonpackage.py +++ b/easybuild/easyblocks/generic/pythonpackage.py @@ -422,6 +422,11 @@ 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']) + def determine_install_command(self): """ Determine install command to use. @@ -452,11 +457,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', os.path.join(self.builddir, 'xdg-cache-home')) - 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 From 4c0d748d4ec60d5d62bd51c9aa868a311bd8c789 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Thu, 27 Jun 2024 13:28:58 +0200 Subject: [PATCH 3/3] fix PythonPackage installation with $PIP_REQUIRE_VIRTUALENV The user using EasyBuild might have $PIP_REQUIRE_VIRTUALENV set which will fail the installation of PythonPackages with > ERROR: Could not find an activated virtualenv (required). So disable this. pip 20.2.3+ seems to require `false` as the value instead of any other value (including the empty string) --- easybuild/easyblocks/generic/pythonpackage.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/easybuild/easyblocks/generic/pythonpackage.py b/easybuild/easyblocks/generic/pythonpackage.py index 01c8e8598e5..3766ff61fe2 100644 --- a/easybuild/easyblocks/generic/pythonpackage.py +++ b/easybuild/easyblocks/generic/pythonpackage.py @@ -426,6 +426,9 @@ def __init__(self, *args, **kwargs): # 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): """