Merge branch 'winbuild' of https://github.com/wiredfool/Pillow into winbuild

This commit is contained in:
wiredfool 2014-03-31 15:49:33 -07:00
commit f26d51c320
6 changed files with 290 additions and 13 deletions

View File

@ -31,14 +31,19 @@ download and install one of them first.
::
for version in ['2.6.5', '2.7.6', '3.2.5', '3.3.5', '3.4.0']:
http://legacy.python.org/ftp/python/%s/python-%s['','.amd64'].msi['','.asc']
for platform in ['', '.amd64']:
for extension in ['','.asc']:
fetch('https://www.python.org/ftp/python/%s/python-%s%s.msi%s' %(
version, version, platform, extension))
UNDONE -- gpg verify the signatures
UNDONE -- gpg verify the signatures (note that we can download from https)
We also need virtualenv and setuptools in at least one of the pythons
to build testing versions.
Python 3.4 comes with pip. That makes it an ideal python to install
first.
Compilers
^^^^^^^^^

243
winbuild/build_dep.py Normal file
View File

@ -0,0 +1,243 @@
from fetch import fetch
from unzip import unzip
from untar import untar
import os, hashlib
libs = { 'zlib':{
'url':'http://zlib.net/zlib128.zip',
'hash': 'md5:126f8676442ffbd97884eb4d6f32afb4',
'dir': 'zlib-1.2.8',
},
'jpeg':{
'url':'http://www.ijg.org/files/jpegsr9a.zip',
'hash': 'md5:a34f3c82760270ee1e1885b15b90a72e', # not found - generated by wiredfool
'dir': 'jpeg-9a',
},
'tiff':{
'url':'ftp://ftp.remotesensing.org/pub/libtiff/tiff-4.0.3.zip',
'hash': 'md5:dd70349cedb3981371686e1c9b89a7f9', # not found - generated by wiredfool
'dir': 'tiff-4.0.3',
},
'freetype':{
'url':'http://download.savannah.gnu.org/releases/freetype/ft253.zip',
'hash': 'md5:b3858f7e69740ac04ef53366aeb172bc', # not found - generated by wiredfool
'dir': 'freetype-2.5.3',
},
'lcms':{
'url':'http://hivelocity.dl.sourceforge.net/project/lcms/lcms/2.6/lcms2-2.6.zip',
'hash': 'sha1:eea25f001246fa2e6b242ac456cecff7483cf061',
'dir': 'lcms2-2.6',
},
'tcl':{
'url':'http://hivelocity.dl.sourceforge.net/project/tcl/Tcl/8.5.13/tcl8513-src.zip',
'hash': 'sha1:3e01585c91293c532a3cd594ec59deca92153a5e',
'dir': '',
},
'tk':{
'url':'http://hivelocity.dl.sourceforge.net/project/tcl/Tcl/8.5.13/tk8513-src.zip',
'hash': 'sha1:23a1d7ddd416e11e06dfdb9f86111d4bab9420b4',
'dir': '',
},
'webp':{
'url':'https://webp.googlecode.com/files/libwebp-0.4.0.tar.gz',
'hash':'sha1:326c4b6787a01e5e32a9b30bae76442d18d2d1b6',
'dir':'libwebp-0.4.0',
},
}
compilers = [ {
'env_version':'v7.0',
'vc_version':'2008',
'env_flags': '/x64 /vista',
'inc_dir': 'msvcr90-x64',
'platform': 'x64'
},
{
'env_version':'v7.0',
'vc_version':'2008',
'env_flags': '/x86 /xp',
'inc_dir': 'msvcr90-x32',
'platform': 'Win32'
},
{
'env_version':'v7.1',
'vc_version':'2010',
'env_flags': '/x64 /vista',
'inc_dir': 'msvcr10-x64',
'platform': 'x64',
},
{
'env_version':'v7.1',
'vc_version':'2010',
'env_flags': '/x86 /xp',
'inc_dir': 'msvcr10-x32',
'platform': 'Win32',
},
]
def _relpath(*args):
return os.path.join(os.getcwd(),*args)
def _relbuild(*args):
return _relpath('build', *args)
build_dir = _relpath('build')
inc_dir = _relpath('depends')
def check_hash(filename, checksum):
if not checksum: return filename
(algo, value) = checksum.split(':')
h = hashlib.new(algo)
with open(filename, 'rb') as f:
h.update(f.read())
if not(h.hexdigest().lower() == value):
raise ValueError('Checksum Mismatch for %s' %filename)
return filename
def check_sig(filename, signame):
#UNDONE -- need gpg
return filename
def mkdirs():
try:
os.mkdir(build_dir)
except:
pass
try:
os.mkdir(inc_dir)
except:
pass
def extract(src, dest):
if '.zip' in src:
return unzip(src, dest)
if '.tar.gz' in src or '.tgz' in src:
return untar(src, dest)
def fetch_libs():
for lib in libs.values():
extract(check_hash(fetch(lib['url']),lib['hash']),build_dir)
def cp_tk():
return r"""
mkdir %INCLIB%\tcl85\include\X11
copy /Y /B %BUILD%\tcl8.5.13\generic\*.h %INCLIB%\tcl85\include\
copy /Y /B %BUILD%\tk8.5.13\generic\*.h %INCLIB%\tcl85\include\
copy /Y /B %BUILD%\tk8.5.13\xlib\X11\* %INCLIB%\tcl85\include\X11\
"""
def header():
return r"""setlocal
set MSBUILD=C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe
set CMAKE="C:\Program Files (x86)\CMake 2.8\bin\cmake.exe"
set INCLIB=%~dp0\depends
set BUILD=%~dp0\build
""" + "\n".join('set %s=%%BUILD%%\%s' %(k.upper(), v['dir'])
for (k,v) in libs.items() if v['dir'])
def setup_compiler(compiler):
return r"""setlocal EnableDelayedExpansion
call "%%ProgramFiles%%\Microsoft SDKs\Windows\%(env_version)s\Bin\SetEnv.Cmd" /Release %(env_flags)s
set INCLIB=%%INCLIB%%\%(inc_dir)s
mkdir %%INCLIB%%
""" % compiler
def end_compiler():
return """
endlocal
"""
def nmake_libs(compiler):
# undone -- pre, makes, headers, libs
return r"""
rem Build libjpeg
setlocal
cd /D %%JPEG%%
nmake -f makefile.vc setup-vc6
nmake -f makefile.vc clean
nmake -f makefile.vc all
copy /Y /B *.dll %%INCLIB%%
copy /Y /B *.lib %%INCLIB%%
copy /Y /B j*.h %%INCLIB%%
endlocal
rem Build zlib
setlocal
cd /D %%ZLIB%%
nmake -f win32\Makefile.msc clean
nmake -f win32\Makefile.msc
copy /Y /B *.dll %%INCLIB%%
copy /Y /B *.lib %%INCLIB%%
copy /Y /B zlib.lib %%INCLIB%%\z.lib
copy /Y /B zlib.h %%INCLIB%%
copy /Y /B zconf.h %%INCLIB%%
endlocal
rem Build webp
setlocal
cd /D %%WEBP%%
nmake -f Makefile.vc clean
nmake -f Makefile.vc CFG=release-static RTLIBCFG=static OBJDIR=output
copy /Y /B release-static\output\%(platform)s\* %%INCLIB%%
copy /Y /B src\webp\*.h %%INCLIB%%
endlocal
rem Build libtiff
setlocal
rem do after building jpeg and zlib
copy %%~dp0\nmake.opt %%TIFF%%
cd /D %%TIFF%%
nmake -f makefile.vc clean
nmake -f makefile.vc
copy /Y /B libtiff\*.dll %%INCLIB%%
copy /Y /B libtiff\*.lib %%INCLIB%%
copy /Y /B libtiff\tiff*.h %%INCLIB%%
endlocal
""" % compiler
def msbuild_libs(compiler):
return r"""
rem Build freetype
setlocal
py -3 %%~dp0\fixproj.py %%FREETYPE%%\builds\windows\vc%(vc_version)s\freetype.sln %(platform)s
py -3 %%~dp0\fixproj.py %%FREETYPE%%\builds\windows\vc%(vc_version)s\freetype.vcproj %(platform)s
rd /S /Q %%FREETYPE%%\objs
%%MSBUILD%% %%FREETYPE%%\builds\windows\vc%(vc_version)s\freetype.sln /t:Clean;Build /p:Configuration="LIB Release";Platform=%(platform)s
xcopy /E /Q %%FREETYPE%%\include %%INCLIB%%
xcopy /E /Q %%FREETYPE%%\objs\win32\vc%(vc_version)s %%INCLIB%%
copy /Y /B %%FREETYPE%%\objs\win32\vc%(vc_version)s\*.lib %%INCLIB%%\freetype.lib
endlocal
rem Build lcms2
setlocal
py -3 %%~dp0\fixproj.py %%LCMS%%\Projects\VC%(vc_version)s\lcms2.sln %(platform)s
py -3 %%~dp0\fixproj.py %%LCMS%%\Projects\VC%(vc_version)s\lcms2.vcproj %(platform)s
rd /S /Q %%LCMS%%\objs
%%MSBUILD%% %%LCMS%%\Projects\VC%(vc_version)s\lcms2.sln /t:Clean;Build /p:Configuration="LIB Release";Platform=%(platform)s
xcopy /E /Q %%LCMS%%\include %%INCLIB%%
xcopy /E /Q %%LCMS%%\objs\win32\VC%(vc_version)s %%INCLIB%%
copy /Y /B %%LCMS%%\objs\win32\VC%(vc_version)s\*.lib %%INCLIB%%\lcms2.lib
endlocal
""" % compiler
mkdirs()
fetch_libs()
script = [header(), cp_tk()]
for compiler in compilers:
script.append(setup_compiler(compiler))
script.append(nmake_libs(compiler))
script.append(msbuild_libs(compiler))
script.append(end_compiler())
print ("\n".join(script))

