6666TOOLS_DIRS = FileNameSet ("scripts" , "i18n" , "pynche" , "demo" , "parser" )
6767TOOLS_FILES = FileSuffixSet (".py" , ".pyw" , ".txt" )
6868
69+ def copy_if_modified (src , dest ):
70+ try :
71+ dest_stat = os .stat (dest )
72+ except FileNotFoundError :
73+ do_copy = True
74+ else :
75+ src_stat = os .stat (src )
76+ do_copy = (src_stat .st_mtime != dest_stat .st_mtime or
77+ src_stat .st_size != dest_stat .st_size )
78+
79+ if do_copy :
80+ shutil .copy2 (src , dest )
6981
7082def get_lib_layout (ns ):
7183 def _c (f ):
@@ -426,7 +438,7 @@ def copy_files(files, ns):
426438 need_compile .append ((dest , ns .copy / dest ))
427439 else :
428440 (ns .temp / "Lib" / dest ).parent .mkdir (parents = True , exist_ok = True )
429- shutil . copy2 (src , ns .temp / "Lib" / dest )
441+ copy_if_modified (src , ns .temp / "Lib" / dest )
430442 need_compile .append ((dest , ns .temp / "Lib" / dest ))
431443
432444 if src not in EXCLUDE_FROM_CATALOG :
@@ -436,7 +448,7 @@ def copy_files(files, ns):
436448 log_debug ("Copy {} -> {}" , src , ns .copy / dest )
437449 (ns .copy / dest ).parent .mkdir (parents = True , exist_ok = True )
438450 try :
439- shutil . copy2 (src , ns .copy / dest )
451+ copy_if_modified (src , ns .copy / dest )
440452 except shutil .SameFileError :
441453 pass
442454
0 commit comments