1313from __future__ import print_function
1414
1515import os
16- # import os.path as osp
1716from pathlib import Path
1817import shutil
1918import re
@@ -75,7 +74,6 @@ def get_package_metadata(database, name, gotoWWW=False, update=False):
7574 # machine which is not connected to the internet
7675 # we store only normalized names now (PEP 503)
7776 db = cp .ConfigParser ()
78- # db.readfp(open(osp.join(DATA_PATH, database)))
7977 db .readfp (open (str (Path (DATA_PATH ) / database )))
8078 my_metadata = dict (
8179 description = '' ,
@@ -110,7 +108,6 @@ def get_package_metadata(database, name, gotoWWW=False, update=False):
110108 try :
111109 db [normalize (name )] = {}
112110 db [normalize (name )]['description' ] = my_metadata ['description' ]
113- # with open(osp.join(DATA_PATH, database), 'w') as configfile:
114111 with open (str (Path (DATA_PATH ) / database ), 'w' ) as configfile :
115112 db .write (configfile )
116113 except :
@@ -141,7 +138,6 @@ def __str__(self):
141138 pytext ,
142139 self .description ,
143140 self .url ,
144- # osp.basename(self.fname),
145141 Path (self .fname ).name ,
146142 )
147143 return text
@@ -185,7 +181,7 @@ def __init__(self, fname, update=False):
185181 def extract_infos (self ):
186182 """Extract package infos (name, version, architecture)
187183 from filename (installer basename)"""
188- bname = Path (self .fname ).name # osp.basename(self.fname)
184+ bname = Path (self .fname ).name
189185 if bname .endswith (('32.whl' , '64.whl' )):
190186 # {name}[-{bloat}]-{version}-{python tag}-{abi tag}-{platform tag}.whl
191187 # ['sounddevice','0.3.5','py2.py3.cp34.cp35','none','win32']
@@ -233,8 +229,6 @@ def extract_infos(self):
233229 self .name = match .groups ()[0 ]
234230 self .logname = '%s-wininst.log' % self .name
235231 fd = open (
236- # osp.join(
237- # self.distribution.target, self.logname
238232 str (Path (self .distribution .target ) / self .logname ),
239233 'U' ,
240234 )
@@ -282,7 +276,6 @@ def __init__(
282276 target
283277 )
284278 # name of the exe (python.exe or pypy3;exe)
285- # self.short_exe = osp.basename(utils.get_python_executable(self.target))
286279 self .short_exe = Path (utils .get_python_executable (self .target )).name
287280
288281 def clean_up (self ):
@@ -313,52 +306,39 @@ def copy_files(
313306 create_bat_files = False ,
314307 ):
315308 """Add copy task"""
316- # srcdir = osp.join(targetdir, srcdir)
317309 srcdir = str (Path (targetdir ) / srcdir )
318- # if not osp.isdir(srcdir):
319310 if not Path (srcdir ).is_dir ():
320311 return
321312 offset = len (srcdir ) + len (os .pathsep )
322313 for dirpath , dirnames , filenames in os .walk (srcdir ):
323314 for dname in dirnames :
324- # t_dname = osp.join(dirpath, dname)[offset:]
325315 t_dname = str (Path (dirpath ) / dname )[offset :]
326- # src = osp.join(srcdir, t_dname)
327316 src = str (Path (srcdir ) / t_dname )
328- # dst = osp.join(dstdir, t_dname)
329317 dst = str (Path (dstdir ) / t_dname )
330318 if self .verbose :
331319 print ("mkdir: %s" % dst )
332- # full_dst = osp.join(self.target, dst)
333320 full_dst = str (Path (self .target ) / dst )
334- # if not osp.exists(full_dst):
335321 if not Path (full_dst ).exists ():
336322 os .mkdir (full_dst )
337323 package .files .append (dst )
338324 for fname in filenames :
339- # t_fname = osp.join(dirpath, fname)[offset:]
340325 t_fname = str (Path (dirpath ) / fname )[offset :]
341- # src = osp.join(srcdir, t_fname)
342326 src = str (Path (srcdir ) / t_fname )
343327 if dirpath .endswith ('_system32' ):
344328 # Files that should be copied in %WINDIR%\system32
345329 dst = fname
346330 else :
347- # dst = osp.join(dstdir, t_fname)
348331 dst = str (Path (dstdir ) / t_fname )
349332 if self .verbose :
350333 print ("file: %s" % dst )
351- # full_dst = osp.join(self.target, dst)
352334 full_dst = str (Path (self .target ) / dst )
353335 shutil .move (src , full_dst )
354336 package .files .append (dst )
355- #name, ext = osp.splitext(dst)
356337 name , ext = Path (dst ).stem , Path (dst ).suffix
357338 if create_bat_files and ext in ('' , '.py' ):
358339 dst = name + '.bat'
359340 if self .verbose :
360341 print ("file: %s" % dst )
361- # full_dst = osp.join(self.target, dst)
362342 full_dst = str (Path (self .target ) / dst )
363343 fd = open (full_dst , 'w' )
364344 fd .write (
@@ -372,11 +352,9 @@ def copy_files(
372352
373353 def create_file (self , package , name , dstdir , contents ):
374354 """Generate data file -- path is relative to distribution root dir"""
375- # dst = osp.join(dstdir, name)
376355 dst = str (Path (dstdir ) / name )
377356 if self .verbose :
378357 print ("create: %s" % dst )
379- # full_dst = osp.join(self.target, dst)
380358 full_dst = str (Path (self .target ) / dst )
381359 open (full_dst , 'w' ).write (contents )
382360 package .files .append (dst )
@@ -388,7 +366,6 @@ def get_installed_packages(self, update=False):
388366 wppm = []
389367 try :
390368 if (
391- #os.path.dirname(sys.executable)
392369 str (Path (sys .executable ).parent )
393370 == self .target
394371 ):
@@ -489,12 +466,9 @@ def do_pip_action(
489466 my_actions = actions
490467 if my_actions is None :
491468 my_actions = []
492- # executing = osp.join(
493- # self.target, '..', 'scripts', 'env.bat'
494469 executing = str (Path (
495470 self .target ).parent / 'scripts' / 'env.bat'
496471 )
497- #if osp.isfile(executing):
498472 if Path (executing ).is_file ():
499473 complement = [
500474 r'&&' ,
@@ -532,7 +506,6 @@ def patch_standard_packages(
532506 import filecmp
533507
534508 # Adpating to PyPy
535- # if 'pypy3' in osp.basename(utils.get_python_executable(self.target)):
536509 if 'pypy3' in Path (utils .get_python_executable (self .target )).name :
537510 site_package_place = "\\ site-packages\\ "
538511 else :
@@ -547,16 +520,12 @@ def patch_standard_packages(
547520 origin = self .target + site_package_place + "pywin32_system32"
548521
549522 destin = self .target
550- # if osp.isdir(origin):
551523 if Path (origin ).is_dir ():
552524 for name in os .listdir (origin ):
553525 here , there = (
554- # osp.join(origin, name),
555526 str (Path (origin ) / name ),
556- # osp.join(destin, name),
557527 str (Path (destin ) / name ),
558528 )
559- # if not os.path.exists(there
560529 if not Path (there ).exists (
561530 ) or not filecmp .cmp (here , there ):
562531 shutil .copyfile (here , there )
@@ -648,13 +617,10 @@ def create_pybat(
648617 ):
649618 """Create launcher batch script when missing"""
650619
651- # scriptpy = osp.join(
652- # self.target, 'Scripts'
653620 scriptpy = str (Path (self .target ) / 'Scripts'
654621 ) # std Scripts of python
655622
656623 # PyPy has no initial Scipts directory
657- # if not osp.isdir(scriptpy):
658624 if not Path (scriptpy ).is_dir ():
659625 os .mkdir (scriptpy )
660626
@@ -667,19 +633,12 @@ def create_pybat(
667633 else :
668634 my_list = names
669635 for name in my_list :
670- # if osp.isdir(scriptpy) and osp.isfile(
671- # osp.join(scriptpy, name)):
672636 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 ():
678638 if not (Path (scriptpy ) / (name + '.exe' )).is_file (
679639 ) and not (Path (scriptpy ) / (name + '.bat' )).is_file (
680640 ):
681641 fd = open (
682- # osp.join(scriptpy, name + '.bat'),
683642 str (Path (scriptpy ) / (name + '.bat' )),
684643 'w' ,
685644 )
@@ -701,8 +660,6 @@ def handle_specific_packages(self, package):
701660 self .create_file (
702661 package ,
703662 name ,
704- #osp.join(
705- # 'Lib', 'site-packages', package.name
706663 str (Path (
707664 'Lib' ) / 'site-packages' / package .name
708665 ),
@@ -729,7 +686,6 @@ def handle_specific_packages(self, package):
729686"%WINPYDIR%\python.exe" "%WINPYDIR%\Lib\site-packages\package.name\uic\pyuic.py" %1 %2 %3 %4 %5 %6 %7 %8 %9'''
730687
731688 # PyPy adaption: python.exe or pypy3.exe
732- #my_exec = osp.basename(utils.get_python_executable(self.target))
733689 my_exec = Path (utils .get_python_executable (self .target )).name
734690 tmp_string = tmp_string .replace ('python.exe' , my_exec )
735691
@@ -742,16 +698,13 @@ def handle_specific_packages(self, package):
742698 ),
743699 )
744700 # Adding missing __init__.py files (fixes Issue 8)
745- # uic_path = osp.join(
746- # 'Lib', 'site-packages', package.name, 'uic'
747701 uic_path = str (Path (
748702 'Lib' ) / 'site-packages' / package .name / 'uic'
749703 )
750704 for dirname in ('Loader' , 'port_v2' , 'port_v3' ):
751705 self .create_file (
752706 package ,
753707 '__init__.py' ,
754- # osp.join(uic_path, dirname),
755708 str (Path (uic_path ) / dirname ),
756709 '' ,
757710 )
@@ -835,40 +788,20 @@ def install_script(self, script, install_options=None):
835788
836789def main (test = False ):
837790 if test :
838- #sbdir = osp.join(
839- # osp.dirname(__file__),
840- # os.pardir,
841- # os.pardir,
842- # os.pardir,
843- # 'sandbox',
844- #)
845791 sbdir = str (Path (__file__ ).parents [0 ].parent .parent .parent / 'sandbox' )
846- #tmpdir = osp.join(sbdir, 'tobedeleted')
847792 tmpdir = str (Path (sbdir ) / 'tobedeleted' )
848793
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'
852794 fname = str (Path (
853795 sbdir ) / 'VTK-5.10.0-Qt-4.7.4.win32-py2.7.exe'
854796 )
855797 print (Package (fname ))
856798 sys .exit ()
857- #target = osp.join(
858- # utils.BASE_DIR,
859- # 'build',
860- # 'winpython-2.7.3',
861- # 'python-2.7.3',
862799 target = str (Path (
863800 utils .BASE_DIR ) /
864801 'build' /
865802 'winpython-2.7.3' /
866803 'python-2.7.3'
867804 )
868- #fname = osp.join(
869- # utils.BASE_DIR,
870- # 'packages.src',
871- # 'docutils-0.9.1.tar.gz',
872805 fname = str (Path (
873806 utils .BASE_DIR ) /
874807 'packages.src' /
@@ -1038,7 +971,6 @@ def main(test=False):
1038971 sys .exit ()
1039972 elif not args .install and not args .uninstall :
1040973 args .install = True
1041- #if not osp.isfile(args.fname) and args.install:
1042974 if not Path (args .fname ).is_file () and args .install :
1043975 if args .fname == "" :
1044976 parser .print_help ()
0 commit comments