def delete_old_compiled_extensions(): pydev_dir = os.path.dirname(os.path.dirname(__file__)) _pydevd_bundle_dir = os.path.dirname(__file__) _pydevd_frame_eval_dir = os.path.join(pydev_dir, '_pydevd_frame_eval') try: import shutil for file in os.listdir(_pydevd_bundle_dir): if file.startswith("pydevd") and file.endswith(".so"): os.remove(os.path.join(_pydevd_bundle_dir, file)) for file in os.listdir(_pydevd_frame_eval_dir): if file.startswith("pydevd") and file.endswith(".so"): os.remove(os.path.join(_pydevd_frame_eval_dir, file)) build_dir = os.path.join(pydev_dir, "build") if os.path.exists(build_dir): shutil.rmtree(os.path.join(pydev_dir, "build")) except OSError: from _pydev_bundle.pydev_monkey import log_error_once log_error_once("warning: failed to delete old cython speedups. Please delete all *.so files from the directories " "\"%s\" and \"%s\"" % (_pydevd_bundle_dir, _pydevd_frame_eval_dir))
elif use_cython is None: # Regular: use fallback if not found and give message to user try: from _pydevd_bundle.pydevd_cython_wrapper import trace_dispatch as _trace_dispatch, global_cache_skips, global_cache_frame_skips def trace_dispatch(py_db, frame, event, arg): return _trace_dispatch(py_db, frame, event, arg) # This version number is always available from _pydevd_bundle.pydevd_additional_thread_info_regular import version as regular_version # This version number from the already compiled cython extension from _pydevd_bundle.pydevd_cython_wrapper import version as cython_version if cython_version != regular_version: delete_old_compiled_extensions() raise ImportError() except ImportError: from _pydevd_bundle.pydevd_additional_thread_info_regular import PyDBAdditionalThreadInfo # @UnusedImport from _pydevd_bundle.pydevd_trace_dispatch_regular import trace_dispatch, global_cache_skips, global_cache_frame_skips # @UnusedImport from _pydev_bundle.pydev_monkey import log_error_once log_error_once( "warning: Debugger speedups using cython not found. Run '\"%s\" \"%s\" build_ext --inplace' to build." % (sys.executable, os.path.join(dirname, 'setup_cython.py'))) else: raise RuntimeError( 'Unexpected value for PYDEVD_USE_CYTHON: %s (accepted: YES, NO)' % (use_cython, ))
show_frame_eval_warning = False clear_thread_local_info = None # "NO" means we should not use frame evaluation, 'YES' we should use it (and fail if not there) and unspecified uses if possible. use_frame_eval = os.environ.get('PYDEVD_USE_FRAME_EVAL', None) if use_frame_eval == 'NO': pass elif use_frame_eval == 'YES': # Fail if unable to use from _pydevd_frame_eval.pydevd_frame_eval_cython_wrapper import frame_eval_func, stop_frame_eval, dummy_trace_dispatch, clear_thread_local_info elif use_frame_eval is None: # Try to use if possible if IS_PY36_OR_GREATER: try: from _pydevd_frame_eval.pydevd_frame_eval_cython_wrapper import frame_eval_func, stop_frame_eval, dummy_trace_dispatch, clear_thread_local_info except ImportError: from _pydev_bundle.pydev_monkey import log_error_once dirname = os.path.dirname(os.path.dirname(__file__)) if not IS_PYCHARM: log_error_once("warning: Debugger speedups using cython not found. Run '\"%s\" \"%s\" build_ext --inplace' to build." % ( sys.executable, os.path.join(dirname, 'setup_cython.py'))) else: show_frame_eval_warning = True else: raise RuntimeError('Unexpected value for PYDEVD_USE_FRAME_EVAL: %s (accepted: YES, NO)' % (use_frame_eval,))
frame_eval_func = None stop_frame_eval = None dummy_trace_dispatch = None show_frame_eval_warning = False clear_thread_local_info = None # "NO" means we should not use frame evaluation, 'YES' we should use it (and fail if not there) and unspecified uses if possible. use_frame_eval = os.environ.get('PYDEVD_USE_FRAME_EVAL', None) use_cython = os.getenv('PYDEVD_USE_CYTHON', None) if not IS_PY36_OR_GREATER: pass elif use_cython == 'NO': log_error_once( "warning: PYDEVD_USE_CYTHON environment variable is set to 'NO'. " "Frame evaluator will be also disabled because it requires Cython extensions to be enabled in order to operate correctly." ) else: if use_frame_eval == 'NO': pass elif use_frame_eval == 'YES': try: import _pydevd_bundle.pydevd_cython_wrapper except ImportError: # Frame evaluator doesn't work without the Cython speedups. pass else: # Fail if unable to use from _pydevd_frame_eval.pydevd_frame_eval_cython_wrapper import frame_eval_func, stop_frame_eval, dummy_trace_dispatch, clear_thread_local_info
# We must import the cython version if forcing cython from _pydevd_bundle.pydevd_cython_wrapper import trace_dispatch as _trace_dispatch def trace_dispatch(py_db, frame, event, arg): return _trace_dispatch(py_db, frame, event, arg) elif use_cython == 'NO': # Use the regular version if not forcing cython from _pydevd_bundle.pydevd_trace_dispatch_regular import trace_dispatch # @UnusedImport elif use_cython is None: # Regular: use fallback if not found and give message to user try: from _pydevd_bundle.pydevd_cython_wrapper import trace_dispatch as _trace_dispatch def trace_dispatch(py_db, frame, event, arg): return _trace_dispatch(py_db, frame, event, arg) except ImportError: from _pydevd_bundle.pydevd_additional_thread_info_regular import PyDBAdditionalThreadInfo # @UnusedImport from _pydevd_bundle.pydevd_trace_dispatch_regular import trace_dispatch # @UnusedImport from _pydevd_bundle.pydevd_constants import CYTHON_SUPPORTED if CYTHON_SUPPORTED: from _pydev_bundle.pydev_monkey import log_error_once log_error_once('warning: Debugger speedups using cython not found. Run "python %s build_ext --inplace" to build.' % ( os.path.join(os.path.dirname(os.path.dirname(__file__)), 'setup_cython.py'))) else: raise RuntimeError('Unexpected value for PYDEVD_USE_CYTHON: %s (accepted: YES, NO)' % (use_cython,))
return _trace_dispatch(py_db, frame, event, arg) elif use_cython == 'NO': # Use the regular version if not forcing cython from _pydevd_bundle.pydevd_trace_dispatch_regular import trace_dispatch # @UnusedImport elif use_cython is None: # Regular: use fallback if not found and give message to user try: from _pydevd_bundle.pydevd_cython_wrapper import trace_dispatch as _trace_dispatch def trace_dispatch(py_db, frame, event, arg): return _trace_dispatch(py_db, frame, event, arg) except ImportError: from _pydevd_bundle.pydevd_additional_thread_info_regular import PyDBAdditionalThreadInfo # @UnusedImport from _pydevd_bundle.pydevd_trace_dispatch_regular import trace_dispatch # @UnusedImport from _pydevd_bundle.pydevd_constants import CYTHON_SUPPORTED if CYTHON_SUPPORTED: from _pydev_bundle.pydev_monkey import log_error_once log_error_once( 'warning: Debugger speedups using cython not found. Run "python %s build_ext --inplace" to build.' % (os.path.join(os.path.dirname(os.path.dirname(__file__)), 'setup_cython.py'))) else: raise RuntimeError( 'Unexpected value for PYDEVD_USE_CYTHON: %s (accepted: YES, NO)' % (use_cython, ))