mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
Flake8 fixes
This commit is contained in:
parent
8a7080cbce
commit
bbf3b52357
|
@ -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,21 +1,26 @@
|
|||
from fetch import fetch
|
||||
from unzip import unzip
|
||||
from untar import untar
|
||||
import os, hashlib
|
||||
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)
|
||||
|
@ -25,10 +30,12 @@ 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)
|
||||
|
@ -44,12 +51,14 @@ def mkdirs():
|
|||
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':
|
||||
|
@ -62,10 +71,12 @@ 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)
|
||||
|
||||
|
||||
def extract_openjpeg(compiler):
|
||||
return r"""
|
||||
rem build openjpeg
|
||||
|
@ -79,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
|
||||
|
@ -92,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
|
||||
|
@ -101,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)
|
||||
|
@ -129,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)
|
||||
|
@ -148,7 +165,6 @@ endlocal
|
|||
""" % atts
|
||||
|
||||
|
||||
|
||||
def nmake_libs(compiler):
|
||||
# undone -- pre, makes, headers, libs
|
||||
return r"""
|
||||
|
@ -201,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
|
||||
|
@ -217,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
|
||||
|
@ -231,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"""
|
||||
|
@ -253,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
|
||||
|
@ -279,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:
|
||||
|
@ -297,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',
|
||||
|
|
|
@ -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