Skip to content

Commit 46de661

Browse files
committed
Merge pull request #6 from stonebig/mingw64_change
set included mingw compilers as default compiler, so that cython and numba can work out of the box
2 parents 676e162 + 99847fe commit 46de661

File tree

1 file changed

+84
-27
lines changed

1 file changed

+84
-27
lines changed

make.py

Lines changed: 84 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -575,11 +575,9 @@ def _create_batch_scripts(self):
575575
set HOME=%WINPYDIR%\..\settings
576576
set PATH=""" + path)
577577

578-
self.create_batch_script('start_ijulia.bat', """@echo off
579-
set WINPYDIR=%~dp0..\\""" + self.python_name + r"""
580-
set WINPYVER=""" + self.winpyver + """
581-
set HOME=%WINPYDIR%\..\settings
582-
set PATH=""" + path + r"""
578+
self.create_batch_script('start_ijulia.bat', r"""@echo off
579+
call %~dp0env.bat
580+
583581
rem ******************
584582
rem Starting Ijulia (supposing you install it in \tools\Julia of winpython)
585583
rem ******************
@@ -638,11 +636,8 @@ def _create_batch_scripts(self):
638636
cmd.exe /k
639637
""")
640638

641-
self.create_batch_script('start_with_r.bat', """@echo off
642-
set WINPYDIR=%~dp0..\\""" + self.python_name + r"""
643-
set WINPYVER=""" + self.winpyver + """
644-
set HOME=%WINPYDIR%\..\settings
645-
set PATH=""" + path + r"""
639+
self.create_batch_script('start_with_r.bat', r"""@echo off
640+
call %~dp0env.bat
646641
647642
rem ******************
648643
rem R part (supposing you install it in \tools\R of winpython)
@@ -656,7 +651,7 @@ def _create_batch_scripts(self):
656651
657652
658653
set SYS_PATH=%PATH%
659-
set PATH=%R_HOMEbin%;%SYS_PATH%
654+
set PATH=%SYS_PATH%;%R_HOMEbin%
660655
661656
echo "r!"
662657
echo "if you want it to be on your winpython icon, update %WINPYDIR%\settings\winpython.ini with"
@@ -668,21 +663,71 @@ def _create_batch_scripts(self):
668663
:r_end
669664
670665
cmd.exe /k
666+
""")
667+
# Prepare a live patch on python (shame we need it) to have mingw64ok
668+
patch_distutils = ""
669+
if self.py_arch == "win-amd64":
670+
if sys.version_info[0] == '3':
671+
use_spec = r"\specs100"
672+
else:
673+
use_spec = r"\specs90"
674+
patch_distutils=r"""
675+
%~dp0Find_And_replace.vbs "%WINPYDIR%\Lib\distutils\cygwinccompiler.py" "-O -W" "-O -DMS_WIN64 -W"
676+
677+
set WINPYXX=%WINPYVER:~0,1%%WINPYVER:~2,1%
678+
set WINPYMSVCR=libmsvcr100.a
679+
IF "%WINPYXX%"=="27" set WINPYMSVCR=libmsvcr90.a
680+
681+
682+
cd %WINPYDIR%
683+
copy /Y ..\tools\mingw32\x86_64-w64-mingw32\lib\%WINPYMSVCR% libs\%WINPYMSVCR%
684+
copy /Y ..\tools\mingw32\lib\gcc\x86_64-w64-mingw32\4.8.2""" + use_spec + r""" ..\tools\mingw32\lib\gcc\x86_64-w64-mingw32\4.8.2\specs
685+
686+
REM generate python.34 import file
687+
688+
..\tools\mingw32\bin\gendef.exe python%WINPYXX%.dll
689+
..\tools\mingw32\bin\dlltool -D python%WINPYXX%.dll -d python%WINPYXX%.def -l libpython%WINPYXX%.dll.a
690+
move /Y libpython%WINPYXX%.dll.a libs
691+
del python%WINPYXX%.def
692+
"""
693+
self.create_batch_script('Find_And_replace.vbs',r"""
694+
' from http://stackoverflow.com/questions/15291341/
695+
' a-batch-file-to-read-a-file-and-replace-a-string-with-a-new-one
696+
697+
If WScript.Arguments.Count <> 3 then
698+
WScript.Echo "usage: Find_And_replace.vbs filename word_to_find replace_with "
699+
WScript.Quit
700+
end If
701+
702+
FindAndReplace WScript.Arguments.Item(0), WScript.Arguments.Item(1), WScript.Arguments.Item(2)
703+
'WScript.Echo "Operation Complete"
704+
705+
function FindAndReplace(strFilename, strFind, strReplace)
706+
Set inputFile = CreateObject("Scripting.FileSystemObject").OpenTextFile(strFilename, 1)
707+
strInputFile = inputFile.ReadAll
708+
inputFile.Close
709+
Set inputFile = Nothing
710+
result_text = Replace(strInputFile, strFind, strReplace)
711+
if result <> strInputFile then
712+
Set outputFile = CreateObject("Scripting.FileSystemObject").OpenTextFile(strFilename,2,true)
713+
outputFile.Write result_text
714+
outputFile.Close
715+
Set outputFile = Nothing
716+
end if
717+
end function
671718
""")
672719

673-
self.create_batch_script('make_cython_use_mingw.bat', """@echo off
674-
set WINPYDIR=%~dp0..\\""" + self.python_name + r"""
675-
set WINPYVER=""" + self.winpyver + """
676-
set HOME=%WINPYDIR%\..\settings
677-
set PATH=""" + path + r"""
720+
self.create_batch_script('make_cython_use_mingw.bat', r"""@echo off
721+
call %~dp0env.bat
678722
679723
rem ******************
680724
rem mingw part (supposing you install it in \tools\mingw32)
681725
rem ******************
682726
set tmp_mingwdirectory=mingw32
683727
if not exist "%WINPYDIR%\..\tools\%tmp_mingwdirectory%\bin" goto mingw_end
684728
685-
729+
""" + patch_distutils +
730+
r"""
686731
set pydistutils_cfg=%WINPYDIR%\..\settings\pydistutils.cfg
687732
688733
set tmp_blank=
@@ -704,10 +749,15 @@ def _create_batch_scripts(self):
704749
echo "%WINPYDIR%\..\tools\%tmp_mingwdirectory%\bin" not found
705750
706751
:mingw_success
707-
pause
752+
rem pause
708753
709754
""")
710755

756+
self.create_batch_script('make_cython_use_vc.bat', """@echo off
757+
set pydistutils_cfg=%WINPYDIR%\..\settings\pydistutils.cfg
758+
echo [config]>%pydistutils_cfg%
759+
""")
760+
711761
self.create_batch_script('cmd.bat', r"""@echo off
712762
call %~dp0env.bat
713763
cmd.exe /k""")
@@ -724,6 +774,13 @@ def _create_batch_scripts(self):
724774
self.create_python_batch('wpcp.bat', 'wpcp', workdir='Scripts')
725775
self.create_python_batch('pyqt_demo.bat', 'qtdemo.pyw',
726776
workdir=r'Lib\site-packages\PyQt4\examples\demos\qtdemo')
777+
778+
# pre-run wingw batch
779+
print ('now pre-running extra mingw')
780+
filepath = osp.join(self.winpydir, 'scripts', 'make_cython_use_mingw.bat')
781+
p = subprocess.Popen(filepath, shell=True, stdout = subprocess.PIPE)
782+
stdout, stderr = p.communicate()
783+
727784
self._print_done()
728785

729786
def make(self, remove_existing=True):
@@ -736,7 +793,7 @@ def make(self, remove_existing=True):
736793
print("WARNING: this is just a simulation!", file=sys.stderr)
737794

738795
self.python_fname = self.get_package_fname(
739-
r'python-([0-9\.]*)(\.amd64)?\.msi')
796+
r'python-([0-9\.rc]*)(\.amd64)?\.msi')
740797
self.python_name = osp.basename(self.python_fname)[:-4]
741798
distname = 'win%s' % self.python_name
742799
vlst = re.match(r'winpython-([0-9\.]*)', distname
@@ -886,15 +943,15 @@ def make_all(build_number, release_level, pyver,
886943
# DO create only what version at a time
887944
# You may have to manually delete previous build\winpython-.. directory
888945

946+
#make_all(1, '', pyver='3.4', rootdir=r'D:\Winpython',
947+
# verbose=False, archis=(32, ))
889948
make_all(2, '', pyver='3.4', rootdir=r'D:\Winpython',
890-
verbose=False, archis=(32, ))
891-
# make_all(2, '', pyver='3.4', rootdir=r'D:\Winpython',
892-
# verbose=False, archis=(64, ))
893-
# make_all(2, '', pyver='3.3', rootdir=r'D:\Winpython',
894-
# verbose=False, archis=(32, )))
895-
# make_all(2, '', pyver='3.3', rootdir=r'D:\Winpython',
949+
verbose=False, archis=(64, ))
950+
#make_all(2, '', pyver='3.3', rootdir=r'D:\Winpython',
951+
# verbose=False, archis=(32, ))
952+
#make_all(2, '', pyver='3.3', rootdir=r'D:\Winpython',
896953
# verbose=False, archis=(64, ))
897954
# make_all(2, '', pyver='2.7', rootdir=r'D:\Winpython',
898955
# verbose=False, archis=(32, ))
899-
# make_all(2, '', pyver='2.7', rootdir=r'D:\Winpython',
900-
# verbose=False, archis=(64, ))
956+
#make_all(2, '', pyver='2.7', rootdir=r'D:\Winpython',
957+
# verbose=False, archis=(64, ))

0 commit comments

Comments
 (0)