4949import itertools
5050import os
5151import pathlib
52- import platform
5352import re
5453import shutil
5554import signal
6564import urllib .request as std_urllib
6665
6766from easybuild .base import fancylogger
68- from easybuild .tools import LooseVersion
6967# import build_log must stay, to use of EasyBuildLog
7068from easybuild .tools .build_log import EasyBuildError , EasyBuildExit , CWD_NOTFOUND_ERROR
7169from easybuild .tools .build_log import dry_run_msg , print_msg , print_warning
@@ -2550,14 +2548,12 @@ def copy_file(path, target_path, force_in_dry_run=False):
25502548 if os .path .exists (target_path ) and os .stat (target_path ).st_mode & stat .S_IWUSR :
25512549 raise EasyBuildError ("Failed to copy file %s to %s: %s" , path , target_path , err )
25522550
2553- pyver = LooseVersion ( platform . python_version ())
2554- if pyver >= LooseVersion ( '3.7' ):
2551+ # If we have anything other than a PermissionError we bail out
2552+ if not isinstance ( err , PermissionError ):
25552553 raise EasyBuildError ("Failed to copy file %s to %s: %s" , path , target_path , err )
2556- elif LooseVersion ('3.7' ) > pyver >= LooseVersion ('3' ):
2557- if not isinstance (err , PermissionError ):
2558- raise EasyBuildError ("Failed to copy file %s to %s: %s" , path , target_path , err )
25592554
2560- # double-check whether the copy actually succeeded
2555+ # double-check whether the copy actually succeeded (or may have already happened
2556+ # if the contents are the same)
25612557 if not os .path .exists (target_path ) or not filecmp .cmp (path , target_path , shallow = False ):
25622558 raise EasyBuildError ("Failed to copy file %s to %s: %s" , path , target_path , err )
25632559
@@ -2569,8 +2565,10 @@ def copy_file(path, target_path, force_in_dry_run=False):
25692565 except OSError as err :
25702566 raise EasyBuildError ("Failed to copy file %s to %s: %s" , path , target_path , err )
25712567
2572- msg = ("Failed to copy extended attributes from file %s to %s, due to a bug in shutil (see "
2573- "https://bugs.python.org/issue24538). Copy successful with workaround." )
2568+ msg = ("In some cases, we may fail to copy extended attributes from file %s to %s, due to a "
2569+ "bug in shutil (see https://bugs.python.org/issue24538). We may also have already "
2570+ "copied the file over so we just check the contents and update the xattrs. "
2571+ "Copy successful with workaround." )
25742572 _log .info (msg , path , target_path )
25752573
25762574 elif os .path .islink (path ):
0 commit comments