diff --git a/aksetup_helper.py b/aksetup_helper.py index 50507afca8e8af736d51ef154316b6badef69b42..36422892cbf07f30736c2bd2d9733bf312545c6b 100644 --- a/aksetup_helper.py +++ b/aksetup_helper.py @@ -12,6 +12,7 @@ def count_down_delay(delay): sleep(1) print("") + DASH_SEPARATOR = 75 * "-" @@ -23,7 +24,7 @@ def setup(*args, **kwargs): raise except SystemExit: raise - except: + except Exception: print(DASH_SEPARATOR) print("Sorry, your build failed. Try rerunning configure.py with " "different options.") @@ -212,7 +213,7 @@ def expand_value(v, options): for i in v: try: exp_i = expand_value(i, options) - except: + except Exception: pass else: result.append(exp_i) @@ -687,17 +688,20 @@ def substitute(substitutions, fname): fname_in = fname+".in" lines = open(fname_in, "r").readlines() new_lines = [] - for l in lines: + for line in lines: made_change = True while made_change: made_change = False - match = var_re.search(l) + match = var_re.search(line) if match: varname = match.group(1) - l = l[:match.start()] + str(substitutions[varname]) + l[match.end():] + line = ( + line[:match.start()] + + str(substitutions[varname]) + + line[match.end():]) made_change = True - match = string_var_re.search(l) + match = string_var_re.search(line) if match: varname = match.group(1) subst = substitutions[varname] @@ -706,9 +710,9 @@ def substitute(substitutions, fname): else: subst = '"%s"' % subst - l = l[:match.start()] + subst + l[match.end():] + line = line[:match.start()] + subst + line[match.end():] made_change = True - new_lines.append(l) + new_lines.append(line) new_lines.insert(1, "# DO NOT EDIT THIS FILE -- " "it was generated by configure.py\n") new_lines.insert(2, "# %s\n" % (" ".join(sys.argv))) @@ -823,3 +827,24 @@ def check_git_submodules(): print(DASH_SEPARATOR) print("git submodules initialized successfully") print(DASH_SEPARATOR) + + +def check_pybind11(): + try: + import pybind11 # noqa + except ImportError: + print(DASH_SEPARATOR) + print("Pybind11 is not installed.") + print(DASH_SEPARATOR) + print("Very likely, the build process after this message will fail.") + print("") + print("Simply press Ctrl+C and type") + print("python -m pip install pybind11") + print("to fix this. If you don't, the build will continue ") + print("in a few seconds.") + print("") + print("[1] https://pybind11.readthedocs.io/en/stable/") + print(DASH_SEPARATOR) + + from aksetup_helper import count_down_delay + count_down_delay(delay=10) diff --git a/setup.py b/setup.py index 7ece3f95c2eeec0f39020a7e2dcab2f252f6d5df..0f85df28cd20f1dbf27baf7db6b8a2f3ac95b246 100644 --- a/setup.py +++ b/setup.py @@ -161,9 +161,9 @@ def get_config_schema(): Switch("CL_ENABLE_GL", False, "Enable OpenCL<->OpenGL interoperability"), Switch( "CL_USE_SHIPPED_EXT", False, - "Use the pyopencl version of CL/cl_ext.h which includes" + - " a broader range of vendor-specific OpenCL extension attributes" + - " than the standard Khronos (or vendor specific) CL/cl_ext.h."), + "Use the pyopencl version of CL/cl_ext.h which includes" + + " a broader range of vendor-specific OpenCL extension attributes" + + " than the standard Khronos (or vendor specific) CL/cl_ext.h."), Option("CL_PRETEND_VERSION", None, "Dotted CL version (e.g. 1.2) which you'd like to use."), @@ -182,28 +182,10 @@ SEPARATOR = "-"*75 def main(): - try: - import pybind11 # noqa - except ImportError: - print(SEPARATOR) - print("Pybind11 is not installed.") - print(SEPARATOR) - print("Very likely, the build process after this message will fail.") - print("") - print("Simply press Ctrl+C and type") - print("python -m pip install pybind11") - print("to fix this. If you don't, the build will continue ") - print("in a few seconds.") - print("") - print("[1] https://pybind11.readthedocs.io/en/stable/") - print(SEPARATOR) - - from aksetup_helper import count_down_delay - count_down_delay(delay=10) - from setuptools import find_packages from aksetup_helper import (hack_distutils, get_config, setup, - check_git_submodules, NumpyExtension) + check_pybind11, check_git_submodules, NumpyExtension) + check_pybind11() check_git_submodules() hack_distutils()