29
29
# osp.dirname(__file__), 'changelogs'
30
30
# )
31
31
CHANGELOGS_DIR = str (Path (__file__ ).parent / 'changelogs' )
32
- assert osp .isdir (CHANGELOGS_DIR )
32
+ # assert osp.isdir(CHANGELOGS_DIR)
33
+ assert Path (CHANGELOGS_DIR ).is_dir ()
33
34
34
35
35
36
def get_drives ():
@@ -51,8 +52,10 @@ def get_nsis_exe():
51
52
r'C:\Program Files (x86)' ,
52
53
drive + r'PortableApps\NSISPortableANSI' ,
53
54
drive + r'PortableApps\NSISPortable' ,
54
- osp .join (localdir , 'NSISPortableANSI' ),
55
- osp .join (localdir , 'NSISPortable' ),
55
+ # osp.join(localdir, 'NSISPortableANSI'),
56
+ str (Path (localdir ) / 'NSISPortableANSI' ),
57
+ # osp.join(localdir, 'NSISPortable'),
58
+ str (Path (localdir ) / 'NSISPortable' ),
56
59
):
57
60
for subdirname in ('.' , 'App' ):
58
61
exe = osp .join (
@@ -61,7 +64,8 @@ def get_nsis_exe():
61
64
'NSIS' ,
62
65
'makensis.exe' ,
63
66
)
64
- if osp .isfile (exe ):
67
+ # if osp.isfile(exe):
68
+ if Path (exe ).is_file ():
65
69
return exe
66
70
else :
67
71
raise RuntimeError (
@@ -83,7 +87,8 @@ def get_iscc_exe():
83
87
# drive+r'PortableApps\NSISPortableANSI',
84
88
# drive+r'PortableApps\NSISPortable',
85
89
# osp.join(localdir, 'NSISPortableANSI'),
86
- osp .join (localdir , 'Inno Setup 5' ),
90
+ # osp.join(localdir, 'Inno Setup 5'),
91
+ str (Path (localdir ) / 'Inno Setup 5' ),
87
92
):
88
93
for subdirname in ('.' , 'App' ):
89
94
exe = osp .join (
@@ -92,7 +97,8 @@ def get_iscc_exe():
92
97
'Inno Setup 5' ,
93
98
'iscc.exe' ,
94
99
)
95
- if osp .isfile (exe ):
100
+ # if osp.isfile(exe):
101
+ if Path (exe ).is_file ():
96
102
return exe
97
103
else :
98
104
#raise RuntimeError(
@@ -111,14 +117,16 @@ def get_7zip_exe():
111
117
for dirname in (
112
118
r'C:\Program Files' ,
113
119
r'C:\Program Files (x86)' ,
114
- osp .join (localdir , '7-Zip' ),
120
+ # osp.join(localdir, '7-Zip'),
121
+ str (Path (localdir ) / '7-Zip' ),
115
122
):
116
123
for subdirname in ('.' , 'App' ):
117
124
exe = osp .join (
118
125
dirname , subdirname , '7-Zip' , '7z.exe'
119
126
)
120
127
# include = osp.join(dirname, subdirname, '7-Zip', 'include')
121
- if osp .isfile (exe ):
128
+ # if osp.isfile(exe):
129
+ if Path (exe ).is_file ():
122
130
return exe
123
131
else :
124
132
raise RuntimeError (
@@ -215,7 +223,8 @@ def build_nsis(srcname, dstname, data):
215
223
data = [
216
224
(
217
225
'!addincludedir' ,
218
- osp .join (portable_dir , 'include' ),
226
+ # osp.join(portable_dir, 'include'),
227
+ str (Path (portable_dir ) / 'include' ),
219
228
)
220
229
] + list (data )
221
230
replace_in_nsis_file (dstname , data )
@@ -350,7 +359,8 @@ def __init__(
350
359
351
360
# osp.join(self.winpydir, self.python_name) = Directory of Python exec
352
361
# self.pythondir =osp.join(self.winpydir, self.python_name)
353
- self .python_name = osp .basename (self .python_fname )[
362
+ # self.python_name = osp.basename(self.python_fname)[
363
+ self .python_name = Path (self .python_fname ).name [
354
364
:- 4
355
365
]
356
366
self .distname = 'winUNKNOWN' #win%s' % self.python_name # PyPy ?
@@ -488,7 +498,8 @@ def winpyver(self):
488
498
@property
489
499
def python_dir (self ):
490
500
"""Return Python dirname (full path) of the target distribution"""
491
- return osp .join (self .winpydir , self .python_name ) # python.exe path
501
+ # return osp.join(self.winpydir, self.python_name) # python.exe path
502
+ return str (Path (self .winpydir ) / self .python_name ) # python.exe path
492
503
493
504
@property
494
505
def winpy_arch (self ):
@@ -583,8 +594,10 @@ def get_package_fname(self, pattern):
583
594
def create_batch_script (self , name , contents ,
584
595
do_changes = None ):
585
596
"""Create batch script %WINPYDIR%/name"""
586
- scriptdir = osp .join (self .winpydir , 'scripts' )
587
- if not osp .isdir (scriptdir ):
597
+ # scriptdir = osp.join(self.winpydir, 'scripts')
598
+ scriptdir = str (Path (self .winpydir ) / 'scripts' )
599
+ # if not osp.isdir(scriptdir):
600
+ if not Path (scriptdir ).is_dir ():
588
601
os .mkdir (scriptdir )
589
602
print ('dochanges for %s %' , name , do_changes )
590
603
# live patch pypy3
@@ -593,7 +606,8 @@ def create_batch_script(self, name, contents,
593
606
for i in do_changes :
594
607
contents_final = contents_final .replace (i [0 ], i [1 ])
595
608
596
- fd = open (osp .join (scriptdir , name ), 'w' )
609
+ # fd = open(osp.join(scriptdir, name), 'w')
610
+ fd = open (str (Path (scriptdir ) / name ), 'w' )
597
611
fd .write (contents_final )
598
612
fd .close ()
599
613
@@ -611,8 +625,10 @@ def create_launcher(
611
625
portable_dir = osp .join (
612
626
osp .dirname (osp .abspath (__file__ )), 'portable'
613
627
)
614
- icon_fname = osp .join (portable_dir , 'icons' , icon )
615
- assert osp .isfile (icon_fname )
628
+ # icon_fname = osp.join(portable_dir, 'icons', icon)
629
+ icon_fname = str (Path (portable_dir ) / 'icons' / icon )
630
+ # assert osp.isfile(icon_fname)
631
+ assert Path (icon_fname ).is_file ()
616
632
617
633
# Customizing NSIS script
618
634
if command is None :
@@ -686,7 +702,8 @@ def create_installer(self):
686
702
portable_dir = osp .join (
687
703
osp .dirname (osp .abspath (__file__ )), 'portable'
688
704
)
689
- fname = osp .join (portable_dir , 'installer-tmp.nsi' )
705
+ # fname = osp.join(portable_dir, 'installer-tmp.nsi')
706
+ fname = str (Path (portable_dir ) / 'installer-tmp.nsi' )
690
707
data = (
691
708
('DISTDIR' , self .winpydir ),
692
709
('ARCH' , self .winpy_arch ),
@@ -811,30 +828,36 @@ def _extract_python(self):
811
828
def _copy_dev_tools (self ):
812
829
"""Copy dev tools"""
813
830
self ._print (f"Copying tools from { self .toolsdirs } to { self .winpydir } /t" )
814
- toolsdir = osp .join (self .winpydir , 't' )
831
+ # toolsdir = osp.join(self.winpydir, 't')
832
+ toolsdir = str (Path (self .winpydir ) / 't' )
815
833
os .mkdir (toolsdir )
816
834
for (
817
835
dirname
818
836
) in (
819
837
[ok_dir for ok_dir in self .toolsdirs if osp .isdir (ok_dir )]
820
838
): # the ones in the make.py script environment
821
839
for name in os .listdir (dirname ):
822
- path = osp .join (dirname , name )
840
+ # path = osp.join(dirname, name)
841
+ path = str (Path (dirname ) / name )
823
842
copy = (
824
843
shutil .copytree
825
- if osp .isdir (path )
844
+ # if osp.isdir(path)
845
+ if Path (path ).is_dir ()
826
846
else shutil .copyfile
827
847
)
828
848
if self .verbose :
829
849
print (
830
850
path
831
851
+ ' --> '
832
- + osp .join (toolsdir , name )
852
+ # + osp.join(toolsdir, name)
853
+ + str (Path (toolsdir ) / name )
833
854
)
834
- copy (path , osp .join (toolsdir , name ))
855
+ # copy(path, osp.join(toolsdir, name))
856
+ copy (path , str (Path (toolsdir ) / name ))
835
857
self ._print_done ()
836
858
# move node higher
837
- nodejs_current = osp .join (toolsdir , 'n' )
859
+ # nodejs_current = osp.join(toolsdir, 'n')
860
+ nodejs_current = str (Path (toolsdir ) / 'n' )
838
861
nodejs_target = self .winpydir + self .NODEJS_PATH
839
862
if nodejs_current != nodejs_target and osp .isdir (
840
863
nodejs_current
@@ -843,29 +866,35 @@ def _copy_dev_tools(self):
843
866
844
867
def _copy_dev_docs (self ):
845
868
"""Copy dev docs"""
846
- docsdir = osp .join (self .winpydir , 'notebooks' )
869
+ # docsdir = osp.join(self.winpydir, 'notebooks')
870
+ docsdir = str (Path (self .winpydir ) / 'notebooks' )
847
871
self ._print (f"Copying Noteebook docs from { self .docsdirs } to { docsdir } " )
848
- if not osp .isdir (docsdir ):
872
+ # if not osp.isdir(docsdir):
873
+ if not Path (docsdir ).is_dir ():
849
874
os .mkdir (docsdir )
850
875
docsdir = osp .join (
851
876
self .winpydir , 'notebooks' , 'docs'
852
877
)
853
- if not osp .isdir (docsdir ):
878
+ # if not osp.isdir(docsdir):
879
+ if not Path (docsdir ).is_dir ():
854
880
os .mkdir (docsdir )
855
881
for dirname in self .docsdirs :
856
882
for name in os .listdir (dirname ):
857
- path = osp .join (dirname , name )
883
+ # path = osp.join(dirname, name)
884
+ path = str (Path (dirname ) / name )
858
885
copy = (
859
886
shutil .copytree
860
- if osp .isdir (path )
887
+ # if osp.isdir(path)
888
+ if Path (path ).is_dir ()
861
889
else shutil .copyfile
862
890
)
863
891
copy (path , osp .join (docsdir , name ))
864
892
if self .verbose :
865
893
print (
866
894
path
867
895
+ ' --> '
868
- + osp .join (docsdir , name )
896
+ # + osp.join(docsdir, name)
897
+ + str (Path (docsdir ) / name )
869
898
)
870
899
self ._print_done ()
871
900
0 commit comments