1#!/usr/bin/env python3 2""" 3# Created: Mon Jun 20 15:12:00 2022 (-0400) 4# @author: Jacob Faibussowitsch 5""" 6import sys 7 8# synchronized print function, should be used everywhere 9sync_print = print 10 11from .__version__ import __MIN_PYTHON_VERSION__, version_tuple, version_str 12 13if sys.version_info < __MIN_PYTHON_VERSION__: 14 raise ImportError('Need python ' + version_str() + '+') 15 16del __MIN_PYTHON_VERSION__ 17 18try: 19 import clang.cindex # type: ignore[import] 20except ModuleNotFoundError as mnfe: 21 if mnfe.name == 'clang': 22 raise RuntimeError('Must run e.g. \'python3 -m pip install clang\' to use linter') from mnfe 23 raise # whatever it is they should know about it 24 25 26def __lazy_import(name, package=None): 27 """ 28 Lazily import the module NAME, it is loaded but not fully imported until an attribute of it is 29 accessed 30 """ 31 import importlib 32 import importlib.util 33 34 spec = importlib.util.find_spec(name, package=package) 35 loader = spec.loader 36 spec.loader = importlib.util.LazyLoader(loader) 37 module = importlib.util.module_from_spec(spec) 38 sys.modules[name] = module 39 loader.exec_module(module) 40 return module 41 42from ._error import * 43 44# order is important to avoid circular imports 45from . import util 46from . import checks 47from . import _typing as typing 48# if all else fails, try the lazy import 49# util = __lazy_import('.util', package='petsclinter') 50from .classes import * 51 52# these should not be exposed 53del __lazy_import 54