Merge pull request #1278 from wiredfool/winbuild

Windows Build/CI
This commit is contained in:
wiredfool 2015-06-18 09:03:38 -07:00
commit a92d737177
19 changed files with 1051 additions and 4 deletions

View File

@ -74,7 +74,6 @@ recursive-include docs *.txt
recursive-include docs BUILDME
recursive-include docs COPYING
recursive-include docs Guardfile
recursive-include docs LICENSE
recursive-include docs Makefile
recursive-include libImaging *.c
recursive-include libImaging *.h

View File

@ -233,6 +233,8 @@ def netpbm_available():
def imagemagick_available():
return IMCONVERT and command_succeeds([IMCONVERT, '-version'])
def on_appveyor():
return 'APPVEYOR' in os.environ
if sys.platform == 'win32':
IMCONVERT = os.environ.get('MAGICK_HOME', '')

View File

@ -1,4 +1,4 @@
from helper import unittest, PillowTestCase
from helper import unittest, PillowTestCase, on_appveyor
import sys
@ -7,10 +7,12 @@ try:
class TestImageGrab(PillowTestCase):
@unittest.skipIf(on_appveyor(), "Test fails on appveyor")
def test_grab(self):
im = ImageGrab.grab()
self.assert_image(im, im.mode, im.size)
@unittest.skipIf(on_appveyor(), "Test fails on appveyor")
def test_grab2(self):
im = ImageGrab.grab()
self.assert_image(im, im.mode, im.size)

30
appveyor.yml Normal file
View File

@ -0,0 +1,30 @@
version: 2.9.pre.{build}
branches:
only:
- winbuild
shallow_clone: true
clone_folder: c:\pillow
init:
- ECHO %PYTHON%
environment:
X64_EXT: -x64
matrix:
- PYTHON: C:/Python27-x64
- PYTHON: C:/Python34
- PYTHON: C:/Python27
- PYTHON: C:/Python34-x64
install:
- git clone https://github.com/wiredfool/pillow-depends.git c:\pillow-depends
- xcopy c:\pillow-depends\*.zip c:\pillow\winbuild\
- xcopy c:\pillow-depends\*.tar.gz c:\pillow\winbuild\
- cd c:\pillow\winbuild\
- c:\python34\python.exe c:\pillow\winbuild\build_dep.py
- c:\pillow\winbuild\build_deps.cmd
build_script:
- '%PYTHON%\python.exe c:\pillow\winbuild\build.py'
- cd c:\pillow
- '%PYTHON%\python.exe selftest.py --installed'
test_script:
- cd c:\pillow
- '%PYTHON%\Scripts\pip.exe install nose'
- '%PYTHON%\python.exe test-installed.py'

94
docs/build.rst Normal file
View File

