9
9
10
10
Created on Fri Aug 03 14:32:26 2012
11
11
"""
12
-
12
+ # pypy3 to patch from 'python' to 'pypy3': 379 493 497 627 692 696 743 767 785
13
13
from __future__ import print_function
14
14
15
15
import os
@@ -376,7 +376,7 @@ def get_installed_packages(self, update=False):
376
376
else :
377
377
# indirect way: we interrogate something else
378
378
cmdx = [
379
- osp . join (self .target , 'python.exe' ),
379
+ utils . get_python_executable (self .target ), # PyPy !
380
380
'-c' ,
381
381
"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()]))" ,
382
382
]
@@ -490,11 +490,13 @@ def do_pip_action(
490
490
'/D' ,
491
491
self .target ,
492
492
r'&&' ,
493
- osp .join (self .target , 'python.exe' ),
493
+ utils .get_python_executable (self .target ),
494
+ # Before PyPy: osp.join(self.target, 'python.exe')
494
495
]
495
496
complement += ['-m' , 'pip' ]
496
497
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')
498
500
complement = ['-m' , 'pip' ]
499
501
try :
500
502
fname = utils .do_script (
@@ -525,6 +527,10 @@ def patch_standard_packages(
525
527
origin = self .target + (
526
528
r"\Lib\site-packages\pywin32_system32"
527
529
)
530
+ if 'pypy3' in sys .executable :
531
+ origin = self .target + (
532
+ r"\site-packages\pywin32_system32"
533
+ )
528
534
destin = self .target
529
535
if osp .isdir (origin ):
530
536
for name in os .listdir (origin ):
@@ -548,29 +554,34 @@ def patch_standard_packages(
548
554
sheb_fix = " executable = get_executable()"
549
555
sheb_mov1 = " executable = os.path.join(os.path.basename(get_executable()))"
550
556
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 )
551
562
if to_movable :
552
563
utils .patch_sourcefile (
553
564
self .target
554
- + r"\Lib\site-packages\pip\_vendor\distlib\scripts.py" ,
565
+ + the_place ,
555
566
sheb_fix ,
556
567
sheb_mov1 ,
557
568
)
558
569
utils .patch_sourcefile (
559
570
self .target
560
- + r"\Lib\site-packages\pip\_vendor\distlib\scripts.py" ,
571
+ + the_place ,
561
572
sheb_mov2 ,
562
573
sheb_mov1 ,
563
574
)
564
575
else :
565
576
utils .patch_sourcefile (
566
577
self .target
567
- + r"\Lib\site-packages\pip\_vendor\distlib\scripts.py" ,
578
+ + the_place ,
568
579
sheb_mov1 ,
569
580
sheb_fix ,
570
581
)
571
582
utils .patch_sourcefile (
572
583
self .target
573
- + r"\Lib\site-packages\pip\_vendor\distlib\scripts.py" ,
584
+ + the_place ,
574
585
sheb_mov2 ,
575
586
sheb_fix ,
576
587
)
@@ -686,6 +697,11 @@ def handle_specific_packages(self, package):
686
697
tmp_string = r'''@echo off
687
698
if "%WINPYDIR%"=="" call "%~dp0..\..\scripts\env.bat"
688
699
"%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
+
689
705
self .create_file (
690
706
package ,
691
707
'pyuic%s.bat' % package .name [- 1 ],
@@ -730,9 +746,10 @@ def uninstall(self, package):
730
746
if not package .name == 'pip' :
731
747
# trick to get true target (if not current)
732
748
this_executable_path = self .target
749
+ this_exec = utils .get_python_executable (self .target ) # PyPy !
733
750
subprocess .call (
734
751
[
735
- this_executable_path + r'\python.exe' ,
752
+ this_exec ,
736
753
'-m' ,
737
754
'pip' ,
738
755
'uninstall' ,
@@ -755,9 +772,7 @@ def install_bdist_direct(
755
772
try :
756
773
fname = utils .direct_pip_install (
757
774
package .fname ,
758
- python_exe = osp .join (
759
- self .target , 'python.exe'
760
- ),
775
+ python_exe = utils .get_python_executable (self .target ), # PyPy !
761
776
architecture = self .architecture ,
762
777
verbose = self .verbose ,
763
778
install_options = install_options ,
@@ -773,9 +788,7 @@ def install_script(self, script, install_options=None):
773
788
try :
774
789
fname = utils .do_script (
775
790
script ,
776
- python_exe = osp .join (
777
- self .target , 'python.exe'
778
- ),
791
+ python_exe = utils .get_python_executable (self .target ), # PyPy3 !
779
792
architecture = self .architecture ,
780
793
verbose = self .verbose ,
781
794
install_options = install_options ,
0 commit comments