@@ -321,7 +321,7 @@ def __init__(
321
321
docsdirs = []
322
322
self ._docsdirs = docsdirs
323
323
self .verbose = verbose
324
- self .winpydir = None
324
+ self .winpydir = None # new WinPython BaseDirectory
325
325
self .distribution = None
326
326
self .installed_packages = []
327
327
self .simulation = simulation
@@ -331,20 +331,31 @@ def __init__(
331
331
self .install_options = install_options
332
332
self .flavor = flavor
333
333
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 (
335
343
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)
337
348
self .python_name = osp .basename (self .python_fname )[
338
349
:- 4
339
350
]
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])
348
359
349
360
@property
350
361
def package_index_wiki (self ):
@@ -471,7 +482,7 @@ def winpyver(self):
471
482
@property
472
483
def python_dir (self ):
473
484
"""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
475
486
476
487
@property
477
488
def winpy_arch (self ):
@@ -561,13 +572,21 @@ def get_package_fname(self, pattern):
561
572
% pattern
562
573
)
563
574
564
- def create_batch_script (self , name , contents ):
575
+ def create_batch_script (self , name , contents ,
576
+ do_changes = None ):
565
577
"""Create batch script %WINPYDIR%/name"""
566
578
scriptdir = osp .join (self .winpydir , 'scripts' )
567
579
if not osp .isdir (scriptdir ):
568
580
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
+
569
588
fd = open (osp .join (scriptdir , name ), 'w' )
570
- fd .write (contents )
589
+ fd .write (contents_final )
571
590
fd .close ()
572
591
573
592
def create_launcher (
@@ -985,6 +1004,14 @@ def _create_batch_scripts_initial(self):
985
1004
+ convps (self .postpath )
986
1005
)
987
1006
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' ),)
988
1015
self .create_batch_script (
989
1016
'env.bat' ,
990
1017
r"""@echo off
@@ -1003,7 +1030,6 @@ def _create_batch_scripts_initial(self):
1003
1030
+ r"""
1004
1031
rem 2019-08-25 pyjulia needs absolutely a variable PYTHON=%WINPYDIR%python.exe
1005
1032
set PYTHON=%WINPYDIR%\python.exe
1006
-
1007
1033
set WINPYVER="""
1008
1034
+ self .winpyver
1009
1035
+ r"""
@@ -1124,6 +1150,7 @@ def _create_batch_scripts_initial(self):
1124
1150
)>> "%winpython_ini%"
1125
1151
1126
1152
""" ,
1153
+ do_changes = changes ,
1127
1154
)
1128
1155
1129
1156
self .create_batch_script (
@@ -1303,6 +1330,7 @@ def _create_batch_scripts_initial(self):
1303
1330
$host.ui.RawUI.ForegroundColor = "White"
1304
1331
1305
1332
""" ,
1333
+ do_changes = changes ,
1306
1334
)
1307
1335
1308
1336
self .create_batch_script (
@@ -1313,6 +1341,7 @@ def _create_batch_scripts_initial(self):
1313
1341
Powershell.exe -Command "& {Start-Process PowerShell.exe -ArgumentList '-ExecutionPolicy RemoteSigned -noexit -File ""%~dp0WinPython_PS_Prompt.ps1""'}"
1314
1342
exit
1315
1343
""" ,
1344
+ do_changes = changes ,
1316
1345
)
1317
1346
1318
1347
self .create_batch_script (
@@ -1322,6 +1351,7 @@ def _create_batch_scripts_initial(self):
1322
1351
Powershell.exe -Command "& {Start-Process PowerShell.exe -ArgumentList '-ExecutionPolicy RemoteSigned -noexit -File ""%~dp0WinPython_PS_Prompt.ps1""'}"
1323
1352
exit
1324
1353
""" ,
1354
+ do_changes = changes ,
1325
1355
)
1326
1356
1327
1357
self .create_batch_script (
@@ -1369,6 +1399,7 @@ def _create_batch_scripts_initial(self):
1369
1399
if not exist "%HOME%\pydistutils.cfg" xcopy "%WINPYDIRBASE%\settings\pydistutils.cfg" "%HOME%"
1370
1400
:no_cython
1371
1401
""" ,
1402
+ do_changes = changes ,
1372
1403
)
1373
1404
1374
1405
self .create_batch_script (
@@ -1440,6 +1471,17 @@ def _create_batch_scripts_initial(self):
1440
1471
def _create_batch_scripts (self ):
1441
1472
"""Create batch scripts"""
1442
1473
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
+
1443
1485
self .create_batch_script (
1444
1486
'readme.txt' ,
1445
1487
r"""These batch files are required to run WinPython icons.
@@ -1498,6 +1540,7 @@ def _create_batch_scripts(self):
1498
1540
"%WINPYDIR%\python.exe" -c "from winpython import wppm;dist=wppm.Distribution(r'%WINPYDIR%');dist.patch_standard_packages('pip', to_movable=True)"
1499
1541
pause
1500
1542
""" ,
1543
+ do_changes = changes ,
1501
1544
)
1502
1545
1503
1546
self .create_batch_script (
@@ -1509,6 +1552,7 @@ def _create_batch_scripts(self):
1509
1552
"%WINPYDIR%\python.exe" -c "from winpython import wppm;dist=wppm.Distribution(r'%WINPYDIR%');dist.patch_standard_packages('pip', to_movable=False)"
1510
1553
pause
1511
1554
""" ,
1555
+ do_changes = changes ,
1512
1556
)
1513
1557
1514
1558
self .create_batch_script (
@@ -1588,6 +1632,7 @@ def _create_batch_scripts(self):
1588
1632
if not "%WINPYWORKDIR%"=="%WINPYWORKDIR1%" cd %WINPYWORKDIR1%
1589
1633
"%WINPYDIR%\python.exe" %*
1590
1634
""" ,
1635
+ do_changes = changes ,
1591
1636
)
1592
1637
1593
1638
self .create_batch_script (
@@ -1602,6 +1647,7 @@ def _create_batch_scripts(self):
1602
1647
"%WINPYDIR%\python.exe" %*
1603
1648
)
1604
1649
""" ,
1650
+ do_changes = changes ,
1605
1651
)
1606
1652
1607
1653
self .create_batch_script (
@@ -1615,6 +1661,7 @@ def _create_batch_scripts(self):
1615
1661
"%WINPYDIR%\python.exe" "%WINPYDIR%\Lib\idlelib\idle.pyw" %*
1616
1662
)
1617
1663
""" ,
1664
+ do_changes = changes ,
1618
1665
)
1619
1666
1620
1667
self .create_batch_script (
@@ -1624,6 +1671,7 @@ def _create_batch_scripts(self):
1624
1671
"%WINPYDIR%\python.exe" "%WINPYDIR%\Lib\idlelib\idle.pyw" %*
1625
1672
1626
1673
""" ,
1674
+ do_changes = changes ,
1627
1675
)
1628
1676
self .create_batch_script (
1629
1677
'winidlex.bat' ,
@@ -1638,6 +1686,7 @@ def _create_batch_scripts(self):
1638
1686
"%WINPYDIR%\python.exe" "%WINPYDIR%\Lib\idlelib\idle.pyw" %*
1639
1687
)
1640
1688
""" ,
1689
+ do_changes = changes ,
1641
1690
)
1642
1691
self .create_batch_script (
1643
1692
'winidle.bat' ,
@@ -1646,6 +1695,7 @@ def _create_batch_scripts(self):
1646
1695
cd/D "%WINPYWORKDIR1%"
1647
1696
"%WINPYDIR%\python.exe" "%WINPYDIR%\Lib\idlelib\idle.pyw" %*
1648
1697
""" ,
1698
+ do_changes = changes ,
1649
1699
)
1650
1700
1651
1701
self .create_batch_script (
@@ -1753,6 +1803,7 @@ def _create_batch_scripts(self):
1753
1803
"%WINPYDIR%\python.exe" "%WINPYDIR%\Lib\site-packages\PySide2\examples\datavisualization\bars3d.py"
1754
1804
)
1755
1805
""" ,
1806
+ do_changes = changes ,
1756
1807
)
1757
1808
1758
1809
self .create_batch_script (
@@ -1854,6 +1905,7 @@ def _create_batch_scripts(self):
1854
1905
cd/D "%WINPYWORKDIR1%"
1855
1906
"%WINPYDIR%\python.exe" -m winpython.controlpanel %*
1856
1907
""" ,
1908
+ do_changes = changes ,
1857
1909
)
1858
1910
1859
1911
# self.create_python_batch('wpcp.bat', '-m winpython.controlpanel',
@@ -1869,6 +1921,7 @@ def _create_batch_scripts(self):
1869
1921
"%WINPYDIR%\python.exe" -c "from winpython import wppm;dist=wppm.Distribution(r'%WINPYDIR%');dist.patch_standard_packages('pip', to_movable=True)
1870
1922
pause
1871
1923
""" ,
1924
+ do_changes = changes ,
1872
1925
)
1873
1926
1874
1927
self .create_batch_script (
@@ -2018,7 +2071,7 @@ def make(
2018
2071
self ._print_done ()
2019
2072
2020
2073
if remove_existing and not self .simulation :
2021
- self ._extract_python ()
2074
+ self ._extract_python () # unzip Python interpreter
2022
2075
self .distribution = wppm .Distribution (
2023
2076
self .python_dir ,
2024
2077
verbose = self .verbose ,
@@ -2033,6 +2086,11 @@ def make(
2033
2086
# always create all launchers (as long as it is NSIS-based)
2034
2087
self ._create_launchers ()
2035
2088
# 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
+
2036
2094
self .distribution .patch_standard_packages ('pip' )
2037
2095
# not forced update of pip (FIRST) and setuptools here
2038
2096
for req in ('pip' , 'setuptools' , 'wheel' , 'winpython' ):
@@ -2180,7 +2238,8 @@ def make_all(
2180
2238
), "The *basedir* directory must be specified"
2181
2239
assert architecture in (32 , 64 )
2182
2240
utils .print_box (
2183
- "Making WinPython %dbits" % architecture
2241
+ "Making WinPython %dbits at %s" % (architecture ,
2242
+ osp .join (basedir , 'bu' + flavor ))
2184
2243
)
2185
2244
2186
2245
# Create Build director, where Winpython will be constructed
0 commit comments