Skip to content

Commit

Permalink
Added Python 3.5-3.7 AppVeyor builds
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Oct 8, 2018
1 parent fe654a7 commit afb6ba5
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 73 deletions.
8 changes: 7 additions & 1 deletion .appveyor.yml
Expand Up @@ -18,8 +18,14 @@ environment:
PIP_DIR: bin
VENV: YES
- PYTHON: C:/Python27-x64
- PYTHON: C:/Python34
- PYTHON: C:/Python37
- PYTHON: C:/Python27
- PYTHON: C:/Python37-x64
- PYTHON: C:/Python36
- PYTHON: C:/Python36-x64
- PYTHON: C:/Python35
- PYTHON: C:/Python35-x64
- PYTHON: C:/Python34
- PYTHON: C:/Python34-x64
- PYTHON: C:/msys64/mingw32
EXECUTABLE: bin/python3
Expand Down
5 changes: 3 additions & 2 deletions setup.py
Expand Up @@ -191,10 +191,11 @@ def __iter__(self):
('disable-platform-guessing', None,
'Disable platform guessing on Linux'),
('debug', None, 'Debug logging')
]
] + [('add-imaging-libs=', None, 'Add libs to _imaging build')]

def initialize_options(self):
self.disable_platform_guessing = None
self.add_imaging_libs = ""
build_ext.initialize_options(self)
for x in self.feature:
setattr(self, 'disable_%s' % x, None)
Expand Down Expand Up @@ -598,7 +599,7 @@ def build_extensions(self):
for src_file in _LIB_IMAGING:
files.append(os.path.join("src/libImaging", src_file + ".c"))

libs = []
libs = self.add_imaging_libs.split()
defs = []
if feature.jpeg:
libs.append(feature.jpeg)
Expand Down
42 changes: 28 additions & 14 deletions winbuild/build.py
Expand Up @@ -7,7 +7,7 @@
import os

from config import (compilers, compiler_from_env, pythons, pyversion_from_env,
VIRT_BASE, X64_EXT)
bit_from_env, VIRT_BASE, X64_EXT)


def setup_vms():
Expand Down Expand Up @@ -64,7 +64,15 @@ def footer():
"""


def build_one(py_ver, compiler):
def vc_setup(compiler, bit):
script = ""
if compiler['vc_version'] == '2015':
arch = "x86" if bit == 32 else "x86_amd64"
script = r"""
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" %s""" % arch
return script

def build_one(py_ver, compiler, bit):
# UNDONE virtual envs if we're not running on appveyor
args = {}
args.update(compiler)
Expand All @@ -78,25 +86,31 @@ def build_one(py_ver, compiler):
args['executable'] = "%EXECUTABLE%"

args['py_ver'] = py_ver
if '34' in py_ver:
if '27' in py_ver:
args['tcl_ver'] = '85'
else:
args['tcl_ver'] = '86'

if compiler['vc_version'] == '2015':
args['imaging_libs'] = ' build_ext --add-imaging-libs=msvcrt'
else:
args['tcl_ver'] = '85'
args['imaging_libs'] = ''

