-
-
Notifications
You must be signed in to change notification settings - Fork 200
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
refactor: replace distutils' copy_tree with shutil copytree #964
refactor: replace distutils' copy_tree with shutil copytree #964
Conversation
118f8ae
to
671cdcd
Compare
Hey @gruzewski , |
@MatteoVoges I did some research and couldn't develop a better solution. The challenge with |
@gruzewski What if we traverse the template dir? Then we would get only the files, which get populated/ copied... |
Now that Python 3.12 is out, Kapitan can't be run and throws a @MatteoVoges what do you think about merging this as-is to enable Python 3.12 support? I realize it's been quite a while so if @gruzewski isn't interested in fixing up the branch I'd be willing to take that on. |
I can pick it up next week :) |
43ba490
to
ee630ab
Compare
I have rebased the PR, and the tests are passing, so this is good to go. @MatteoVoges, coming back to your point - we could technically do that, but there is a risk of reporting files that failed to copy. It wouldn't be a good first impression for users. |
Thanks, I will have a look at it soon!
I don't see it that critical if we just dump the tree output. Can you explain once again why we need the different handling for new vs. old files? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done!
Thank you @MatteoVoges and @gruzewski |
@gruzewski Could you remove |
Fixes issue #963 (partially)
Proposed Changes
distutils.dir_util
module is deprecated and will be removed from3.12
(see this). Unfortunately,shutil.copytree
is not a drop-in replacement as it returns destination directory and not the list of copied files, like indistutils.dir_util.copy_tree
.This PR adds a simple wrapper around
copy_tree
that computes copied files.Testing
kapitan init --directory
and got the same results. Cases covered: empty dir, existing dir without the structure, existing dir with the structure in placeNOTE: This change only works with Python >= 3.8 as
dirs_exist_ok
was added there. Otherwise, it will throwFileExistsError
.