cpython: d94d8789e924 (original) (raw)

Mercurial > cpython

changeset 93262:d94d8789e924 3.4

Issue #8876: distutils now falls back to copying files when hard linking doesn't work. This allows use with special filesystems such as VirtualBox shared folders. [#8876]

Antoine Pitrou solipsis@pitrou.net
date Thu, 30 Oct 2014 19:37:07 +0100
parents 9dddc95ef31e
children ce484e0840e3 1eabc79a713e
files Lib/distutils/file_util.py Lib/distutils/tests/test_file_util.py Misc/NEWS
diffstat 3 files changed, 55 insertions(+), 13 deletions(-)[+] [-] Lib/distutils/file_util.py 32 Lib/distutils/tests/test_file_util.py 32 Misc/NEWS 4

line wrap: on

line diff

--- a/Lib/distutils/file_util.py +++ b/Lib/distutils/file_util.py @@ -80,7 +80,8 @@ def copy_file(src, dst, preserve_mode=1, (os.symlink) instead of copying: set it to "hard" or "sym"; if it is None (the default), files are copied. Don't set 'link' on systems that don't support it: 'copy_file()' doesn't check if hard or symbolic

Under Mac OS, uses the native file copy function in macostools; on other systems, uses '_copy_file_contents()' to copy file contents. @@ -132,24 +133,31 @@ def copy_file(src, dst, preserve_mode=1, # (Unix only, of course, but that's the caller's responsibility) elif link == 'hard': if not (os.path.exists(dst) and os.path.samefile(src, dst)):

# Otherwise (non-Mac, not linking), copy the file contents and # (optionally) copy the times and mode.

return (dst, 1)

--- a/Lib/distutils/tests/test_file_util.py +++ b/Lib/distutils/tests/test_file_util.py @@ -5,7 +5,7 @@ import shutil import errno from unittest.mock import patch -from distutils.file_util import move_file +from distutils.file_util import move_file, copy_file from distutils import log from distutils.tests import support from distutils.errors import DistutilsFileError @@ -78,6 +78,36 @@ class FileUtilTestCase(support.TempdirMa fobj.write('spam eggs') move_file(self.source, self.target, verbose=0)

+

+ + def test_suite(): return unittest.makeSuite(FileUtilTestCase)

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -33,6 +33,10 @@ Core and Builtins Library ------- +- Issue #8876: distutils now falls back to copying files when hard linking