From 5a6ae1f9f00c707760ce6695651208eadc05d74a Mon Sep 17 00:00:00 2001 From: Bowie Chen Date: Tue, 29 Apr 2025 13:43:33 -0700 Subject: [PATCH] Replace usage of deprecated `distutils.(file|dir)_util` (#10530) Summary: X-link: https://github.com/facebook/FAI-PEP/pull/543 `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 --- docs/source/conf.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index d0e21e8aa22..7128e34ed8d 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -18,9 +18,9 @@ # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # -import distutils.file_util import glob import os +import shutil import sys from typing import Any @@ -135,7 +135,7 @@ # Copy .md files from source dir to gallery dir for f in glob.glob(os.path.join(source_dir, "*.md")): - distutils.file_util.copy_file(f, gallery_dir, update=True) + shutil.copyfile(f, gallery_dir) source_suffix = [".rst", ".md"]