return r"""
script = 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%%\tcl%(tcl_ver)s\include
setlocal
set LIB=%%LIB%%;C:\Python%(py_ver)s\tcl
call %(python_path)s\%(executable)s setup.py %%BLDOPT%%
set LIB=%%LIB%%;C:\Python%(py_ver)s\tcl""" + vc_setup(compiler, bit) + r"""
call %(python_path)s\%(executable)s setup.py %(imaging_libs)s %%BLDOPT%%
endlocal
endlocal
""" % args
"""
return script % args


def clean():
Expand All @@ -111,19 +125,18 @@ def clean():
def main(op):
scripts = []

for py_version, compiler_version in pythons.items():
for py_version, py_info in pythons.items():
py_compilers = compilers[py_info['compiler']][py_info['vc']]
scripts.append((py_version,
"\n".join([header(op),
build_one(py_version,
compilers[(compiler_version,
32)]),
py_compilers[32], 32),
footer()])))

scripts.append(("%s%s" % (py_version, X64_EXT),
"\n".join([header(op),
build_one("%sx64" % py_version,
compilers[(compiler_version,
64)]),
py_compilers[64], 64),
footer()])))

results = map(run_script, scripts)
Expand All @@ -136,10 +149,11 @@ def run_one(op):

compiler = compiler_from_env()
py_version = pyversion_from_env()
bit = bit_from_env()

run_script((py_version,
"\n".join([header(op),
build_one(py_version, compiler),
build_one(py_version, compiler, bit),
footer()])
))

Expand Down
32 changes: 18 additions & 14 deletions winbuild/build_dep.py
Expand Up @@ -3,7 +3,9 @@
import os

from fetch import fetch
from config import compilers, compiler_from_env, libs
from config import (compilers, all_compilers, compiler_from_env, bit_from_env,
libs)
from build import vc_setup


def _relpath(*args):
Expand All @@ -28,7 +30,7 @@ def mkdirs():
os.mkdir(inc_dir)
except OSError:
pass
for compiler in compilers.values():
for compiler in all_compilers():
try:
os.mkdir(os.path.join(inc_dir, compiler['inc_dir']))
except OSError:
Expand All @@ -48,7 +50,7 @@ def extract_libs():
if not os.path.exists(filename):
filename = fetch(lib['url'])
if name == 'openjpeg':
for compiler in compilers.values():
for compiler in all_compilers():
if not os.path.exists(os.path.join(
build_dir, lib['dir']+compiler['inc_dir'])):
extract(filename, build_dir)
Expand Down Expand Up @@ -148,11 +150,12 @@ def msbuild_openjpeg(compiler):
""" % atts


def nmake_libs(compiler):
def nmake_libs(compiler, bit):
# undone -- pre, makes, headers, libs
return r"""
script = r"""
rem Build libjpeg
setlocal
""" + vc_setup(compiler, bit) + r"""
cd /D %%JPEG%%
nmake -f makefile.vc setup-vc6
nmake -f makefile.vc clean
Expand All @@ -176,6 +179,7 @@ def nmake_libs(compiler):
rem Build webp
setlocal
""" + vc_setup(compiler, bit) + r"""
cd /D %%WEBP%%
rd /S /Q %%WEBP%%\output\release-static
nmake -f Makefile.vc CFG=release-static RTLIBCFG=static OBJDIR=output all
Expand All @@ -186,6 +190,7 @@ def nmake_libs(compiler):
rem Build libtiff
setlocal
""" + vc_setup(compiler, bit) + r"""
rem do after building jpeg and zlib
copy %%~dp0\nmake.opt %%TIFF%%
Expand All @@ -196,9 +201,8 @@ def nmake_libs(compiler):
copy /Y /B libtiff\*.lib %%INCLIB%%
copy /Y /B libtiff\tiff*.h %%INCLIB%%
endlocal
""" % compiler
"""
return script % compiler


