예제 #1
0
파일: util.py 프로젝트: yzh119/taichi
def import_ti_core(tmp_dir=None):
    global ti_core
    if get_os_name() != 'win':
        old_flags = sys.getdlopenflags()
        sys.setdlopenflags(258)  # 258 = RTLD_NOW | RTLD_GLOBAL
    else:
        pyddir = os.path.join(package_root(), 'lib')
        os.environ['PATH'] += ';' + pyddir
    try:
        import taichi_core as core
    except Exception as e:
        if isinstance(e, ImportError):
            print(
                Fore.YELLOW + "Share object taichi_core import failed, "
                "check this page for possible solutions:\n"
                "https://taichi.readthedocs.io/en/stable/install.html#troubleshooting"
                + Fore.RESET)
        raise e
    ti_core = core
    if get_os_name() != 'win':
        sys.setdlopenflags(old_flags)
    lib_dir = os.path.join(package_root(), 'lib')
    core.set_lib_dir(locale_encode(lib_dir))
    if tmp_dir is not None:
        core.set_tmp_dir(locale_encode(tmp_dir))
예제 #2
0
def import_ti_core(tmp_dir=None):
    global ti_core
    if settings.get_os_name() != 'win':
        old_flags = sys.getdlopenflags()
        sys.setdlopenflags(2 | 8)  # RTLD_NOW | RTLD_DEEPBIND
    else:
        pyddir = os.path.join(package_root(), 'lib')
        os.environ['PATH'] += ';' + pyddir
    try:
        import taichi_core as core
    except Exception as e:
        if isinstance(e, ImportError):
            print(
                Fore.YELLOW + "Share object taichi_core import failed, "
                "check this page for possible solutions:\n"
                "https://taichi.readthedocs.io/en/stable/install.html#troubleshooting"
                + Fore.RESET)
            if settings.get_os_name() == 'win':
                e.msg += '\nConsider installing Microsoft Visual C++ Redistributable: https://aka.ms/vs/16/release/vc_redist.x64.exe'
            elif settings.get_os_name() == 'linux':
                e.msg += '\nConsider installing libtinfo5: sudo apt-get install libtinfo5'
        raise e from None
    ti_core = core
    if settings.get_os_name() != 'win':
        sys.setdlopenflags(old_flags)
    lib_dir = os.path.join(package_root(), 'lib')
    core.set_lib_dir(locale_encode(lib_dir))
    if tmp_dir is not None:
        core.set_tmp_dir(locale_encode(tmp_dir))
예제 #3
0
파일: util.py 프로젝트: zixzeus/taichi
def import_tc_core(tmp_dir=None):
  global tc_core
  if get_os_name() != 'win':
    old_flags = sys.getdlopenflags()
    sys.setdlopenflags(258)  # 258 = RTLD_NOW | RTLD_GLOBAL
  else:
    pyddir = os.path.join(package_root(), 'lib')
    os.environ['PATH'] += ';' + pyddir
  try:
    import taichi_core as core
  except Exception as e:
    if isinstance(e, ImportError):
      print("Share object taichi_core import failed. If you are on Windows, please consider installing \"Microsoft Visual C++ Redistributable\" (https://aka.ms/vs/16/release/vc_redist.x64.exe)")
    raise e
  tc_core = core
  if get_os_name() != 'win':
    sys.setdlopenflags(old_flags)
  lib_dir = os.path.join(package_root(), 'lib')
  core.set_lib_dir(locale_encode(lib_dir))
  if tmp_dir is not None:
    core.set_tmp_dir(locale_encode(tmp_dir))