2121import sys
2222import os
2323import os .path as osp
24+ from pathlib import Path
2425import shutil
2526import traceback
2627import atexit
@@ -98,7 +99,8 @@ def prepend_modules_to_path(module_base_path):
9899 # Assuming py2exe distribution
99100 return
100101 fnames = [
101- osp .join (module_base_path , name )
102+ # osp.join(module_base_path, name)
103+ str (Path (module_base_path ) / name )
102104 for name in os .listdir (module_base_path )
103105 ]
104106 messages = [
@@ -137,9 +139,10 @@ def to_include_files(data_files):
137139 include_files = []
138140 for dest_dir , fnames in data_files :
139141 for source_fname in fnames :
140- dest_fname = osp .join (
141- dest_dir , osp .basename (source_fname )
142- )
142+ #dest_fname = osp.join(
143+ # dest_dir, osp.basename(source_fname))
144+ dest_fname = str (Path (dest_dir ) /
145+ osp .basename (source_fname ))
143146 include_files .append ((source_fname , dest_fname ))
144147 return include_files
145148
@@ -351,7 +354,8 @@ def add_pyqt4(self):
351354 if osp .isdir (pyqt_tmp ):
352355 shutil .rmtree (pyqt_tmp )
353356 os .mkdir (pyqt_tmp )
354- vc90man_pyqt = osp .join (pyqt_tmp , vc90man )
357+ # vc90man_pyqt = osp.join(pyqt_tmp, vc90man)
358+ vc90man_pyqt = str (Path (pyqt_tmp ) / vc90man )
355359 man = (
356360 open (vc90man , "r" )
357361 .read ()
@@ -362,10 +366,12 @@ def add_pyqt4(self):
362366 )
363367 open (vc90man_pyqt , 'w' ).write (man )
364368 for dirpath , _ , filenames in os .walk (
365- osp .join (pyqt_path , "plugins" )
369+ # osp.join(pyqt_path, "plugins")
370+ str (Path (pyqt_path ) / "plugins" )
366371 ):
367372 filelist = [
368- osp .join (dirpath , f )
373+ # osp.join(dirpath, f)
374+ str (Path (dirpath ) / f )
369375 for f in filenames
370376 if osp .splitext (f )[1 ] in ('.dll' , '.py' )
371377 ]
@@ -389,8 +395,9 @@ def add_pyqt4(self):
389395 if self .msvc :
390396 atexit .register (remove_dir , pyqt_tmp )
391397 # Including french translation
392- fr_trans = osp .join (
393- pyqt_path , "translations" , "qt_fr.qm"
398+ # fr_trans = osp.join(
399+ # pyqt_path, "translations", "qt_fr.qm"
400+ fr_trans = str (Path (pyqt_path ) / "translations" / "qt_fr.qm" )
394401 )
395402 if osp .exists (fr_trans ):
396403 self .data_files .append (
@@ -434,7 +441,8 @@ def add_pyside(self):
434441 if self .msvc :
435442 vc90man = "Microsoft.VC90.CRT.manifest"
436443 os .mkdir ('pyside_tmp' )
437- vc90man_pyside = osp .join ('pyside_tmp' , vc90man )
444+ # vc90man_pyside = osp.join('pyside_tmp', vc90man)
445+ vc90man_pyside = str (Path ('pyside_tmp' ) / vc90man )
438446 man = (
439447 open (vc90man , "r" )
440448 .read ()
@@ -445,10 +453,12 @@ def add_pyside(self):
445453 )
446454 open (vc90man_pyside , 'w' ).write (man )
447455 for dirpath , _ , filenames in os .walk (
448- osp .join (pyside_path , "plugins" )
456+ # osp.join(pyside_path, "plugins")
457+ str (Path (pyside_path ) / "plugins" )
449458 ):
450459 filelist = [
451- osp .join (dirpath , f )
460+ # osp.join(dirpath, f)
461+ str (Path (dirpath ) / f )
452462 for f in filenames
453463 if osp .splitext (f )[1 ] in ('.dll' , '.py' )
454464 ]
@@ -472,7 +482,8 @@ def add_pyside(self):
472482 # Replacing dlls found by cx_Freeze by the real PySide Qt dlls:
473483 # (http://qt-project.org/wiki/Packaging_PySide_applications_on_Windows)
474484 dlls = [
475- osp .join (pyside_path , fname )
485+ # osp.join(pyside_path, fname)
486+ str (Path (pyside_path ) / fname )
476487 for fname in os .listdir (pyside_path )
477488 if osp .splitext (fname )[1 ] == '.dll'
478489 ]
@@ -481,9 +492,9 @@ def add_pyside(self):
481492 if self .msvc :
482493 atexit .register (remove_dir , 'pyside_tmp' )
483494 # Including french translation
484- fr_trans = osp .join (
485- pyside_path , "translations" , "qt_fr.qm"
486- )
495+ # fr_trans = osp.join(
496+ # pyside_path, "translations", "qt_fr.qm")
497+ fr_trans = str ( Path ( pyside_path ) / "translations" / "qt_fr.qm" )
487498 if osp .exists (fr_trans ):
488499 self .data_files .append (
489500 ('translations' , (fr_trans ,))
@@ -573,9 +584,10 @@ def add_modules(self, *module_names):
573584 (
574585 '' ,
575586 (
576- osp .join (
577- get_module_path ('h5py' ),
578- 'zlib1.dll' ,
587+ #osp.join(
588+ # get_module_path('h5py'),
589+ # 'zlib1.dll',
590+ str (Path (get_module_path ('h5py' )) / 'zlib1.dll'
579591 ),
580592 ),
581593 )
@@ -688,7 +700,8 @@ def add_module_data_dir(
688700 """
689701 module_dir = get_module_path (module_name )
690702 nstrip = len (module_dir ) + len (osp .sep )
691- data_dir = osp .join (module_dir , data_dir_name )
703+ # data_dir = osp.join(module_dir, data_dir_name)
704+ data_dir = str (Path (module_dir ) / data_dir_name )
692705 if not osp .isdir (data_dir ):
693706 raise IOError (
694707 "Directory not found: %s" % data_dir
@@ -700,9 +713,11 @@ def add_module_data_dir(
700713 if osp .basename (dirpath ) in exclude_dirs :
701714 continue
702715 if not copy_to_root :
703- dirname = osp .join (module_name , dirname )
716+ # dirname = osp.join(module_name, dirname)
717+ dirname = str (Path (module_name ) / dirname )
704718 pathlist = [
705- osp .join (dirpath , f )
719+ # osp.join(dirpath, f)
720+ str (Path (dirpath ) / f )
706721 for f in filenames
707722 if osp .splitext (f )[1 ].lower () in extensions
708723 ]
@@ -743,13 +758,15 @@ def add_module_data_files(
743758 verbose ,
744759 exclude_dirs ,
745760 )
746- translation_file = osp .join (
747- module_dir ,
748- "locale" ,
749- "fr" ,
750- "LC_MESSAGES" ,
751- "%s.mo" % module_name ,
752- )
761+ #translation_file = osp.join(
762+ # module_dir,
763+ # "locale",
764+ # "fr",
765+ # "LC_MESSAGES",
766+ # "%s.mo" % module_name,
767+ #)
768+ translation_file = str (Path (module_dir ) / "locale" / "fr" /
769+ "LC_MESSAGES" / f"{ module_name } .mo" )
753770 if osp .isfile (translation_file ):
754771 self .data_files .append (
755772 (
0 commit comments