Skip to content

Commit

Permalink
replace distutils (deprecated in python 3.12)
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards4b committed Sep 30, 2024
1 parent 9ac3e71 commit b8fce66
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions CIME/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
from argparse import Action
from contextlib import contextmanager

# pylint: disable=deprecated-module
from distutils import file_util

# Return this error code if the scripts worked but tests failed
TESTS_FAILED_ERR_CODE = 100
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -1412,12 +1409,9 @@ def safe_copy(src_path, tgt_path, preserve_meta=True):

if owner_uid == os.getuid():
# I am the owner, copy file contents, permissions, and metadata
file_util.copy_file(
shutil.copy2(
src_path,
tgt_path,
preserve_mode=preserve_meta,
preserve_times=preserve_meta,
verbose=0,
)
else:
# I am not the owner, just copy file contents
Expand All @@ -1426,12 +1420,9 @@ def safe_copy(src_path, tgt_path, preserve_meta=True):
else:
# We are making a new file, copy file contents, permissions, and metadata.
# This can fail if the underlying directory is not writable by current user.
file_util.copy_file(
shutil.copy2(
src_path,
tgt_path,
preserve_mode=preserve_meta,
preserve_times=preserve_meta,
verbose=0,
)

# If src file was executable, then the tgt file should be too
Expand Down

0 comments on commit b8fce66

Please sign in to comment.