def msbuild_freetype(compiler):
Expand Down Expand Up @@ -273,9 +277,9 @@ def build_lcms_71(compiler):
""" % compiler


def add_compiler(compiler):
def add_compiler(compiler, bit):
script.append(setup_compiler(compiler))
script.append(nmake_libs(compiler))
script.append(nmake_libs(compiler, bit))

# script.append(extract_openjpeg(compiler))

Expand All @@ -293,12 +297,12 @@ def add_compiler(compiler):


if 'PYTHON' in os.environ:
add_compiler(compiler_from_env())
add_compiler(compiler_from_env(), bit_from_env())
else:
# for compiler in compilers.values():
# for compiler in all_compilers():
# add_compiler(compiler)
add_compiler(compilers[(7.0, 32)])
# add_compiler(compilers[(7.1, 64)])
add_compiler(compilers[7.0][2008][32], 32)
# add_compiler(compilers[7.1][2010][64])

with open('build_deps.cmd', 'w') as f:
f.write("\n".join(script))
120 changes: 78 additions & 42 deletions winbuild/config.py
Expand Up @@ -3,12 +3,13 @@
SF_MIRROR = 'http://iweb.dl.sourceforge.net'
PILLOW_DEPENDS_DIR = 'C:\\pillow-depends\\'

pythons = { # '26': 7,
'27': 7,
'pypy2': 7,
# '32': 7,
'33': 7.1,
'34': 7.1}
pythons = {'27': {'compiler':7, 'vc':2008},
'pypy2': {'compiler':7, 'vc':2008},
'33': {'compiler':7.1, 'vc':2010},
'34': {'compiler':7.1, 'vc':2010},
'35': {'compiler':7.1, 'vc':2015},
'36': {'compiler':7.1, 'vc':2015},
'37': {'compiler':7.1, 'vc':2015}}

VIRT_BASE = "c:/vp/"
X64_EXT = os.environ.get('X64_EXT', "x64")
Expand Down Expand Up @@ -78,38 +79,64 @@
}

compilers = {
(7, 64): {
'env_version': 'v7.0',
'vc_version': '2008',
'env_flags': '/x64 /xp',
'inc_dir': 'msvcr90-x64',
'platform': 'x64',
'webp_platform': 'x64',
},
(7, 32): {
'env_version': 'v7.0',
'vc_version': '2008',
'env_flags': '/x86 /xp',
'inc_dir': 'msvcr90-x32',
'platform': 'Win32',
'webp_platform': 'x86',
},
(7.1, 64): {
'env_version': 'v7.1',
'vc_version': '2010',
'env_flags': '/x64 /vista',
'inc_dir': 'msvcr10-x64',
'platform': 'x64',
'webp_platform': 'x64',
},
(7.1, 32): {
'env_version': 'v7.1',
'vc_version': '2010',
'env_flags': '/x86 /vista',
'inc_dir': 'msvcr10-x32',
'platform': 'Win32',
'webp_platform': 'x86',
7: {
2008: {
64: {
'env_version': 'v7.0',
'vc_version': '2008',
'env_flags': '/x64 /xp',
'inc_dir': 'msvcr90-x64',
'platform': 'x64',
'webp_platform': 'x64',
},
32: {
'env_version': 'v7.0',
'vc_version': '2008',
'env_flags': '/x86 /xp',
'inc_dir': 'msvcr90-x32',
'platform': 'Win32',
'webp_platform': 'x86',
}
}
},
7.1: {
2010: {
64: {
'env_version': 'v7.1',
'vc_version': '2010',
'env_flags': '/x64 /vista',
'inc_dir': 'msvcr10-x64',
'platform': 'x64',
'webp_platform': 'x64',
},
32: {
'env_version': 'v7.1',
'vc_version': '2010',
'env_flags': '/x86 /vista',
'inc_dir': 'msvcr10-x32',
'platform': 'Win32',
'webp_platform': 'x86',
}
},
2015: {
64: {
'env_version': 'v7.1',
'vc_version': '2015',
'env_flags': '/x64 /vista',
'inc_dir': 'msvcr10-x64',
'platform': 'x64',
'webp_platform': 'x64',
},
32: {
'env_version': 'v7.1',
'vc_version': '2015',
'env_flags': '/x86 /vista',
'inc_dir': 'msvcr10-x32',
'platform': 'Win32',
'webp_platform': 'x86',
}
}
}
}


Expand All @@ -133,11 +160,20 @@ def compiler_from_env():

for k, v in pythons.items():
if k in py:
compiler_version = v
py_info = v
break

bit = 32
if '64' in py:
bit = 64
bit = bit_from_env()
return compilers[py_info['compiler']][py_info['vc']][bit]

def bit_from_env():
py = os.environ['PYTHON']

return 64 if '64' in py else 32

return compilers[(compiler_version, bit)]
def all_compilers():
all = []
for vc_compilers in compilers.values():
for bit_compilers in vc_compilers.values():
all += bit_compilers.values()
return all

0 comments on commit afb6ba5

Please sign in to comment.