Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 73 additions & 22 deletions make.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def __init__(self, build_number, release_level, target, instdir,
@property
def package_index_wiki(self):
"""Return Package Index page in Wiki format"""
installed_tools = [('gettext', '0.14.4'), ('SciTE', '3.3.7')]
installed_tools = [('gettext', '0.14.4'), ('SciTE', '3.3.7')]

def get_tool_path(relpath, checkfunc):
if self.simulation:
Expand Down Expand Up @@ -228,7 +228,7 @@ def winpy_arch(self):
def pyqt_arch(self):
"""Return distribution architecture, in PyQt format: x32/x64"""
return 'x%d' % self.distribution.architecture

@property
def py_arch(self):
"""Return distribution architecture, in Python distutils format:
Expand Down Expand Up @@ -297,7 +297,7 @@ def create_batch_script(self, name, contents):
fd = open(osp.join(scriptdir, name), 'w')
fd.write(contents)
fd.close()

def create_launcher(self, name, icon, command=None,
args=None, workdir=None, settingspath=None):
"""Create exe launcher with NSIS"""
Expand Down Expand Up @@ -453,7 +453,7 @@ def _install_required_packages(self):
'PyQwt-([0-9\.]*)-py%s-%s-([a-z0-9\.\-]*).exe'
% (self.python_version, self.pyqt_arch))

# Install 'main packages' first (was before Wheel idea, keep for now)
# Install 'main packages' first (was before Wheel idea, keep for now)
for happy_few in['numpy-MKL', 'scipy', 'matplotlib', 'pandas']:
self.install_package(
'%s-([0-9\.]*[a-z]*[0-9]?).%s(-py%s)?.exe'
Expand Down Expand Up @@ -636,38 +636,88 @@ def _create_batch_scripts(self):
cmd.exe /k
""")


self.create_batch_script('Add_or_removeLine.vbs',r"""
'from http://blogs.technet.com/b/heyscriptingguy/archive/2007/09/07/
' how-can-i-remove-any-line-in-a-text-file-that-contains-a-specified-string-value.aspx
If WScript.Arguments.Count <> 3 then
WScript.Echo "usage: Add_or_removeLine.vbs filename word_to_find line_to_add" &_
vbNewLine & "or Add_or_removeLine.vbs filename word_to_find -remove"
WScript.Quit
end If

Set colArgs = WScript.Arguments
Add_or_removeLine colArgs(0), colArgs(1), colArgs(2)

function Add_or_removeLine(strFilename, strFind, strAction)
Set inputFile = CreateObject("Scripting.FileSystemObject").OpenTextFile(strFilename, 1)
a_change = False
Do Until inputFile.AtEndOfStream
strLine = inputFile.ReadLine
If InStr(strLine, strFind) = 0 Then
result_text= result_text & strLine & vbNewLine
else
a_change = True
if strAction <> "-remove" then result_text= result_text & strLine & vbNewLine & strAction & vbNewLine
End If
Loop
inputFile.Close

if a_change then
Set outputFile = CreateObject("Scripting.FileSystemObject").OpenTextFile(strFilename,2,true)
outputFile.Write result_text
outputFile.Close
end if
end function
""")

