Merge pull request #741 from python-pillow/flake8-fixes

Top level flake8 fixes
This commit is contained in:
Hugo 2014-06-28 08:26:15 +03:00
commit c567c3ec89
3 changed files with 16 additions and 17 deletions

View File

@ -5,6 +5,7 @@ from multiprocessing import Pool, cpu_count
from distutils.ccompiler import CCompiler from distutils.ccompiler import CCompiler
import os import os
# hideous monkeypatching. but. but. but. # hideous monkeypatching. but. but. but.
def _mp_compile_one(tp): def _mp_compile_one(tp):
(self, obj, build, cc_args, extra_postargs, pp_opts) = tp (self, obj, build, cc_args, extra_postargs, pp_opts) = tp
@ -15,6 +16,7 @@ def _mp_compile_one(tp):
self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts) self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
return return
def _mp_compile(self, sources, output_dir=None, macros=None, def _mp_compile(self, sources, output_dir=None, macros=None,
include_dirs=None, debug=0, extra_preargs=None, include_dirs=None, debug=0, extra_preargs=None,
extra_postargs=None, depends=None): extra_postargs=None, depends=None):
@ -25,12 +27,10 @@ def _mp_compile(self, sources, output_dir=None, macros=None,
# A concrete compiler class can either override this method # A concrete compiler class can either override this method
# entirely or implement _compile(). # entirely or implement _compile().
macros, objects, extra_postargs, pp_opts, build = \ macros, objects, extra_postargs, pp_opts, build = self._setup_compile(
self._setup_compile(output_dir, macros, include_dirs, sources, output_dir, macros, include_dirs, sources, depends, extra_postargs)
depends, extra_postargs)
cc_args = self._get_cc_args(pp_opts, debug, extra_preargs) cc_args = self._get_cc_args(pp_opts, debug, extra_preargs)
try: try:
max_procs = int(os.environ.get('MAX_CONCURRENCY', cpu_count())) max_procs = int(os.environ.get('MAX_CONCURRENCY', cpu_count()))
except: except:
@ -38,10 +38,12 @@ def _mp_compile(self, sources, output_dir=None, macros=None,
pool = Pool(max_procs) pool = Pool(max_procs)
try: try:
print ("Building using %d processes" % pool._processes) print ("Building using %d processes" % pool._processes)
except: pass except:
arr = [(self, obj, build, cc_args, extra_postargs, pp_opts) for obj in objects] pass
results = pool.map_async(_mp_compile_one,arr) arr = [
(self, obj, build, cc_args, extra_postargs, pp_opts) for obj in objects
]
pool.map_async(_mp_compile_one, arr)
pool.close() pool.close()
pool.join() pool.join()
# Return *all* object filenames, not just the ones we just built. # Return *all* object filenames, not just the ones we just built.

View File

@ -14,8 +14,6 @@ import re
import struct import struct
import sys import sys
import mp_compile
from distutils.command.build_ext import build_ext from distutils.command.build_ext import build_ext
from distutils import sysconfig from distutils import sysconfig
from setuptools import Extension, setup, find_packages from setuptools import Extension, setup, find_packages
@ -742,5 +740,4 @@ if __name__=='__main__':
license='Standard PIL License', license='Standard PIL License',
zip_safe=True, zip_safe=True,
) )
# End of file # End of file

View File

@ -4,8 +4,8 @@ import os
import sys import sys
import glob import glob
# monkey with the path, removing the local directory but adding the Tests/ directory # monkey with the path, removing the local directory but adding the Tests/
# for helper.py and the other local imports there. # directory for helper.py and the other local imports there.
del(sys.path[0]) del(sys.path[0])
sys.path.insert(0, os.path.abspath('./Tests')) sys.path.insert(0, os.path.abspath('./Tests'))