99
1010Created on Fri Aug 03 14:32:26 2012
1111"""
12-
12+ # pypy3 to patch from 'python' to 'pypy3': 379 493 497 627 692 696 743 767 785
1313from __future__ import print_function
1414
1515import os
@@ -376,7 +376,7 @@ def get_installed_packages(self, update=False):
376376 else :
377377 # indirect way: we interrogate something else
378378 cmdx = [
379- osp . join (self .target , 'python.exe' ),
379+ utils . get_python_executable (self .target ), # PyPy !
380380 '-c' ,
381381 "import pip;from pip._internal.utils.misc import get_installed_distributions as pip_get_installed_distributions ;print('+!+'.join(['%s@+@%s@+@' % (i.key,i.version) for i in pip_get_installed_distributions()]))" ,
382382 ]
@@ -490,11 +490,13 @@ def do_pip_action(
490490 '/D' ,
491491 self .target ,
492492 r'&&' ,
493- osp .join (self .target , 'python.exe' ),
493+ utils .get_python_executable (self .target ),
494+ # Before PyPy: osp.join(self.target, 'python.exe')
494495 ]
495496 complement += ['-m' , 'pip' ]
496497 else :
497- executing = osp .join (self .target , 'python.exe' )
498+ executing = utils .get_python_executable (self .target )
499+ # Before PyPy: osp.join(self.target, 'python.exe')
498500 complement = ['-m' , 'pip' ]
499501 try :
500502 fname = utils .do_script (
@@ -525,6 +527,10 @@ def patch_standard_packages(
525527 origin = self .target + (
526528 r"\Lib\site-packages\pywin32_system32"
527529 )
530+ if 'pypy3' in sys .executable :
531+ origin = self .target + (
532+ r"\site-packages\pywin32_system32"
533+ )
528534 destin = self .target
529535 if osp .isdir (origin ):
530536 for name in os .listdir (origin ):
@@ -548,29 +554,34 @@ def patch_standard_packages(
548554 sheb_fix = " executable = get_executable()"
549555 sheb_mov1 = " executable = os.path.join(os.path.basename(get_executable()))"
550556 sheb_mov2 = " executable = os.path.join('..',os.path.basename(get_executable()))"
557+ if 'pypy3' in sys .executable :
558+ the_place = r"\site-packages\pip\_vendor\distlib\scripts.py"
559+ else :
560+ the_place = r"\Lib\site-packages\pip\_vendor\distlib\scripts.py"
561+ print (the_place )
551562 if to_movable :
552563 utils .patch_sourcefile (
553564 self .target
554- + r"\Lib\site-packages\pip\_vendor\distlib\scripts.py" ,
565+ + the_place ,
555566 sheb_fix ,
556567 sheb_mov1 ,
557568 )
558569 utils .patch_sourcefile (
559570 self .target
560- + r"\Lib\site-packages\pip\_vendor\distlib\scripts.py" ,
571+ + the_place ,
561572 sheb_mov2 ,
562573 sheb_mov1 ,
563574 )
564575 else :
565576 utils .patch_sourcefile (
566577 self .target
567- + r"\Lib\site-packages\pip\_vendor\distlib\scripts.py" ,
578+ + the_place ,
568579 sheb_mov1 ,
569580 sheb_fix ,
570581 )
571582 utils .patch_sourcefile (
572583 self .target
573- + r"\Lib\site-packages\pip\_vendor\distlib\scripts.py" ,
584+ + the_place ,
574585 sheb_mov2 ,
575586 sheb_fix ,
576587 )
@@ -686,6 +697,11 @@ def handle_specific_packages(self, package):
686697 tmp_string = r'''@echo off
687698if "%WINPYDIR%"=="" call "%~dp0..\..\scripts\env.bat"
688699"%WINPYDIR%\python.exe" "%WINPYDIR%\Lib\site-packages\package.name\uic\pyuic.py" %1 %2 %3 %4 %5 %6 %7 %8 %9'''
700+
701+ # PyPy adaption: python.exe or pypy3.exe
702+ my_exec = osp .basename (utils .get_python_executable (self .target ))
703+ tmp_string = tmp_string .replace ('python.exe' , my_exec )
704+
689705 self .create_file (
690706 package ,
691707 'pyuic%s.bat' % package .name [- 1 ],
@@ -730,9 +746,10 @@ def uninstall(self, package):
730746 if not package .name == 'pip' :
731747 # trick to get true target (if not current)
732748 this_executable_path = self .target
749+ this_exec = utils .get_python_executable (self .target ) # PyPy !
733750 subprocess .call (
734751 [
735- this_executable_path + r'\python.exe' ,
752+ this_exec ,
736753 '-m' ,
737754 'pip' ,
738755 'uninstall' ,
@@ -755,9 +772,7 @@ def install_bdist_direct(
755772 try :
756773 fname = utils .direct_pip_install (
757774 package .fname ,
758- python_exe = osp .join (
759- self .target , 'python.exe'
760- ),
775+ python_exe = utils .get_python_executable (self .target ), # PyPy !
761776 architecture = self .architecture ,
762777 verbose = self .verbose ,
763778 install_options = install_options ,
@@ -773,9 +788,7 @@ def install_script(self, script, install_options=None):
773788 try :
774789 fname = utils .do_script (
775790 script ,
776- python_exe = osp .join (
777- self .target , 'python.exe'
778- ),
791+ python_exe = utils .get_python_executable (self .target ), # PyPy3 !
779792 architecture = self .architecture ,
780793 verbose = self .verbose ,
781794 install_options = install_options ,
0 commit comments