Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove distutils #4688

Merged
merged 2 commits into from
Oct 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 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,26 +1409,25 @@ 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
shutil.copyfile(src_path, tgt_path)

else:
elif preserve_meta:
# 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,
)
else:
shutil.copy(
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
Loading