mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-15 18:52:19 +03:00
Merge pull request #1291 from radarhere/winbuild_health
Style/health fixes
This commit is contained in:
commit
05c482655c
|
@ -105,7 +105,6 @@ post-patch:
|
|||
test_output = BytesIO()
|
||||
im.save(test_output, "JPEG", qtables=qtables)
|
||||
|
||||
|
||||
def test_exif_leak(self):
|
||||
"""
|
||||
pre patch:
|
||||
|
|
|
@ -233,6 +233,7 @@ def netpbm_available():
|
|||
def imagemagick_available():
|
||||
return IMCONVERT and command_succeeds([IMCONVERT, '-version'])
|
||||
|
||||
|
||||
def on_appveyor():
|
||||
return 'APPVEYOR' in os.environ
|
||||
|
||||
|
|
|
@ -2,11 +2,13 @@
|
|||
|
||||
import subprocess
|
||||
import shutil
|
||||
import sys, getopt
|
||||
import sys
|
||||
import getopt
|
||||
import os
|
||||
|
||||
from config import *
|
||||
|
||||
|
||||
def setup_vms():
|
||||
ret = []
|
||||
for py in pythons.keys():
|
||||
|
@ -20,6 +22,7 @@ def setup_vms():
|
|||
(VIRT_BASE, py, arch))
|
||||
return "\n".join(ret)
|
||||
|
||||
|
||||
def run_script(params):
|
||||
(version, script) = params
|
||||
try:
|
||||
|
@ -53,11 +56,13 @@ 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 = {}
|
||||
|
@ -87,6 +92,7 @@ endlocal
|
|||
endlocal
|
||||
""" % args
|
||||
|
||||
|
||||
def clean():
|
||||
try:
|
||||
shutil.rmtree('../build')
|
||||
|
@ -95,6 +101,7 @@ def clean():
|
|||
pass
|
||||
run_script(('virtualenvs', setup_vms()))
|
||||
|
||||
|
||||
def main(op):
|
||||
scripts = []
|
||||
|
||||
|
@ -116,12 +123,12 @@ def main(op):
|
|||
for (version, status, trace, err) in results:
|
||||
print("Compiled %s: %s" % (version, status and 'ERR' or 'OK'))
|
||||
|
||||
|
||||
def run_one(op):
|
||||
|
||||
compiler = compiler_fromEnv()
|
||||
py_version = pyversion_fromEnv()
|
||||
|
||||
|
||||
run_script((py_version,
|
||||
"\n".join([header(op),
|
||||
build_one(py_version, compiler),
|
||||
|
@ -129,8 +136,6 @@ def run_one(op):
|
|||
))
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
opts, args = getopt.getopt(sys.argv[1:], '', ['clean', 'dist'])
|
||||
opts = dict(opts)
|
||||
|
|
|
@ -1,22 +1,26 @@
|
|||
from fetch import fetch
|
||||
from unzip import unzip
|
||||
from untar import untar
|
||||
import os, hashlib
|
||||
import shutil
|
||||
import os
|
||||
import hashlib
|
||||
|
||||
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
|
||||
if not checksum:
|
||||
return filename
|
||||
|
||||
(algo, value) = checksum.split(':')
|
||||
h = hashlib.new(algo)
|
||||
|
@ -26,31 +30,35 @@ def check_hash(filename, checksum):
|
|||
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:
|
||||
except OSError:
|
||||
pass
|
||||
try:
|
||||
os.mkdir(inc_dir)
|
||||
except:
|
||||
except OSError:
|
||||
pass
|
||||
for compiler in compilers.values():
|
||||
try:
|
||||
os.mkdir(os.path.join(inc_dir, compiler['inc_dir']))
|
||||
except:
|
||||
except OSError:
|
||||
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':
|
||||
|
@ -63,18 +71,11 @@ def fetch_libs():
|
|||
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"""
|
||||
|
@ -89,6 +90,7 @@ copy /Y /B openjpeg-2.0.0-win32-x86\lib\ %%INCLIB%%
|
|||
endlocal
|
||||
""" % compiler
|
||||
|
||||
|
||||
def cp_tk():
|
||||
return r"""
|
||||
mkdir %INCLIB%\tcl85\include\X11
|
||||
|
@ -102,6 +104,7 @@ copy /Y /B %BUILD%\tk8.6.4\generic\*.h %INCLIB%\tcl86\include\
|
|||
copy /Y /B %BUILD%\tk8.6.4\xlib\X11\* %INCLIB%\tcl86\include\X11\
|
||||
"""
|
||||
|
||||
|
||||
def header():
|
||||
return r"""setlocal
|
||||
set MSBUILD=C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe
|
||||
|
@ -111,17 +114,20 @@ 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)
|
||||
|
@ -139,6 +145,7 @@ 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)
|
||||
|
@ -158,7 +165,6 @@ endlocal
|
|||
""" % atts
|
||||
|
||||
|
||||
|
||||
def nmake_libs(compiler):
|
||||
# undone -- pre, makes, headers, libs
|
||||
return r"""
|
||||
|
@ -211,11 +217,13 @@ 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
|
||||
|
@ -227,6 +235,7 @@ copy /Y /B %%FREETYPE%%\objs\vc%(vc_version)s\%(platform)s\*.lib %%INCLIB%%\free
|
|||
endlocal
|
||||
""" % compiler
|
||||
|
||||
|
||||
def msbuild_freetype_70(compiler):
|
||||
return r"""
|
||||
rem Build freetype
|
||||
|
@ -241,14 +250,17 @@ copy /Y /B %%FREETYPE%%\objs\win32\vc%(vc_version)s\*.lib %%INCLIB%%\freetype.li
|
|||
endlocal
|
||||
""" % compiler
|
||||
|
||||
|
||||
def build_lcms2(compiler):
|
||||
if compiler['env_version'] == 'v7.1':
|
||||
return build_lcms_71(compiler)
|
||||
return build_lcms_70(compiler)
|
||||
|
||||
|
||||
def build_lcms_70(compiler):
|
||||
"""Link error here on x64"""
|
||||
if compiler['platform'] == 'x64': return ''
|
||||
if compiler['platform'] == 'x64':
|
||||
return ''
|
||||
|
||||
"""Build LCMS on VC2008. This version is only 32bit/Win32"""
|
||||
return r"""
|
||||
|
@ -263,6 +275,7 @@ copy /Y /B %%LCMS%%\Projects\VC%(vc_version)s\Release\*.lib %%INCLIB%%
|
|||
endlocal
|
||||
""" % compiler
|
||||
|
||||
|
||||
def build_lcms_71(compiler):
|
||||
return r"""
|
||||
rem Build lcms2
|
||||
|
@ -289,14 +302,12 @@ def add_compiler(compiler):
|
|||
script.append(end_compiler())
|
||||
|
||||
|
||||
|
||||
mkdirs()
|
||||
fetch_libs()
|
||||
# extract_binlib()
|
||||
script = [header(), cp_tk()]
|
||||
|
||||
|
||||
|
||||
if 'PYTHON' in os.environ:
|
||||
add_compiler(compiler_fromEnv())
|
||||
else:
|
||||
|
@ -307,7 +318,3 @@ else:
|
|||
|
||||
with open('build_deps.cmd', 'w') as f:
|
||||
f.write("\n".join(script))
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@ libs = { 'zlib':{
|
|||
'url': 'http://downloads.webmproject.org/releases/webp/libwebp-0.4.3.tar.gz',
|
||||
'hash': 'sha1:1c307a61c4d0018620b4ba9a58e8f48a8d6640ef',
|
||||
'dir': 'libwebp-0.4.3',
|
||||
|
||||
},
|
||||
'openjpeg': {
|
||||
'url': SF_MIRROR+'/project/openjpeg/openjpeg/2.1.0/openjpeg-2.1.0.tar.gz',
|
||||
|
@ -118,7 +119,7 @@ def pyversion_fromEnv():
|
|||
py = os.environ['PYTHON']
|
||||
|
||||
py_version = '27'
|
||||
for k,v in pythons.items():
|
||||
for k in pythons.keys():
|
||||
if k in py:
|
||||
py_version = k
|
||||
break
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
import sys, os, urllib.parse, urllib.request
|
||||
import sys
|
||||
import os
|
||||
import urllib.parse
|
||||
import urllib.request
|
||||
|
||||
|
||||
def fetch(url):
|
||||
name = urllib.parse.urlsplit(url)[2].split('/')[-1]
|
||||
|
@ -12,5 +16,3 @@ def fetch(url):
|
|||
|
||||
if __name__ == '__main__':
|
||||
fetch(sys.argv[1])
|
||||
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import sys
|
|||
|
||||
from config import *
|
||||
|
||||
|
||||
def test_one(params):
|
||||
python, architecture = params
|
||||
try:
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
import sys, tarfile
|
||||
import sys
|
||||
import tarfile
|
||||
|
||||
|
||||
def untar(src, dest):
|
||||
with tarfile.open(src, 'r:gz') as tgz:
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
import sys, zipfile
|
||||
import sys
|
||||
import zipfile
|
||||
|
||||
|
||||
def unzip(src, dest):
|
||||
with zipfile.ZipFile(src) as zf:
|
||||
|
|
Loading…
Reference in New Issue
Block a user