self.create_batch_script('start_with_r.bat', r"""@echo off
call %~dp0env.bat

rem ******************
rem R part (supposing you install it in \tools\R of winpython)
rem ******************
set tmp_Rdirectory=R
if not exist "%WINPYDIR%\..\tools\%tmp_Rdirectory%\bin" goto r_end
if not exist "%WINPYDIR%\..\tools\%tmp_Rdirectory%\bin" goto r_bad

rem R_HOME for rpy2, R_HOMEBIN for PATH
set R_HOME=%WINPYDIR%\..\tools\%tmp_Rdirectory%\
set R_HOMEbin=%WINPYDIR%\..\tools\%tmp_Rdirectory%\bin


set SYS_PATH=%PATH%
set PATH=%SYS_PATH%;%R_HOMEbin%

echo "r!"
echo "if you want it to be on your winpython icon, update %WINPYDIR%\settings\winpython.ini with"
echo "PATH=%path%"
echo " "
echo to launch Ipython with R, type now "Ipython notebook"
rem Ipython notebook
echo "We are going to update %WINPYDIR%\settings\winpython.ini with"
echo "R_HOME = %R_HOME%"
echo "(relaunch this batch, if you move your winpython)"
pause

:r_end
%~dp0Add_or_removeLine.vbs ..\settings\winpython.ini "R_HOME = " -remove

cmd.exe /k
rem Handle case when winpython.ini is not already created
if exist "..\settings\winpython.ini" goto ini_exists

echo [debug]>"..\settings\winpython.ini"
echo state = disabled>>"..\settings\winpython.ini"
echo [environment]>>"..\settings\winpython.ini"

:ini_exists
%~dp0Add_or_removeLine.vbs ..\settings\winpython.ini "[environment]" "R_HOME = %R_HOME%"
goto r_end

:r_bad

echo directory "%WINPYDIR%\..\tools\%tmp_Rdirectory%\bin" not found
echo please install R at "%WINPYDIR%\..\tools\%tmp_Rdirectory%"
pause

:r_end
""")
# Prepare a live patch on python (shame we need it) to have mingw64ok
patch_distutils = ""
if self.py_arch == "win-amd64":
patch_distutils=r"""
patch_distutils = r"""
%~dp0Find_And_replace.vbs "%WINPYDIR%\Lib\distutils\cygwinccompiler.py" "-O -W" "-O -DMS_WIN64 -W"

set WINPYXX=%WINPYVER:~0,1%%WINPYVER:~2,1%
Expand All @@ -690,8 +740,9 @@ def _create_batch_scripts(self):
..\tools\mingw32\bin\dlltool -D python%WINPYXX%.dll -d python%WINPYXX%.def -l libpython%WINPYXX%.dll.a
move /Y libpython%WINPYXX%.dll.a libs
del python%WINPYXX%.def
"""
self.create_batch_script('Find_And_replace.vbs',r"""
"""

self.create_batch_script('Find_And_replace.vbs', r"""
' from http://stackoverflow.com/questions/15291341/
' a-batch-file-to-read-a-file-and-replace-a-string-with-a-new-one

Expand All @@ -714,7 +765,7 @@ def _create_batch_scripts(self):
outputFile.Write result_text
outputFile.Close
Set outputFile = Nothing
end if
end if
end function
""")

Expand Down Expand Up @@ -777,9 +828,9 @@ def _create_batch_scripts(self):
workdir=r'Lib\site-packages\PyQt4\examples\demos\qtdemo')

# pre-run wingw batch
print ('now pre-running extra mingw')
print('now pre-running extra mingw')
filepath = osp.join(self.winpydir, 'scripts', 'make_cython_use_mingw.bat')
p = subprocess.Popen(filepath, shell=True, stdout = subprocess.PIPE)
p = subprocess.Popen(filepath, shell=True, stdout=subprocess.PIPE)
stdout, stderr = p.communicate()

self._print_done()
Expand Down Expand Up @@ -837,12 +888,12 @@ def make(self, remove_existing=True):
if not self.simulation:
self._create_launchers()
self._create_batch_scripts()

if remove_existing and not self.simulation:
self._print("Cleaning up distribution")
self.distribution.clean_up()
self._print_done()

# Writing package index
self._print("Writing package index")
fname = osp.join(self.winpydir, os.pardir,
Expand Down Expand Up @@ -946,7 +997,7 @@ def make_all(build_number, release_level, pyver,

#make_all(1, '', pyver='3.4', rootdir=r'D:\Winpython',
# verbose=False, archis=(32, ))
make_all(2, '', pyver='3.4', rootdir=r'D:\Winpython',
make_all(1, '', pyver='3.4', rootdir=r'D:\Winpython',
verbose=False, archis=(64, ))
#make_all(2, '', pyver='3.3', rootdir=r'D:\Winpython',
# verbose=False, archis=(32, ))
Expand Down