@ -0,0 +1,94 @@
Building Pillow on Windows
==========================
.. note:: For most people, the :doc:`installation instructions
<installation>` should be sufficient
This page will describe a build setup to build Pillow against the
supported python versions in 32 and 64-bit modes, using freely
available Microsoft compilers. This has been developed and tested
against 64-bit Windows 7 Professional and Windows Server 2012
64-bit version on Amazon EC2.
Prerequisites
------------
Extra Build Helpers
^^^^^^^^^^^^^^^^^^^
* Powershell (available by default on Windows Server)
* GitHub client (provides git+bash shell)
Optional:
* GPG (for checking signatures) (UNDONE -- Python signature checking)
Pythons
^^^^^^^
The build routines expect Python to be installed at C:\PythonXX for
32-bit versions or C:\PythonXXx64 for the 64-bit versions.
Download Python 3.4, install it, and add it to the path. This is the
Python that we will use to bootstrap the build process. (The download
routines are using 3.2+ features, and installing 3.4 gives us pip and
virtualenv as well, reducing the number of packages that we need to
install.)
Download the rest of the Pythons by opening a command window, changing
to the `winbuild` directory, and running `python
get_pythons.py`.
UNDONE -- gpg verify the signatures (note that we can download from
https)
Run each installer and set the proper path to the installation. Don't
set any of them as the default Python, or add them to the path.
Compilers
^^^^^^^^^
Download and install:
* `Microsoft Windows SDK for Windows 7 and .NET Framework 3.5
SP1 <http://www.microsoft.com/en-us/download/details.aspx?id=3138>`_
* `Microsoft Windows SDK for Windows 7 and .NET Framework
4 <http://www.microsoft.com/en-us/download/details.aspx?id=8279>`_
* `CMake-2.8.10.2-win32-x86.exe <http://www.cmake.org/cmake/resources/software.html>`_
The samples and the .NET SDK portions aren't required, just the
compilers and other tools. UNDONE -- check exact wording.
Dependencies
------------
The script 'build_dep.py' downloads and builds the dependencies. Open
a command window, change directory into `winbuild` and run `python
build_dep.py`.
This will download libjpeg, libtiff, libz, and freetype. It will then
compile 32 and 64-bit versions of the libraries, with both versions of
the compilers.
UNDONE -- lcms fails.
UNDONE -- webp, jpeg2k not recognized
Building Pillow
---------------
Once the dependencies are built, run `python build.py --clean` to
build and install Pillow in virtualenvs for each python
build. `build.py --dist` will build Windows installers instead of
installing into virtualenvs.
UNDONE -- suppressed output, what about failures.
Testing Pillow
--------------
Build and install Pillow, then run `python test.py` from the
`winbuild` directory.

View File

@ -13,6 +13,12 @@
#include <tiff.h>
#endif
/* UNDONE -- what are we using from this? */
/*#ifndef _UNISTD_H
# include <unistd.h>
# endif
*/
#ifndef min
#define min(x,y) (( x > y ) ? y : x )
#define max(x,y) (( x < y ) ? y : x )

View File

@ -462,7 +462,10 @@ class pil_build_ext(build_ext):
if feature.want('lcms'):
if _find_include_file(self, "lcms2.h"):
if _find_library_file(self, "lcms2"):
feature.lcms = "lcms"
feature.lcms = "lcms2"
elif _find_library_file(self, "lcms2_static"):
#alternate Windows name.
feature.lcms = "lcms2_static"
if _tkinter and _find_include_file(self, "tk.h"):
# the library names may vary somewhat (e.g. tcl84 or tcl8.4)
@ -554,7 +557,7 @@ class pil_build_ext(build_ext):
exts.append(Extension(
"PIL._imagingcms",
["_imagingcms.c"],
libraries=["lcms2"] + extra))
libraries=[feature.lcms] + extra))
if os.path.isfile("_webp.c") and feature.webp:
libs = [feature.webp]
@ -755,3 +758,4 @@ setup(
zip_safe=not debug_build(),
)
# End of file

6
winbuild/.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
*.zip
*.tar.gz
*.msi
*.asc
__pycache__
depends/

18
winbuild/README.md Normal file
View File

