Skip to content

Commit e2561df

Browse files
committed
Replace deprecated distutils package
The package `distutils` is deprecated since python 3.10 and it is scheduled to be removed with python 3.12, see: https://docs.python.org/3.12/whatsnew/3.12.html python/cpython#92584 `shutil.copytree()` is able to copy the source directory tree to an existing destination directory only from python 3.8 (parameter `dirs_exist_ok=True`), for python < 3.8 still use `distutils.dir_util.copy_tree()`
1 parent 2a12e0c commit e2561df

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

worker/sri.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"__version": 213, "updater.py": "GEDqwD5F16roa/hRFbTNbbUqW/smvbe/4Rcf09O5BIJOAI63wsAVgLEnMtQp1naZ", "worker.py": "dT4tz1DqISrMUZhqlQNV94nvpf6EPVg0ebs118cSJ8gC7C22PetaQjQgA1Ciupm4", "games.py": "LyUiwCAMXllQWLIHsWGZpQpziYGO6dK3jDXzimEFd2ehLLrp5nsSGbl7+AUQTnAa"}
1+
{"__version": 213, "updater.py": "jkqHSdrm3XNEDF2Xck73ZgH3zx6fauZuYlkvYRj1kTaO+qzB/DLQvXy3NTQ0AkRt", "worker.py": "dT4tz1DqISrMUZhqlQNV94nvpf6EPVg0ebs118cSJ8gC7C22PetaQjQgA1Ciupm4", "games.py": "LyUiwCAMXllQWLIHsWGZpQpziYGO6dK3jDXzimEFd2ehLLrp5nsSGbl7+AUQTnAa"}

worker/updater.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import shutil
33
import sys
44
from datetime import datetime, timezone
5-
from distutils.dir_util import copy_tree
65
from pathlib import Path
76
from zipfile import ZipFile
87

@@ -57,7 +56,14 @@ def update(restart=True, test=False):
5756
sep="",
5857
file=sys.stderr,
5958
)
60-
copy_tree(str(worker_src), str(worker_dir))
59+
if sys.version_info >= (3, 8):
60+
from shutil import copytree
61+
62+
copytree(worker_src, worker_dir, dirs_exist_ok=True)
63+
else:
64+
from distutils.dir_util import copy_tree
65+
66+
copy_tree(str(worker_src), str(worker_dir))
6167
else:
6268
file_list = os.listdir(worker_src)
6369
shutil.rmtree(update_dir)

0 commit comments

Comments
 (0)