13
13
from __future__ import print_function
14
14
15
15
import os
16
- # import os.path as osp
17
16
from pathlib import Path
18
17
import shutil
19
18
import re
@@ -75,7 +74,6 @@ def get_package_metadata(database, name, gotoWWW=False, update=False):
75
74
# machine which is not connected to the internet
76
75
# we store only normalized names now (PEP 503)
77
76
db = cp .ConfigParser ()
78
- # db.readfp(open(osp.join(DATA_PATH, database)))
79
77
db .readfp (open (str (Path (DATA_PATH ) / database )))
80
78
my_metadata = dict (
81
79
description = '' ,
@@ -110,7 +108,6 @@ def get_package_metadata(database, name, gotoWWW=False, update=False):
110
108
try :
111
109
db [normalize (name )] = {}
112
110
db [normalize (name )]['description' ] = my_metadata ['description' ]
113
- # with open(osp.join(DATA_PATH, database), 'w') as configfile:
114
111
with open (str (Path (DATA_PATH ) / database ), 'w' ) as configfile :
115
112
db .write (configfile )
116
113
except :
@@ -141,7 +138,6 @@ def __str__(self):
141
138
pytext ,
142
139
self .description ,
143
140
self .url ,
144
- # osp.basename(self.fname),
145
141
Path (self .fname ).name ,
146
142
)
147
143
return text
@@ -185,7 +181,7 @@ def __init__(self, fname, update=False):
185
181
def extract_infos (self ):
186
182
"""Extract package infos (name, version, architecture)
187
183
from filename (installer basename)"""
188
- bname = Path (self .fname ).name # osp.basename(self.fname)
184
+ bname = Path (self .fname ).name
189
185
if bname .endswith (('32.whl' , '64.whl' )):
190
186
# {name}[-{bloat}]-{version}-{python tag}-{abi tag}-{platform tag}.whl
191
187
# ['sounddevice','0.3.5','py2.py3.cp34.cp35','none','win32']
@@ -233,8 +229,6 @@ def extract_infos(self):
233
229
self .name = match .groups ()[0 ]
234
230
self .logname = '%s-wininst.log' % self .name
235
231
fd = open (
236
- # osp.join(
237
- # self.distribution.target, self.logname
238
232
str (Path (self .distribution .target ) / self .logname ),
239
233
'U' ,
240
234
)
@@ -282,7 +276,6 @@ def __init__(
282
276
target
283
277
)
284
278
# name of the exe (python.exe or pypy3;exe)
285
- # self.short_exe = osp.basename(utils.get_python_executable(self.target))
286
279
self .short_exe = Path (utils .get_python_executable (self .target )).name
287
280
288
281
def clean_up (self ):
@@ -313,52 +306,39 @@ def copy_files(
313
306
create_bat_files = False ,
314
307
):
315
308
"""Add copy task"""
316
- # srcdir = osp.join(targetdir, srcdir)
317
309
srcdir = str (Path (targetdir ) / srcdir )
318
- # if not osp.isdir(srcdir):
319
310
if not Path (srcdir ).is_dir ():
320
311
return
321
312
offset = len (srcdir ) + len (os .pathsep )
322
313
for dirpath , dirnames , filenames in os .walk (srcdir ):
323
314
for dname in dirnames :
324
- # t_dname = osp.join(dirpath, dname)[offset:]
325
315
t_dname = str (Path (dirpath ) / dname )[offset :]
326
- # src = osp.join(srcdir, t_dname)
327
316
src = str (Path (srcdir ) / t_dname )
328
- # dst = osp.join(dstdir, t_dname)
329
317
dst = str (Path (dstdir ) / t_dname )
330
318
if self .verbose :
331
319
print ("mkdir: %s" % dst )
332
- # full_dst = osp.join(self.target, dst)
333
320
full_dst = str (Path (self .target ) / dst )
334
- # if not osp.exists(full_dst):
335
321
if not Path (full_dst ).exists ():
336
322
os .mkdir (full_dst )
337
323
package .files .append (dst )
338
324
for fname in filenames :
339
- # t_fname = osp.join(dirpath, fname)[offset:]
340
325
t_fname = str (Path (dirpath ) / fname )[offset :]
341
- # src = osp.join(srcdir, t_fname)
342
326
src = str (Path (srcdir ) / t_fname )
343
327
if dirpath .endswith ('_system32' ):
344
328
# Files that should be copied in %WINDIR%\system32
345
329
dst = fname
346
330
else :
347
- # dst = osp.join(dstdir, t_fname)
348
331
dst = str (Path (dstdir ) / t_fname )
349
332
if self .verbose :
350
333
print ("file: %s" % dst )
351
- # full_dst = osp.join(self.target, dst)
352
334
full_dst = str (Path (self .target ) / dst )
353
335
shutil .move (src , full_dst )
354
336
package .files .append (dst )
355
- #name, ext = osp.splitext(dst)
356
337
name , ext = Path (dst ).stem , Path (dst ).suffix
357
338
if create_bat_files and ext in ('' , '.py' ):
358
339
dst = name + '.bat'
359
340
if self .verbose :
360
341
print ("file: %s" % dst )
361
- # full_dst = osp.join(self.target, dst)
362
342
full_dst = str (Path (self .target ) / dst )
363
343
fd = open (full_dst , 'w' )
364
344
fd .write (
@@ -372,11 +352,9 @@ def copy_files(
372
352
373
353
def create_file (self , package , name , dstdir , contents ):
374
354
"""Generate data file -- path is relative to distribution root dir"""
375
- # dst = osp.join(dstdir, name)
376
355
dst = str (Path (dstdir ) / name )
377
356
if self .verbose :
378
357
print ("create: %s" % dst )
379
- # full_dst = osp.join(self.target, dst)
380
358
full_dst = str (Path (self .target ) / dst )
381
359
open (full_dst , 'w' ).write (contents )
382
360
package .files .append (dst )
@@ -388,7 +366,6 @@ def get_installed_packages(self, update=False):
388
366
wppm = []
389
367
try :
390
368
if (
391
- #os.path.dirname(sys.executable)
392
369
str (Path (sys .executable ).parent )
393
370
== self .target
394
371
):
@@ -489,12 +466,9 @@ def do_pip_action(
489
466
my_actions = actions
490
467
if my_actions is None :
491
468
my_actions = []
492
- # executing = osp.join(
493
- # self.target, '..', 'scripts', 'env.bat'
494
469
executing = str (Path (
495
470
self .target ).parent / 'scripts' / 'env.bat'
496
471
)
497
- #if osp.isfile(executing):
498
472
if Path (executing ).is_file ():
499
473
complement = [
500
474
r'&&' ,
@@ -532,7 +506,6 @@ def patch_standard_packages(
532
506
import filecmp
533
507
534
508
# Adpating to PyPy
535
- # if 'pypy3' in osp.basename(utils.get_python_executable(self.target)):
536
509
if 'pypy3' in Path (utils .get_python_executable (self .target )).name :
537
510
site_package_place = "\\ site-packages\\ "
538
511
else :
@@ -547,16 +520,12 @@ def patch_standard_packages(
547
520
origin = self .target + site_package_place + "pywin32_system32"
548
521
549
522
destin = self .target
550
- # if osp.isdir(origin):
551
523
if Path (origin ).is_dir ():
552
524
for name in os .listdir (origin ):
553
525
here , there = (
554
- # osp.join(origin, name),
555
526
str (Path (origin ) / name ),
556
- # osp.join(destin, name),
557
527
str (Path (destin ) / name ),
558
528
)
559
- # if not os.path.exists(there
560
529
if not Path (there ).exists (
561
530
) or not filecmp .cmp (here , there ):
562
531
shutil .copyfile (here , there )
@@ -648,13 +617,10 @@ def create_pybat(
648
617
):
649
618
"""Create launcher batch script when missing"""
650
619
651
- # scriptpy = osp.join(
652
- # self.target, 'Scripts'
653
620
scriptpy = str (Path (self .target ) / 'Scripts'
654
621
) # std Scripts of python
655
622
656
623
# PyPy has no initial Scipts directory
657
- # if not osp.isdir(scriptpy):
658
624
if not Path (scriptpy ).is_dir ():
659
625
os .mkdir (scriptpy )
660
626
@@ -667,19 +633,12 @@ def create_pybat(
667
633
else :
668
634
my_list = names
669
635
for name in my_list :
670
- # if osp.isdir(scriptpy) and osp.isfile(
671
- # osp.join(scriptpy, name)):
672
636
if Path (scriptpy ).is_dir () and (Path (
673
- scriptpy ) / name ).is_dir ():
674
- #if not osp.isfile(
675
- # osp.join(scriptpy, name + '.exe')
676
- #) and not osp.isfile(
677
- # osp.join(scriptpy, name + '.bat')
637
+ scriptpy ) / name ).is_file ():
678
638
if not (Path (scriptpy ) / (name + '.exe' )).is_file (
679
639
) and not (Path (scriptpy ) / (name + '.bat' )).is_file (
680
640
):
681
641
fd = open (
682
- # osp.join(scriptpy, name + '.bat'),
683
642
str (Path (scriptpy ) / (name + '.bat' )),
684
643
'w' ,
685
644
)
@@ -701,8 +660,6 @@ def handle_specific_packages(self, package):
701
660
self .create_file (
702
661
package ,
703
662
name ,
704
- #osp.join(
705
- # 'Lib', 'site-packages', package.name
706
663
str (Path (
707
664
'Lib' ) / 'site-packages' / package .name
708
665
),
@@ -729,7 +686,6 @@ def handle_specific_packages(self, package):
729
686
"%WINPYDIR%\python.exe" "%WINPYDIR%\Lib\site-packages\package.name\uic\pyuic.py" %1 %2 %3 %4 %5 %6 %7 %8 %9'''
730
687
731
688
# PyPy adaption: python.exe or pypy3.exe
732
- #my_exec = osp.basename(utils.get_python_executable(self.target))
733
689
my_exec = Path (utils .get_python_executable (self .target )).name
734
690
tmp_string = tmp_string .replace ('python.exe' , my_exec )
735
691
@@ -742,16 +698,13 @@ def handle_specific_packages(self, package):
742
698
),
743
699
)
744
700
# Adding missing __init__.py files (fixes Issue 8)
745
- # uic_path = osp.join(
746
- # 'Lib', 'site-packages', package.name, 'uic'
747
701
uic_path = str (Path (
748
702
'Lib' ) / 'site-packages' / package .name / 'uic'
749
703
)
750
704
for dirname in ('Loader' , 'port_v2' , 'port_v3' ):
751
705
self .create_file (
752
706
package ,
753
707
'__init__.py' ,
754
- # osp.join(uic_path, dirname),
755
708
str (Path (uic_path ) / dirname ),
756
709
'' ,
757
710
)
@@ -835,40 +788,20 @@ def install_script(self, script, install_options=None):
835
788
836
789
def main (test = False ):
837
790
if test :
838
- #sbdir = osp.join(
839
- # osp.dirname(__file__),
840
- # os.pardir,
841
- # os.pardir,
842
- # os.pardir,
843
- # 'sandbox',
844
- #)
845
791
sbdir = str (Path (__file__ ).parents [0 ].parent .parent .parent / 'sandbox' )
846
- #tmpdir = osp.join(sbdir, 'tobedeleted')
847
792
tmpdir = str (Path (sbdir ) / 'tobedeleted' )
848
793
849
- # fname = osp.join(tmpdir, 'scipy-0.10.1.win-amd64-py2.7.exe')
850
- #fname = osp.join(
851
- # sbdir, 'VTK-5.10.0-Qt-4.7.4.win32-py2.7.exe'
852
794
fname = str (Path (
853
795
sbdir ) / 'VTK-5.10.0-Qt-4.7.4.win32-py2.7.exe'
854
796
)
855
797
print (Package (fname ))
856
798
sys .exit ()
857
- #target = osp.join(
858
- # utils.BASE_DIR,
859
- # 'build',
860
- # 'winpython-2.7.3',
861
- # 'python-2.7.3',
862
799
target = str (Path (
863
800
utils .BASE_DIR ) /
864
801
'build' /
865
802
'winpython-2.7.3' /
866
803
'python-2.7.3'
867
804
)
868
- #fname = osp.join(
869
- # utils.BASE_DIR,
870
- # 'packages.src',
871
- # 'docutils-0.9.1.tar.gz',
872
805
fname = str (Path (
873
806
utils .BASE_DIR ) /
874
807
'packages.src' /
@@ -1038,7 +971,6 @@ def main(test=False):
1038
971
sys .exit ()
1039
972
elif not args .install and not args .uninstall :
1040
973
args .install = True
1041
- #if not osp.isfile(args.fname) and args.install:
1042
974
if not Path (args .fname ).is_file () and args .install :
1043
975
if args .fname == "" :
1044
976
parser .print_help ()
0 commit comments