@ -0,0 +1,18 @@
Quick README
------------
For more extensive info, see the windows build instructions `docs/build.rst`.
* See https://github.com/python-imaging/Pillow/issues/553#issuecomment-37877416 and https://github.com/matplotlib/matplotlib/issues/1717#issuecomment-13343859
* Works best with Python 3.4, due to virtualenv and pip batteries included. Python3+ required for fetch command.
* Check config.py for virtual env paths, suffix for 64 bit releases. Defaults to `x64`, set `X64_EXT` to change.
* When running in CI with one python per invocation, set the `PYTHON` env variable to the python folder. (e.g. `PYTHON`=`c:\Python27\`) This overrides the matrix in config.py and will just build and test for the speciic python.
* `python get_pythons.py` downloads all the python releases, and their signatures. (Manually) Install in `c:\PythonXX[x64]\`.
* `python build_dep.py` downloads and creates a build script for all the dependencies, in 32 and 64 bit versions, and with both compiler versions.
* (in powershell) `build_deps.cmd` invokes the dependency build.
* `python build.py --clean` makes pillow for the matrix of pythons.
* `python test.py` runs the tests on pillow in all the virtual envs.
* Currently working with zlib, libjpeg, freetype, and libtiff on Python 2.7, 3.3, and 3.4, both 32 and 64 bit, on a local win7 pro machine and appveyor.com (3.3 untested there)
* Webp is built, not detected.
* LCMS and OpenJpeg are not building.

144
winbuild/build.py Normal file
View File

@ -0,0 +1,144 @@
#/usr/bin/env python3
import subprocess, multiprocessing
import shutil
import sys, getopt
import os
from config import *
def setup_vms():
ret = []
for py in pythons.keys():
for arch in ('', X64_EXT):
ret.append("virtualenv -p c:/Python%s%s/python.exe --clear %s%s%s" %
(py, arch, VIRT_BASE, py, arch))
ret.append("%s%s%s\Scripts\pip.exe install nose" %
(VIRT_BASE, py, arch))
if py == '26':
ret.append("%s%s%s\Scripts\pip.exe install unittest2" %
(VIRT_BASE, py, arch))
return "\n".join(ret)
def run_script(params):
(version, script) = params
try:
print ("Running %s" %version)
filename = 'build_pillow_%s.cmd' % version
with open(filename, 'w') as f:
f.write(script)
command = ['powershell', "./%s" %filename]
proc = subprocess.Popen(command,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
(trace, stderr) = proc.communicate()
status = proc.returncode
print (stderr)
print ("Done with %s: %s" % (version, status))
return (version, status, trace, stderr)
except Exception as msg:
print ("Error with %s: %s" % (version, str(msg)))
return (version, -1, "", str(msg))
def header(op):
return r"""
setlocal
set MPLSRC=%%~dp0\..
set INCLIB=%%~dp0\depends
set BLDOPT=%s
cd /D %%MPLSRC%%
""" % (op)
def footer():
return """endlocal
exit
"""
def build_one(py_ver, compiler):
# UNDONE virtual envs if we're not running on appveyor
args = {}
args.update(compiler)
if 'PYTHON' in os.environ:
args['python_path'] = "%PYTHON%"
else:
args['python_path'] = "%s%s\\Scripts" % (VIRT_BASE, py_ver)
args['py_ver'] = py_ver
return r"""
setlocal EnableDelayedExpansion
call "%%ProgramFiles%%\Microsoft SDKs\Windows\%(env_version)s\Bin\SetEnv.Cmd" /Release %(env_flags)s
set DISTUTILS_USE_SDK=1
set LIB=%%LIB%%;%%INCLIB%%\%(inc_dir)s
set INCLUDE=%%INCLUDE%%;%%INCLIB%%\%(inc_dir)s;%%INCLIB%%\tcl85\include
setlocal
set LIB=%%LIB%%;C:\Python%(py_ver)s\tcl
call %(python_path)s\python.exe setup.py %%BLDOPT%%
endlocal
endlocal
""" % args
def clean():
try:
shutil.rmtree('../build')
except:
# could already be removed
pass
run_script(('virtualenvs', setup_vms()))
def main(op):
scripts = []
for py_version, compiler_version in pythons.items():
scripts.append((py_version,
"\n".join([header(op),
build_one(py_version,
compilers[(compiler_version, 32)]),
footer()])))
scripts.append(("%s%s" % (py_version, X64_EXT),
"\n".join([header(op),
build_one("%sx64" %py_version,
compilers[(compiler_version, 64)]),
footer()])))
pool = multiprocessing.Pool()
results = pool.map(run_script, scripts)
for (version, status, trace, err) in results:
print ("Compiled %s: %s" % (version, status))
def run_one(op):
compiler = compiler_fromEnv()
py_version = pyversion_fromEnv()
run_script((py_version,
"\n".join([header(op),
build_one(py_version, compiler),
footer()])
))
if __name__=='__main__':
opts, args = getopt.getopt(sys.argv[1:], '', ['clean', 'dist'])
opts = dict(opts)
if '--clean' in opts:
clean()
op = 'install'
if '--dist' in opts:
op = "bdist_wininst --user-access-control=auto"
if 'PYTHON' in os.environ:
run_one(op)
else:
main(op)

286
winbuild/build_dep.py Normal file
View File

@ -0,0 +1,286 @@
from fetch import fetch
from unzip import unzip
from untar import untar
import os, hashlib
import shutil
from config import *
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
for compiler in compilers.values():
try:
os.mkdir(os.path.join(inc_dir, compiler['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 name,lib in libs.items():
if name == 'openjpeg':
filename = check_hash(fetch(lib['url']),lib['hash'])
for compiler in compilers.values():
if not os.path.exists(os.path.join(build_dir,lib['dir']+compiler['inc_dir'])):
extract(filename, build_dir)
os.rename(os.path.join(build_dir,lib['dir']),
os.path.join(build_dir,lib['dir']+compiler['inc_dir']))
else:
extract(check_hash(fetch(lib['url']),lib['hash']),build_dir)
def extract_binlib():
lib = bin_libs['openjpeg']
extract(lib['filename'], build_dir)
return
base = os.path.splitext(lib['filename'])[0]
for compiler in compilers.values():
shutil.copy(os.path.join(inc_dir, base, 'include', 'openjpeg-%s' % lib['version']),
os.path.join(inc_dir, compiler['inc_dir']))
shutil.copy(os.path.join(inc_dir, base, 'bin', 'openjp2.dll'),
os.path.join(inc_dir, compiler['inc_dir']))
shutil.copy(os.path.join(inc_dir, base, 'lib', 'openjp2.lib'),
os.path.join(inc_dir, compiler['inc_dir']))
def extract_openjpeg(compiler):
return r"""
rem build openjpeg
setlocal
@echo on
cd %%BUILD%%
mkdir %%INCLIB%%\openjpeg-2.0
copy /Y /B openjpeg-2.0.0-win32-x86\include\openjpeg-2.0 %%INCLIB%%\openjpeg-2.0
copy /Y /B openjpeg-2.0.0-win32-x86\bin\ %%INCLIB%%
copy /Y /B openjpeg-2.0.0-win32-x86\lib\ %%INCLIB%%
endlocal
""" % compiler
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="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
""" % compiler
def end_compiler():
return """
endlocal
"""
def nmake_openjpeg(compiler):
atts = {'op_ver': '2.1'}
atts.update(compiler)
return r"""
rem build openjpeg
setlocal
@echo on
cd /D %%OPENJPEG%%%(inc_dir)s
%%CMAKE%% -DBUILD_THIRDPARTY:BOOL=OFF -G "NMake Makefiles" .
nmake -f Makefile clean
nmake -f Makefile
copy /Y /B bin\* %%INCLIB%%
mkdir %%INCLIB%%\openjpeg-%(op_ver)s
copy /Y /B src\lib\openjp2\*.h %%INCLIB%%\openjpeg-%(op_ver)s
endlocal
""" % atts
def msbuild_openjpeg(compiler):
atts = {'op_ver': '2.1'}
atts.update(compiler)
return r"""
rem build openjpeg
setlocal
@echo on
cd /D %%OPENJPEG%%%(inc_dir)s
%%CMAKE%% -DBUILD_THIRDPARTY:BOOL=OFF -G "NMake Makefiles" .
nmake -f Makefile clean
nmake -f Makefile
copy /Y /B bin\* %%INCLIB%%
mkdir %%INCLIB%%\openjpeg-%(op_ver)s
copy /Y /B src\lib\openjp2\*.h %%INCLIB%%\openjpeg-%(op_ver)s
endlocal
""" % atts
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 libjpeg.lib
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 zlib.lib
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%%
rd /S /Q %%WEBP%%\output\release-static
nmake -f Makefile.vc CFG=release-static RTLIBCFG=static OBJDIR=output all
copy /Y /B output\release-static\%(platform)s\lib\* %%INCLIB%%
mkdir %%INCLIB%%\webp
copy /Y /B src\webp\*.h %%INCLIB%%\\webp
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 lib
copy /Y /B libtiff\*.dll %%INCLIB%%
copy /Y /B libtiff\*.lib %%INCLIB%%
copy /Y /B libtiff\tiff*.h %%INCLIB%%
endlocal
""" % compiler
def msbuild_freetype(compiler):
if compiler['env_version'] == 'v7.1':
return msbuild_freetype_71(compiler)
return msbuild_freetype_70(compiler)
def msbuild_freetype_71(compiler):
return r"""
rem Build freetype
setlocal
rd /S /Q %%FREETYPE%%\objs
%%MSBUILD%% %%FREETYPE%%\builds\windows\vc%(vc_version)s\freetype.sln /t:Clean;Build /p:Configuration="Release" /p:Platform=%(platform)s /m
xcopy /Y /E /Q %%FREETYPE%%\include %%INCLIB%%
copy /Y /B %%FREETYPE%%\objs\vc%(vc_version)s\%(platform)s\*.lib %%INCLIB%%\freetype.lib
endlocal
""" %compiler
def msbuild_freetype_70(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 /m
xcopy /Y /E /Q %%FREETYPE%%\include %%INCLIB%%
xcopy /Y /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
""" %compiler
def build_lcms2(compiler):
return r"""
rem Build lcms2
setlocal
rd /S /Q %%LCMS%%\Lib
rd /S /Q %%LCMS%%\Projects\VC%(vc_version)s\Release
%%MSBUILD%% %%LCMS%%\Projects\VC%(vc_version)s\lcms2.sln /t:Clean /p:Configuration="Release" /p:Platform=%(platform)s /m
%%MSBUILD%% %%LCMS%%\Projects\VC%(vc_version)s\lcms2.sln /t:lcms2_static /p:Configuration="Release" /p:Platform=%(platform)s /m
xcopy /Y /E /Q %%LCMS%%\include %%INCLIB%%
copy /Y /B %%LCMS%%\Projects\VC%(vc_version)s\Release\*.lib %%INCLIB%%
copy /Y /B %%LCMS%%\Lib\MS\*.lib %%INCLIB%%
endlocal
""" % compiler
def add_compiler(compiler):
script.append(setup_compiler(compiler))
script.append(nmake_libs(compiler))
#script.append(extract_openjpeg(compiler))
script.append(msbuild_freetype(compiler))
#script.append(build_lcms2(compiler))
#script.append(nmake_openjpeg(compiler))
script.append(end_compiler())
mkdirs()
fetch_libs()
#extract_binlib()
script = [header()] #, cp_tk()]
if 'PYTHON' in os.environ:
add_compiler(compiler_fromEnv())
else:
for compiler in compilers.values():
add_compiler(compiler)
#add_compiler(compilers[(7,32)])
with open('build_deps.cmd', 'w') as f:
f.write("\n".join(script))

142
winbuild/config.py Normal file
View File

@ -0,0 +1,142 @@
import os
SF_MIRROR = 'http://hivelocity.dl.sourceforge.net'
SF_MIRROR = 'http://iweb.dl.sourceforge.net'
pythons = {#'26':7,
'27':7,
#'32':7,
'33':7.1,
'34':7.1}
VIRT_BASE = "c:/vp/"
X64_EXT = os.environ.get('X64_EXT',"x64")
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',
# },
'freetype':{
'url': 'http://download.savannah.gnu.org/releases/freetype/freetype-2.6.tar.gz',
'hash':'md5:1d733ea6c1b7b3df38169fbdbec47d2b',
'dir': 'freetype-2.6',
},
'lcms':{
'url':SF_MIRROR+'/project/lcms/lcms/2.6/lcms2-2.6.zip',
'hash': 'sha1:eea25f001246fa2e6b242ac456cecff7483cf061',
'dir': 'lcms2-2.6',
},
'tcl':{
'url':SF_MIRROR+'/project/tcl/Tcl/8.5.13/tcl8513-src.zip',
'hash': 'sha1:3e01585c91293c532a3cd594ec59deca92153a5e',
'dir': '',
},
'tk':{
'url':SF_MIRROR+'/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',
},
# 'openjpeg':{
# 'url':'https://openjpeg.googlecode.com/files/openjpeg-2.0.0.tar.gz',
# 'hash':'sha1:0af78ab2283b43421458f80373422d8029a9f7a7',
# 'dir':'openjpeg-2.0.0',
# },
'openjpeg':{
'url':SF_MIRROR+'/project/openjpeg/openjpeg/2.1.0/openjpeg-2.1.0.tar.gz',
'hash':'md5:f6419fcc233df84f9a81eb36633c6db6',
'dir':'openjpeg-2.1.0',
},
}
bin_libs = {
'openjpeg':{
'filename':'openjpeg-2.0.0-win32-x86.zip',
'hash':'sha1:xxx',
'version':'2.0'
},
}
compilers = { (7,64): {
'env_version':'v7.0',
'vc_version':'2008',
'env_flags': '/x64 /xp',
'inc_dir': 'msvcr90-x64',
'platform': 'x64'
},
(7,32): {
'env_version':'v7.0',
'vc_version':'2008',
'env_flags': '/x86 /xp',
'inc_dir': 'msvcr90-x32',
'platform': 'Win32'
},
(7.1,64): {
'env_version':'v7.1',
'vc_version':'2010',
'env_flags': '/x64 /vista',
'inc_dir': 'msvcr10-x64',
'platform': 'x64',
},
(7.1,32): {
'env_version':'v7.1',
'vc_version':'2010',
'env_flags': '/x86 /vista',
'inc_dir': 'msvcr10-x32',
'platform': 'Win32',
},
}
def pyversion_fromEnv():
py = os.environ['PYTHON']
py_version = '27'
for k,v in pythons.items():
if k in py:
py_version = k
break
if '64' in py:
py_version = '%s%s' % (py_version, X64_EXT)
return py_version
def compiler_fromEnv():
py = os.environ['PYTHON']
for k,v in pythons.items():
if k in py:
compiler_version = v
break
bit = 32
if '64' in py:
bit = 64
return compilers[(compiler_version, bit)]

16
winbuild/fetch.py Normal file
View File

@ -0,0 +1,16 @@
import sys, os, urllib.parse, urllib.request
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])

8
winbuild/fixproj.py Normal file
View File

@ -0,0 +1,8 @@
import sys
with open(sys.argv[1], 'r') as fd:
content = '\n'.join(line.strip() for line in fd if line.strip())
if len(sys.argv) == 3:
content = content.replace('Win32', sys.argv[2]).replace('x64', sys.argv[2])
with open(sys.argv[1], 'w') as fd:
fd.write(content)

12
winbuild/get_pythons.py Normal file
View File

@ -0,0 +1,12 @@
from fetch import fetch
import os
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')

218
winbuild/nmake.opt Normal file
View File

@ -0,0 +1,218 @@
# $Id: nmake.opt,v 1.18 2006/06/07 16:33:45 dron Exp $
#
# Copyright (C) 2004, Andrey Kiselev <dron@ak4719.spb.edu>
#
# Permission to use, copy, modify, distribute, and sell this software and
# its documentation for any purpose is hereby granted without fee, provided
# that (i) the above copyright notices and this permission notice appear in
# all copies of the software and related documentation, and (ii) the names of
# Sam Leffler and Silicon Graphics may not be used in any advertising or
# publicity relating to the software without the specific, prior written
# permission of Sam Leffler and Silicon Graphics.
#
# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
#
# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
# OF THIS SOFTWARE.
# Compile time parameters for MS Visual C++ compiler.
# You may edit this file to specify building options.
#
###### Edit the following lines to choose a feature set you need. #######
#
#
# Select WINMODE_CONSOLE to build a library which reports errors to stderr, or
# WINMODE_WINDOWED to build such that errors are reported via MessageBox().
#
WINMODE_CONSOLE = 1
#WINMODE_WINDOWED = 1
#
# Comment out the following lines to disable internal codecs.
#
# Support for CCITT Group 3 & 4 algorithms
CCITT_SUPPORT = 1
# Support for Macintosh PackBits algorithm
PACKBITS_SUPPORT = 1
# Support for LZW algorithm
LZW_SUPPORT = 1
# Support for ThunderScan 4-bit RLE algorithm
THUNDER_SUPPORT = 1
# Support for NeXT 2-bit RLE algorithm
NEXT_SUPPORT = 1
# Support for LogLuv high dynamic range encoding
LOGLUV_SUPPORT = 1
#
# Uncomment and edit following lines to enable JPEG support.
#
JPEG_SUPPORT = 1
JPEGDIR = $(BUILD)\jpeg-9a
JPEG_INCLUDE = -I$(JPEGDIR)
JPEG_LIB = $(JPEGDIR)/libjpeg.lib
#
# Uncomment and edit following lines to enable ZIP support
# (required for Deflate compression and Pixar log-format)
#
ZIP_SUPPORT = 1
ZLIBDIR = $(BUILD)\zlib-1.2.8
ZLIB_INCLUDE = -I$(ZLIBDIR)
ZLIB_LIB = $(ZLIBDIR)/zlib.lib
#
# Uncomment and edit following lines to enable ISO JBIG support
#
#JBIG_SUPPORT = 1
#JBIGDIR = d:/projects/jbigkit
#JBIG_INCLUDE = -I$(JBIGDIR)/libjbig
#JBIG_LIB = $(JBIGDIR)/libjbig/jbig.lib
#
# Uncomment following line to enable Pixar log-format algorithm
# (Zlib required).
#
#PIXARLOG_SUPPORT = 1
#
# Comment out the following lines to disable strip chopping
# (whether or not to convert single-strip uncompressed images to multiple
# strips of specified size to reduce memory usage). Default strip size
# is 8192 bytes, it can be configured via the STRIP_SIZE_DEFAULT parameter
#
STRIPCHOP_SUPPORT = 1
STRIP_SIZE_DEFAULT = 8192
#
# Comment out the following lines to disable treating the fourth sample with
# no EXTRASAMPLE_ value as being ASSOCALPHA. Many packages produce RGBA
# files but don't mark the alpha properly.
#
EXTRASAMPLE_AS_ALPHA_SUPPORT = 1
#
# Comment out the following lines to disable picking up YCbCr subsampling
# info from the JPEG data stream to support files lacking the tag.
# See Bug 168 in Bugzilla, and JPEGFixupTestSubsampling() for details.
#
CHECK_JPEG_YCBCR_SUBSAMPLING = 1
#
####################### Compiler related options. #######################
#
#
# Pick debug or optimized build flags. We default to an optimized build
# with no debugging information.
# NOTE: /EHsc option required if you want to build the C++ stream API
#
OPTFLAGS = /Ox /MD /EHsc /W3 /D_CRT_SECURE_NO_DEPRECATE
#OPTFLAGS = /Zi
#
# Uncomment following line to enable using Windows Common RunTime Library
# instead of Windows specific system calls. See notes on top of tif_unix.c
# module for details.
#
USE_WIN_CRT_LIB = 1
# Compiler specific options. You may probably want to adjust compilation
# parameters in CFLAGS variable. Refer to your compiler documentation
# for the option reference.
#
MAKE = nmake /nologo
CC = cl /nologo
CXX = cl /nologo
AR = lib /nologo
LD = link /nologo
CFLAGS = $(OPTFLAGS) $(INCL) $(EXTRAFLAGS)
CXXFLAGS = $(OPTFLAGS) $(INCL) $(EXTRAFLAGS)
EXTRAFLAGS =
LIBS =
# Name of the output shared library
DLLNAME = libtiff.dll
#
########### There is nothing to edit below this line normally. ###########
#
# Set the native cpu bit order
EXTRAFLAGS = -DFILLODER_LSB2MSB $(EXTRAFLAGS)
!IFDEF WINMODE_WINDOWED
EXTRAFLAGS = -DTIF_PLATFORM_WINDOWED $(EXTRAFLAGS)
LIBS = user32.lib $(LIBS)
!ELSE
EXTRAFLAGS = -DTIF_PLATFORM_CONSOLE $(EXTRAFLAGS)
!ENDIF
# Codec stuff
!IFDEF CCITT_SUPPORT
EXTRAFLAGS = -DCCITT_SUPPORT $(EXTRAFLAGS)
!ENDIF
!IFDEF PACKBITS_SUPPORT
EXTRAFLAGS = -DPACKBITS_SUPPORT $(EXTRAFLAGS)
!ENDIF
!IFDEF LZW_SUPPORT
EXTRAFLAGS = -DLZW_SUPPORT $(EXTRAFLAGS)
!ENDIF
!IFDEF THUNDER_SUPPORT
EXTRAFLAGS = -DTHUNDER_SUPPORT $(EXTRAFLAGS)
!ENDIF
!IFDEF NEXT_SUPPORT
EXTRAFLAGS = -DNEXT_SUPPORT $(EXTRAFLAGS)
!ENDIF
!IFDEF LOGLUV_SUPPORT
EXTRAFLAGS = -DLOGLUV_SUPPORT $(EXTRAFLAGS)
!ENDIF
!IFDEF JPEG_SUPPORT
LIBS = $(LIBS) $(JPEG_LIB)
EXTRAFLAGS = -DJPEG_SUPPORT -DOJPEG_SUPPORT $(EXTRAFLAGS)
!ENDIF
!IFDEF ZIP_SUPPORT
LIBS = $(LIBS) $(ZLIB_LIB)
EXTRAFLAGS = -DZIP_SUPPORT $(EXTRAFLAGS)
!IFDEF PIXARLOG_SUPPORT
EXTRAFLAGS = -DPIXARLOG_SUPPORT $(EXTRAFLAGS)
!ENDIF
!ENDIF
!IFDEF JBIG_SUPPORT
LIBS = $(LIBS) $(JBIG_LIB)
EXTRAFLAGS = -DJBIG_SUPPORT $(EXTRAFLAGS)
!ENDIF
!IFDEF STRIPCHOP_SUPPORT
EXTRAFLAGS = -DSTRIPCHOP_DEFAULT=TIFF_STRIPCHOP -DSTRIP_SIZE_DEFAULT=$(STRIP_SIZE_DEFAULT) $(EXTRAFLAGS)
!ENDIF
!IFDEF EXTRASAMPLE_AS_ALPHA_SUPPORT
EXTRAFLAGS = -DDEFAULT_EXTRASAMPLE_AS_ALPHA $(EXTRAFLAGS)
!ENDIF
!IFDEF CHECK_JPEG_YCBCR_SUBSAMPLING
EXTRAFLAGS = -DCHECK_JPEG_YCBCR_SUBSAMPLING $(EXTRAFLAGS)
!ENDIF
!IFDEF USE_WIN_CRT_LIB
EXTRAFLAGS = -DAVOID_WIN32_FILEIO $(EXTRAFLAGS)
!ELSE
EXTRAFLAGS = -DUSE_WIN32_FILEIO $(EXTRAFLAGS)
!ENDIF

44
winbuild/test.py Normal file
View File

@ -0,0 +1,44 @@
#!/usr/bin/env python3
import subprocess
import os
import glob
import sys
from config import *
def test_one(params):
python, architecture = params
try:
print ("Running: %s, %s" %params)
command = [r'%s\%s%s\Scripts\python.exe' % (VIRT_BASE, python, architecture),
'test-installed.py',
'--processes=-0',
'--process-timeout=30',
]
command.extend(glob.glob('Tests/test*.py'))
proc = subprocess.Popen(command,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE)
(trace, stderr) = proc.communicate()
status = proc.returncode
print ("Done with %s, %s -- %s" % (python, architecture, status ))
return (python, architecture, status, trace)
except Exception as msg:
print ("Error with %s, %s: %s" % (python, architecture, msg))
return (python, architecture, -1, str(msg))
if __name__=='__main__':
os.chdir('..')
matrix = [(python, architecture) for python in pythons
for architecture in ('', X64_EXT)]
results = map(test_one, matrix)
for (python, architecture, status, trace) in results:
print ("%s%s: %s" % (python, architecture, status and 'ERR' or 'PASS'))
res = all(status for (python, architecture, status, trace) in results)
sys.exit(res)

8
winbuild/untar.py Normal file
View File

@ -0,0 +1,8 @@
import sys, tarfile
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])

8
winbuild/unzip.py Normal file
View File

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