From 585b099d69ddd4b0b8132208e547bab41da8f22a Mon Sep 17 00:00:00 2001 From: Alan O'Cais Date: Mon, 2 Mar 2026 11:33:59 +0100 Subject: [PATCH 1/2] Be a bit more forgiving with `copy_file` --- easybuild/tools/filetools.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/easybuild/tools/filetools.py b/easybuild/tools/filetools.py index 9954e87661..f0b9d7d304 100644 --- a/easybuild/tools/filetools.py +++ b/easybuild/tools/filetools.py @@ -2550,14 +2550,12 @@ def copy_file(path, target_path, force_in_dry_run=False): if os.path.exists(target_path) and os.stat(target_path).st_mode & stat.S_IWUSR: raise EasyBuildError("Failed to copy file %s to %s: %s", path, target_path, err) - pyver = LooseVersion(platform.python_version()) - if pyver >= LooseVersion('3.7'): + # If we have anything other than a PermissionError we bail out + if not isinstance(err, PermissionError): raise EasyBuildError("Failed to copy file %s to %s: %s", path, target_path, err) - elif LooseVersion('3.7') > pyver >= LooseVersion('3'): - if not isinstance(err, PermissionError): - raise EasyBuildError("Failed to copy file %s to %s: %s", path, target_path, err) - # double-check whether the copy actually succeeded + # double-check whether the copy actually succeeded (or may have already happened + # if the contents are the same) if not os.path.exists(target_path) or not filecmp.cmp(path, target_path, shallow=False): raise EasyBuildError("Failed to copy file %s to %s: %s", path, target_path, err) @@ -2569,8 +2567,10 @@ def copy_file(path, target_path, force_in_dry_run=False): except OSError as err: raise EasyBuildError("Failed to copy file %s to %s: %s", path, target_path, err) - msg = ("Failed to copy extended attributes from file %s to %s, due to a bug in shutil (see " - "https://bugs.python.org/issue24538). Copy successful with workaround.") + msg = ("In some cases, we may fail to copy extended attributes from file %s to %s, due to a " + "bug in shutil (see https://bugs.python.org/issue24538). We may also have already " + "copied the file over so we just check the contents and update the xattrs. " + "Copy successful with workaround.") _log.info(msg, path, target_path) elif os.path.islink(path): From 4543743515c53c19a19d9e13a947556e19914c24 Mon Sep 17 00:00:00 2001 From: Alan O'Cais Date: Mon, 2 Mar 2026 11:54:10 +0100 Subject: [PATCH 2/2] Pass PEP8-compliance --- easybuild/tools/filetools.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/easybuild/tools/filetools.py b/easybuild/tools/filetools.py index f0b9d7d304..366f7b87fc 100644 --- a/easybuild/tools/filetools.py +++ b/easybuild/tools/filetools.py @@ -49,7 +49,6 @@ import itertools import os import pathlib -import platform import re import shutil import signal @@ -65,7 +64,6 @@ import urllib.request as std_urllib from easybuild.base import fancylogger -from easybuild.tools import LooseVersion # import build_log must stay, to use of EasyBuildLog from easybuild.tools.build_log import EasyBuildError, EasyBuildExit, CWD_NOTFOUND_ERROR from easybuild.tools.build_log import dry_run_msg, print_msg, print_warning