@@ -321,7 +321,7 @@ def __init__(
321321 docsdirs = []
322322 self ._docsdirs = docsdirs
323323 self .verbose = verbose
324- self .winpydir = None
324+ self .winpydir = None # new WinPython BaseDirectory
325325 self .distribution = None
326326 self .installed_packages = []
327327 self .simulation = simulation
@@ -331,20 +331,31 @@ def __init__(
331331 self .install_options = install_options
332332 self .flavor = flavor
333333
334- self .python_fname = self .get_package_fname (
334+ # python_fname = the .zip of the python interpreter PyPy !
335+ # impot re
336+ # re.match(r'(pypy3*-v|python-)([0-9\.rcba]*)((\.|\-)(amd64|win64)?\.zip')
337+ try : # PyPy
338+ self .python_fname = self .get_package_fname (
339+ r'(pypy3|python-)([0-9]|[a-zA-Z]|.)*.zip'
340+ )
341+ except : # normal Python
342+ self .python_fname = self .get_package_fname (
335343 r'python-([0-9\.rcba]*)((\.|\-)amd64)?\.(zip|zip)'
336- )
344+ )
345+
346+ # osp.join(self.winpydir, self.python_name) = Directory of Python exec
347+ # self.pythondir =osp.join(self.winpydir, self.python_name)
337348 self .python_name = osp .basename (self .python_fname )[
338349 :- 4
339350 ]
340- self .distname = 'win%s' % self .python_name
341- vlst = (
342- re .match (r'winpython-([0-9\.]*)' , self .distname )
343- .groups ()[0 ]
344- .split ('.' )
345- )
346- self .python_version = '.' .join (vlst [:2 ])
347- self .python_fullversion = '.' .join (vlst [:3 ])
351+ self .distname = 'winUNKNOWN' # win%s' % self.python_name # PyPy ?
352+ # vlst = (
353+ # re.match(r'winpython-([0-9\.]*)', self.distname)
354+ # .groups()[0]
355+ # .split('.')
356+ # )
357+ self .python_version = 'winUNKNOWN' # ' .'.join(vlst[:2])
358+ self .python_fullversion = 'winUNKNOWN' # ' .'.join(vlst[:3])
348359
349360 @property
350361 def package_index_wiki (self ):
@@ -471,7 +482,7 @@ def winpyver(self):
471482 @property
472483 def python_dir (self ):
473484 """Return Python dirname (full path) of the target distribution"""
474- return osp .join (self .winpydir , self .python_name )
485+ return osp .join (self .winpydir , self .python_name ) # python.exe path
475486
476487 @property
477488 def winpy_arch (self ):
@@ -561,13 +572,21 @@ def get_package_fname(self, pattern):
561572 % pattern
562573 )
563574
564- def create_batch_script (self , name , contents ):
575+ def create_batch_script (self , name , contents ,
576+ do_changes = None ):
565577 """Create batch script %WINPYDIR%/name"""
566578 scriptdir = osp .join (self .winpydir , 'scripts' )
567579 if not osp .isdir (scriptdir ):
568580 os .mkdir (scriptdir )
581+ print ('dochanges for %s %' , name , do_changes )
582+ # live patch pypy3
583+ contents_final = contents
584+ if do_changes != None :
585+ for i in do_changes :
586+ contents_final = contents_final .replace (i [0 ], i [1 ])
587+
569588 fd = open (osp .join (scriptdir , name ), 'w' )
570- fd .write (contents )
589+ fd .write (contents_final )
571590 fd .close ()
572591
573592 def create_launcher (
@@ -985,6 +1004,14 @@ def _create_batch_scripts_initial(self):
9851004 + convps (self .postpath )
9861005 )
9871006
1007+ # PyPy3
1008+ shorty = self .distribution .short_exe
1009+ changes = (
1010+ (r'DIR%\python.exe' , r'DIR%' + "\\ " + shorty ),
1011+ (r'DIR%\PYTHON.EXE' , r'DIR%' + "\\ " + shorty ),
1012+ )
1013+ if shorty == 'pypy3.exe' :
1014+ changes += ((r'\Lib\idlelib' , r'\lib-python\3\idlelib' ),)
9881015 self .create_batch_script (
9891016 'env.bat' ,
9901017 r"""@echo off
@@ -1003,7 +1030,6 @@ def _create_batch_scripts_initial(self):
10031030 + r"""
10041031rem 2019-08-25 pyjulia needs absolutely a variable PYTHON=%WINPYDIR%python.exe
10051032set PYTHON=%WINPYDIR%\python.exe
1006-
10071033set WINPYVER="""
10081034 + self .winpyver
10091035 + r"""
@@ -1124,6 +1150,7 @@ def _create_batch_scripts_initial(self):
11241150)>> "%winpython_ini%"
11251151
11261152""" ,
1153+ do_changes = changes ,
11271154 )
11281155
11291156 self .create_batch_script (
@@ -1303,6 +1330,7 @@ def _create_batch_scripts_initial(self):
13031330$host.ui.RawUI.ForegroundColor = "White"
13041331
13051332""" ,
1333+ do_changes = changes ,
13061334 )
13071335
13081336 self .create_batch_script (
@@ -1313,6 +1341,7 @@ def _create_batch_scripts_initial(self):
13131341Powershell.exe -Command "& {Start-Process PowerShell.exe -ArgumentList '-ExecutionPolicy RemoteSigned -noexit -File ""%~dp0WinPython_PS_Prompt.ps1""'}"
13141342exit
13151343""" ,
1344+ do_changes = changes ,
13161345 )
13171346
13181347 self .create_batch_script (
@@ -1322,6 +1351,7 @@ def _create_batch_scripts_initial(self):
13221351Powershell.exe -Command "& {Start-Process PowerShell.exe -ArgumentList '-ExecutionPolicy RemoteSigned -noexit -File ""%~dp0WinPython_PS_Prompt.ps1""'}"
13231352exit
13241353""" ,
1354+ do_changes = changes ,
13251355 )
13261356
13271357 self .create_batch_script (
@@ -1369,6 +1399,7 @@ def _create_batch_scripts_initial(self):
13691399if not exist "%HOME%\pydistutils.cfg" xcopy "%WINPYDIRBASE%\settings\pydistutils.cfg" "%HOME%"
13701400:no_cython
13711401""" ,
1402+ do_changes = changes ,
13721403 )
13731404
13741405 self .create_batch_script (
@@ -1440,6 +1471,17 @@ def _create_batch_scripts_initial(self):
14401471 def _create_batch_scripts (self ):
14411472 """Create batch scripts"""
14421473 self ._print ("Creating batch scripts" )
1474+
1475+ # PyPy3
1476+ shorty = self .distribution .short_exe
1477+ changes = (
1478+ (r'DIR%\python.exe' , r'DIR%' + "\\ " + shorty ),
1479+ (r'DIR%\PYTHON.EXE' , r'DIR%' + "\\ " + shorty ),
1480+ )
1481+ if shorty == 'pypy3.exe' :
1482+ changes += ((r'\Lib\idlelib' , r'\lib-python\3\idlelib' ),)
1483+
1484+
14431485 self .create_batch_script (
14441486 'readme.txt' ,
14451487 r"""These batch files are required to run WinPython icons.
@@ -1498,6 +1540,7 @@ def _create_batch_scripts(self):
14981540"%WINPYDIR%\python.exe" -c "from winpython import wppm;dist=wppm.Distribution(r'%WINPYDIR%');dist.patch_standard_packages('pip', to_movable=True)"
14991541pause
15001542 """ ,
1543+ do_changes = changes ,
15011544 )
15021545
15031546 self .create_batch_script (
@@ -1509,6 +1552,7 @@ def _create_batch_scripts(self):
15091552"%WINPYDIR%\python.exe" -c "from winpython import wppm;dist=wppm.Distribution(r'%WINPYDIR%');dist.patch_standard_packages('pip', to_movable=False)"
15101553pause
15111554 """ ,
1555+ do_changes = changes ,
15121556 )
15131557
15141558 self .create_batch_script (
@@ -1588,6 +1632,7 @@ def _create_batch_scripts(self):
15881632if not "%WINPYWORKDIR%"=="%WINPYWORKDIR1%" cd %WINPYWORKDIR1%
15891633"%WINPYDIR%\python.exe" %*
15901634""" ,
1635+ do_changes = changes ,
15911636 )
15921637
15931638 self .create_batch_script (
@@ -1602,6 +1647,7 @@ def _create_batch_scripts(self):
16021647 "%WINPYDIR%\python.exe" %*
16031648)
16041649""" ,
1650+ do_changes = changes ,
16051651 )
16061652
16071653 self .create_batch_script (
@@ -1615,6 +1661,7 @@ def _create_batch_scripts(self):
16151661 "%WINPYDIR%\python.exe" "%WINPYDIR%\Lib\idlelib\idle.pyw" %*
16161662)
16171663""" ,
1664+ do_changes = changes ,
16181665 )
16191666
16201667 self .create_batch_script (
@@ -1624,6 +1671,7 @@ def _create_batch_scripts(self):
16241671"%WINPYDIR%\python.exe" "%WINPYDIR%\Lib\idlelib\idle.pyw" %*
16251672
16261673""" ,
1674+ do_changes = changes ,
16271675 )
16281676 self .create_batch_script (
16291677 'winidlex.bat' ,
@@ -1638,6 +1686,7 @@ def _create_batch_scripts(self):
16381686 "%WINPYDIR%\python.exe" "%WINPYDIR%\Lib\idlelib\idle.pyw" %*
16391687)
16401688""" ,
1689+ do_changes = changes ,
16411690 )
16421691 self .create_batch_script (
16431692 'winidle.bat' ,
@@ -1646,6 +1695,7 @@ def _create_batch_scripts(self):
16461695cd/D "%WINPYWORKDIR1%"
16471696"%WINPYDIR%\python.exe" "%WINPYDIR%\Lib\idlelib\idle.pyw" %*
16481697""" ,
1698+ do_changes = changes ,
16491699 )
16501700
16511701 self .create_batch_script (
@@ -1753,6 +1803,7 @@ def _create_batch_scripts(self):
17531803 "%WINPYDIR%\python.exe" "%WINPYDIR%\Lib\site-packages\PySide2\examples\datavisualization\bars3d.py"
17541804)
17551805""" ,
1806+ do_changes = changes ,
17561807 )
17571808
17581809 self .create_batch_script (
@@ -1854,6 +1905,7 @@ def _create_batch_scripts(self):
18541905cd/D "%WINPYWORKDIR1%"
18551906"%WINPYDIR%\python.exe" -m winpython.controlpanel %*
18561907""" ,
1908+ do_changes = changes ,
18571909 )
18581910
18591911 # self.create_python_batch('wpcp.bat', '-m winpython.controlpanel',
@@ -1869,6 +1921,7 @@ def _create_batch_scripts(self):
18691921"%WINPYDIR%\python.exe" -c "from winpython import wppm;dist=wppm.Distribution(r'%WINPYDIR%');dist.patch_standard_packages('pip', to_movable=True)
18701922pause
18711923""" ,
1924+ do_changes = changes ,
18721925 )
18731926
18741927 self .create_batch_script (
@@ -2018,7 +2071,7 @@ def make(
20182071 self ._print_done ()
20192072
20202073 if remove_existing and not self .simulation :
2021- self ._extract_python ()
2074+ self ._extract_python () # unzip Python interpreter
20222075 self .distribution = wppm .Distribution (
20232076 self .python_dir ,
20242077 verbose = self .verbose ,
@@ -2033,6 +2086,11 @@ def make(
20332086 # always create all launchers (as long as it is NSIS-based)
20342087 self ._create_launchers ()
20352088 # pre-patch current pip (until default python has pip 8.0.3)
2089+
2090+ # PyPY must ensure pip
2091+ # "pypy3.exe -m ensurepip"
2092+ utils .python_execmodule ('ensurepip' , self .distribution .target )
2093+
20362094 self .distribution .patch_standard_packages ('pip' )
20372095 # not forced update of pip (FIRST) and setuptools here
20382096 for req in ('pip' , 'setuptools' , 'wheel' , 'winpython' ):
@@ -2180,7 +2238,8 @@ def make_all(
21802238 ), "The *basedir* directory must be specified"
21812239 assert architecture in (32 , 64 )
21822240 utils .print_box (
2183- "Making WinPython %dbits" % architecture
2241+ "Making WinPython %dbits at %s" % (architecture ,
2242+ osp .join (basedir , 'bu' + flavor ))
21842243 )
21852244
21862245 # Create Build director, where Winpython will be constructed
0 commit comments