Skip to content

Commit

Permalink
Replace deprecated distutils package
Browse files Browse the repository at this point in the history
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()`
  • Loading branch information
ppigazzini committed Aug 28, 2023
1 parent 2a12e0c commit e2561df
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion worker/sri.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"__version": 213, "updater.py": "GEDqwD5F16roa/hRFbTNbbUqW/smvbe/4Rcf09O5BIJOAI63wsAVgLEnMtQp1naZ", "worker.py": "dT4tz1DqISrMUZhqlQNV94nvpf6EPVg0ebs118cSJ8gC7C22PetaQjQgA1Ciupm4", "games.py": "LyUiwCAMXllQWLIHsWGZpQpziYGO6dK3jDXzimEFd2ehLLrp5nsSGbl7+AUQTnAa"}
{"__version": 213, "updater.py": "jkqHSdrm3XNEDF2Xck73ZgH3zx6fauZuYlkvYRj1kTaO+qzB/DLQvXy3NTQ0AkRt", "worker.py": "dT4tz1DqISrMUZhqlQNV94nvpf6EPVg0ebs118cSJ8gC7C22PetaQjQgA1Ciupm4", "games.py": "LyUiwCAMXllQWLIHsWGZpQpziYGO6dK3jDXzimEFd2ehLLrp5nsSGbl7+AUQTnAa"}
10 changes: 8 additions & 2 deletions worker/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import shutil
import sys
from datetime import datetime, timezone
from distutils.dir_util import copy_tree
from pathlib import Path
from zipfile import ZipFile

Expand Down Expand Up @@ -57,7 +56,14 @@ def update(restart=True, test=False):
sep="",
file=sys.stderr,
)
copy_tree(str(worker_src), str(worker_dir))
if sys.version_info >= (3, 8):
from shutil import copytree

copytree(worker_src, worker_dir, dirs_exist_ok=True)
else:
from distutils.dir_util import copy_tree

copy_tree(str(worker_src), str(worker_dir))
else:
file_list = os.listdir(worker_src)
shutil.rmtree(update_dir)
Expand Down

0 comments on commit e2561df

Please sign in to comment.