View File

@ -1,7 +1,16 @@
import sys, os, urllib.parse, urllib.request
name = urllib.parse.urlsplit(sys.argv[1])[2].split('/')[-1]
if not os.path.exists(name):
print("Fetching", sys.argv[1])
content = urllib.request.urlopen(sys.argv[1]).read()
def fetch(url):
name = urllib.parse.urlsplit(url)[2].split('/')[-1]
if not os.path.exists(name):
print("Fetching", url)
content = urllib.request.urlopen(url).read()
with open(name, 'wb') as fd:
fd.write(content)
return name
if __name__=='__main__':
fetch(sys.argv[1])

11
winbuild/get_pythons.py Normal file
View File

@ -0,0 +1,11 @@
from fetch import fetch
if __name__=='__main__':
for version in ['2.6.5', '2.7.6', '3.2.5', '3.3.5', '3.4.0']:
for platform in ['', '.amd64']:
for extension in ['','.asc']:
fetch('https://www.python.org/ftp/python/%s/python-%s%s.msi%s' %(
version, version, platform, extension))
# find pip, if it's not in the path!
os.system('pip install virtualenv')

View File

@ -1,4 +1,8 @@
import sys, tarfile
with tarfile.open(sys.argv[1], 'r:gz') as tgz:
tgz.extractall(sys.argv[2])
def untar(src, dest):
with tarfile.open(src, 'r:gz') as tgz:
tgz.extractall(dest)
if __name__=='__main__':
untar(sys.argv[1],sys.argv[2])

View File

@ -1,3 +1,8 @@
import sys, zipfile
with zipfile.ZipFile(sys.argv[1]) as zf:
zf.extractall(sys.argv[2])
def unzip(src, dest):
with zipfile.ZipFile(src) as zf:
zf.extractall(dest)
if __name__=='__main__':
unzip(sys.argv[1], sys.argv[2])