@@ -394,54 +394,37 @@ def install(self, package, install_options=None):
394394 elif bname .endswith ('.msi' ):
395395 self .install_bdist_msi (package )
396396 self .handle_specific_packages (package )
397+ # minimal post-install actions
398+ self .patch_standard_packages (package .name )
397399 if not package .fname .endswith (('.whl' , '.tar.gz' , '.zip' )):
398400 package .save_log (self .logdir )
399401 if tmp_fname is not None :
400402 os .remove (tmp_fname )
401403
402- # We minimal post-install pywin (pywin32_postinstall.py do too much)
403- if package .name == "pywin32" :
404+ def patch_standard_packages (self , package_name = None ):
405+ """patch Winpython packages in need"""
406+ import filecmp
407+ # 'pywin32' minimal post-install (pywin32_postinstall.py do too much)
408+ if package_name == "pywin32" or package_name == None :
404409 origin = self .target + (r"\Lib\site-packages\pywin32_system32" )
405410 destin = self .target
406411 for name in os .listdir (origin ):
407- print ("shutil.copy " , osp .join (origin , name ), " " , osp .join (destin , name ))
408- shutil .copyfile (osp .join (origin , name ), osp .join (destin , name ))
409-
410- # We patch pip live (around line 100) !!!!
412+ here , there = osp .join (origin , name ), osp .join (destin , name )
413+ if (not os .path .exists (there ) or
414+ not filecmp .cmp (here , there )):
415+ shutil .copyfile (here , there )
416+ # 'pip' to do movable launchers (around line 100) !!!!
411417 # rational: https://github.com/pypa/pip/issues/2328
412- if package .name == "get-pip" :
413- # self.exec_script
414- my_script_is = osp .join (self .target , 'Scripts' , 'get-pip.py' )
415- self .install_script (my_script_is , install_options = None )
416- # change of method 2014-05-08:
417- # touching pip at installation seems not working anymore
418- # so brute force method is applied
419- if package .name == "pip" or package .name == "get-pip" or 1 == 1 :
420- self .patch_all_shebang ()
421- # ensure pip.exe and easy_install.exe
422- problems = [('pip' , 'pip' ), ('easy_install' , 'easy_install-' )]
423- solutions = [('%s.%s' % sys .version_info [:2 ]),
424- ('%s' % sys .version_info [0 ])]
425- for p in problems :
426- problem = r'%s\Scripts\%s.exe' % (self .target , p [0 ])
427- for s in solutions :
428- solution = r'%s\Scripts\%s%s.exe' % (self .target , p [1 ], s )
429- if not osp .exists (problem ) and osp .exists (solution ):
430- shutil .copyfile (solution , problem )
431-
432- if package .name == "pip" or package .name == "get-pip" :
418+ if package_name == "pip" or package_name == None :
419+ # ensure pip will create movable launchers
433420 utils .patch_sourcefile (
434421 self .target + (
435422 r"\Lib\site-packages\pip\_vendor\distlib\scripts.py" ),
436423 " executable = get_executable()" ,
437424 " executable = os.path.join(os.path.basename(get_executable()))" )
438- # We patch IPython\kernel\kernelspec.py live (around line 51) !!!!
439- if package .name == "ipython" :
440- utils .patch_sourcefile (
441- self .target + r"\Lib\site-packages\IPython\kernel\kernelspec.py" ,
442- r" kernel_dict = json.load(f)" ,
443- r" kernel_dict = json.loads(('\n'.join(f.readlines())).replace('[WINPYDIR]',(os.environ['WINPYDIR']).replace('\\','\\\\')))" +
444- ";" + "from winpython.utils import patch_julia03; patch_julia03()" )
425+
426+ # create movable launchers for previous package installations
427+ self .patch_all_shebang ()
445428
446429 def handle_specific_packages (self , package ):
447430 """Packages requiring additional configuration"""
0 commit comments