From b88ccc292c59e4b976f7ab598dae7e92185c3d3b Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 17 Aug 2023 14:36:38 -0400 Subject: [PATCH] Avoid deprecation on distutils with newer python Unfortunately, python 3.6 needs the distutils version, but we should avoid it altogether by python 3.10, but by 3.10 the shutil.copytree can do it. --- imgutil/imgutil | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/imgutil/imgutil b/imgutil/imgutil index 839e5e98..5f64c988 100644 --- a/imgutil/imgutil +++ b/imgutil/imgutil @@ -3,7 +3,13 @@ import configparser import ctypes import ctypes.util import datetime -from distutils.dir_util import copy_tree +import inspect +from shutil import copytree as copytree +if 'dirs_exist_ok' in inspect.getargspec(copytree).args: + def copy_tree(src, dst): + copytree(src, dst, dirs_exist_ok=True) +else: + from distutils.dir_util import copy_tree import glob import json import argparse