3232@author: Jens Timmerman (Ghent University)
3333"""
3434
35- import shutil
3635import os
3736import stat
3837
3938from easybuild .framework .easyblock import EasyBlock
4039from easybuild .framework .easyconfig import CUSTOM
4140from easybuild .tools .build_log import EasyBuildError
42- from easybuild .tools .filetools import adjust_permissions , copy_file , mkdir , remove_dir
41+ from easybuild .tools .filetools import adjust_permissions , clean_dir , copy_dir , copy_file , mkdir
4342from easybuild .tools .run import run_shell_cmd
4443
4544
@@ -116,8 +115,8 @@ def install_step(self):
116115 if install_cmd is None and install_cmds is None :
117116 try :
118117 # shutil.copytree doesn't allow the target directory to exist already
119- remove_dir (self .installdir )
120- shutil . copytree (self .cfg ['start_dir' ], self .installdir , symlinks = self .cfg ['keepsymlinks' ])
118+ clean_dir (self .installdir )
119+ copy_dir (self .cfg ['start_dir' ], self .installdir , symlinks = self .cfg ['keepsymlinks' ], dirs_exist_ok = True )
121120 except OSError as err :
122121 raise EasyBuildError ("Failed to copy %s to %s: %s" , self .cfg ['start_dir' ], self .installdir , err )
123122 else :
@@ -142,14 +141,8 @@ def post_processing_step(self):
142141 if self .cfg .get ('staged_install' , False ):
143142 staged_installdir = self .installdir
144143 self .installdir = self .actual_installdir
145- try :
146- # copytree expects target directory to not exist yet
147- if os .path .exists (self .installdir ):
148- remove_dir (self .installdir )
149- shutil .copytree (staged_installdir , self .installdir )
150- except OSError as err :
151- raise EasyBuildError ("Failed to move staged install from %s to %s: %s" ,
152- staged_installdir , self .installdir , err )
144+ clean_dir (self .installdir )
145+ copy_dir (staged_installdir , self .installdir , dirs_exist_ok = True )
153146
154147 super ().post_processing_step ()
155148
0 commit comments