Skip to content

Commit 9dc68c5

Browse files
authored
Replace use of distutils by shutils.copytree in datasets.py (#458)
* Replace use of distutils by shutils.copytree in datasets.py As mentioned in issue #457, the module `distutils` is deprecated since python v3.12. I believe it is only used in `datasets.py` and can be replaced with `shutils.copytree`. This PR attempts to fix the issue by replacing `distutils.dir_util.copy_tree` by `shutils.copytree`. * fix: run black
1 parent 006fb49 commit 9dc68c5

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/psf/black
3-
rev: 24.10.0
3+
rev: 25.1.0
44
hooks:
55
- id: black
66
language_version: python3

pysteps/datasets.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import sys
2222
import time
2323
from datetime import datetime, timedelta
24-
from distutils.dir_util import copy_tree
2524
from logging.handlers import RotatingFileHandler
2625
from tempfile import NamedTemporaryFile, TemporaryDirectory
2726
from urllib import request
@@ -329,7 +328,9 @@ def download_pysteps_data(dir_path, force=True):
329328

330329
zip_obj.extractall(tmp_dir.name)
331330

332-
copy_tree(os.path.join(tmp_dir.name, common_path), dir_path)
331+
shutil.copytree(
332+
os.path.join(tmp_dir.name, common_path), dir_path, dirs_exist_ok=True
333+
)
333334

334335

335336
def create_default_pystepsrc(

0 commit comments

Comments
 (0)