from __future__ import print_function, division, absolute_import
import sys
import os
import warnings


def _readenv(name, ctor, default):
    try:
        res = os.environ[name]
    except KeyError:
        return default
    else:
        try:
            return ctor(res)
        except:
            warnings.warn("environ %s defined but failed to parse '%s'" %
                          (name, res), RuntimeWarning)
            return default


# Debug flag to control compiler debug print
DEBUG = _readenv("NUMBA_DEBUG", int, 0)

# JIT Debug flag to trigger IR instruction print
DEBUG_JIT = _readenv("NUMBA_DEBUG_JIT", int, 0)

# Optimization level
OPT = _readenv("NUMBA_OPT", int, 3)

# Force dump of LLVM IR
DUMP_LLVM = _readenv("NUMBA_DUMP_LLVM", int, DEBUG)

# Force dump of Function optimized LLVM IR
NUMBA_DUMP_FUNC_OPT = _readenv("NUMBA_DUMP_FUNC_OPT", int, DEBUG)

# Force dump of Optimized LLVM IR
DUMP_OPTIMIZED = _readenv("NUMBA_DUMP_OPTIMIZED", int, DEBUG)

# Force dump of generated assembly
DUMP_ASSEMBLY = _readenv("NUMBA_DUMP_ASSEMBLY", int, DEBUG)

# Force dump of type annotation
ANNOTATE = _readenv("NUMBA_DUMP_ANNOTATION", int, 0)

# Python version in (major, minor) tuple
PYVERSION = sys.version_info[:2]

# Disable CUDA support
DISABLE_CUDA = _readenv("NUMBA_DISABLE_CUDA", int, 0)


@@ -483,24 +483,25 @@
 debug print%0A
+#
 DEBUG = _rea
@@ -523,24 +523,64 @@
 UG%22, int, 0)
+%0ADEBUG = _readenv(%22NUMBA_DEBUG%22, int, 1)
 %0A%0A# JIT Debu
@@ -618,16 +618,17 @@
 n print%0A
+#
 DEBUG_JI
@@ -662,24 +662,72 @@
 IT%22, int, 0)
+%0ADEBUG_JIT = _readenv(%22NUMBA_DEBUG_JIT%22, int, 1)
 %0A%0A# Optimiza
@@ -1186,16 +1186,17 @@
 otation%0A
+#
 ANNOTATE
@@ -1239,16 +1239,69 @@
  int, 0)
+%0AANNOTATE = _readenv(%22NUMBA_DUMP_ANNOTATION%22, int, 1)
 %0A%0A# Pyth

set config to debug mode