diff --git a/dvc/system.py b/dvc/system.py index d32663b4a..c300daac5 100644 --- a/dvc/system.py +++ b/dvc/system.py @@ -1,14 +1,31 @@ import errno import logging import os +import platform import shutil from dvc.compat import fspath from dvc.exceptions import DvcException - logger = logging.getLogger(__name__) +if platform.system() == "Windows": + try: + import speedcopy + + speedcopy.patch_copyfile() + except ImportError: + pass +else: + import sys + + if sys.version_info < (3, 8): + try: + # Importing the module monkey-patches shutil.copyfile + import pyfastcopy # noqa: F401 + except ImportError: + pass + class System(object): @staticmethod @@ -90,8 +107,6 @@ class System(object): @staticmethod def reflink(source, link_name): - import platform - source, link_name = fspath(source), fspath(link_name) system = platform.system() diff --git a/setup.py b/setup.py index d9d13a4bd..07fb26531 100644 --- a/setup.py +++ b/setup.py @@ -75,6 +75,8 @@ install_requires = [ "win-unicode-console>=0.5; sys_platform == 'win32'", "pywin32>=225; sys_platform == 'win32'", "networkx>=2.1,<2.4", + "speedcopy>=2.0.1", + "pyfastcopy>=1.0.3", "flatten-dict>=0.2.0", "texttable>=0.5.2", ]