Skip to content

Commit 7a60b42

Browse files
bowiechenfacebook-github-bot
authored andcommitted
Replace usage of deprecated distutils.(file|dir)_util (facebook#543)
Summary: X-link: pytorch/executorch#10530 `distutils` has been deprecated since Python 3.10, and [removed in Python 3.12](https://docs.python.org/3/whatsnew/3.12.html#distutils). Existing usage will now raise the following error under Python 3.12+: ``` ModuleNotFoundError: No module named 'distutils' ``` This diff replaces `distutils` usage according to [PEP-632 migration advice](https://peps.python.org/pep-0632/#migration-advice). --- I generated this diff by looking for all usages of `distutils.*copy_(tree|file)` and replaced them with `shutil.copy(tree|file)`. These should be close to drop-in replacements! Reviewed By: itamaro, mergennachin Differential Revision: D73804939
1 parent 91a2028 commit 7a60b42

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

benchmarking/benchmarks/benchmarks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,9 @@ def _copyFile(self, field, destination_name, source):
259259
)
260260
os.symlink(abs_name, destination_name)
261261
elif os.path.isdir(abs_name):
262-
import distutils.dir_util
262+
import shutil
263263

264-
distutils.dir_util.copy_tree(abs_name, destination_name)
264+
shutil.copytree(abs_name, destination_name)
265265
else:
266266
raise AssertionError(f"Path {abs_name} cannot be retrieved.")
267267
return False

0 commit comments

Comments
 (0)