Пример #1
0
# "ensure that only a single OpenMP runtime is linked into the process".
#
# https://github.com/llvm-mirror/openmp/blob/8453ca8594e1a5dd8a250c39bf8fcfbfb1760e60/runtime/src/i18n/en_US.txt#L449
# https://github.com/dmlc/xgboost/issues/1715
import os
import sys
os.environ['KMP_DUPLICATE_LIB_OK'] = 'True'
from ctypes import CDLL as _CDLL
from ctypes.util import find_library as _find_library
from pathlib import Path as _Path

from open3d._build_config import _build_config
if _build_config["BUILD_GUI"] and not (_find_library('c++abi')
                                       or _find_library('c++')):
    try:  # Preload libc++.so and libc++abi.so (required by filament)
        _CDLL(str(next((_Path(__file__).parent).glob('*c++abi.*'))))
        _CDLL(str(next((_Path(__file__).parent).glob('*c++.*'))))
    except StopIteration:  # Not found: check system paths while loading
        pass

__DEVICE_API__ = 'cpu'
if _build_config["BUILD_CUDA_MODULE"]:
    # Load CPU pybind dll gracefully without introducing new python variable.
    # Do this before loading the CUDA pybind dll to correctly resolve symbols
    try:  # StopIteration if cpu version not available
        _CDLL(str(next((_Path(__file__).parent / 'cpu').glob('pybind*'))))
    except StopIteration:
        pass
    try:
        # Check CUDA availability without importing CUDA pybind symbols to
        # prevent "symbol already registered" errors if first import fails.
Пример #2
0
def init(dllpath=None, root="C:\\", bypass_check=False):
    """ Initialize the underlying tos-databridge DLL

  dllpath: string of the exact path of the DLL
  root: string of the directory to start walking/searching to find the DLL
  """
    global _dll, _dll_depend1
    rel = set()
    if not bypass_check and dllpath is None and root == "C:\\":
        if abort_init_after_warn():
            return False

    def _remove_older_versions():
        nonlocal rel
        getver = lambda x: _search(_REGEX_VER_SFFX, x).group().strip('-')
        vers = tuple(zip(map(getver, rel), rel))
        vers_max = max(vers)[0].split('.')[0]
        mtup = tuple(( x[0].split('.')[1],x[1]) \
                       for x in vers if x[0].split('.')[0] == vers_max )
        mtup_max = max(mtup)[0]
        rel = set(x[1] for x in mtup if x[0] == mtup_max)

    def _get_depends1_dll_path(dllpath):
        d = _path.dirname(dllpath)
        return d + "/" + DLL_DEPENDS1_NAME + "-" + SYS_ARCH_TYPE + ".dll"

    try:
        if dllpath is None:
            matcher = _partial(_match, _REGEX_DLL_NAME)  # regex match function
            for nfile in map(matcher, _listdir(_curdir)):
                if nfile:  # try the current dir first
                    rel.add(_curdir + _sep + nfile.string)
            if not rel:  # no luck, walk the dir tree
                for root, dirs, files in _walk(root):
                    for file in map(matcher, files):
                        if file:
                            rel.add(root + _sep + file.string)
                if not rel:  # if still nothing throw
                    raise TOSDB_InitError(" could not locate DLL")
            if len(rel) > 1:  # only use the most recent version(s)
                _remove_older_versions()
            # most recently updated
            d = dict(zip(map(lambda x: _stat(x).st_mtime, rel), rel))
            rec = max(d)
            dllpath = d[rec]

        dllpath_depends1 = _get_depends1_dll_path(dllpath)
        _dll_depend1 = _CDLL(dllpath_depends1)
        _dll = _CDLL(dllpath)

        print("+ Using Module(s) ", dllpath)
        print("                  ", dllpath_depends1)
        print("+ Last Update ", _asctime(_localtime(_stat(dllpath).st_mtime)))
        if connect():
            print("+ Succesfully Connected to Service \ Engine")
        else:
            print("- Failed to Connect to Service \ Engine")
        return True  # indicate the lib was loaded (but not if connect succeeded)
    except TOSDB_Error:
        raise
    except Exception as e:
        raise TOSDB_InitError("unable to initialize library", e)
Пример #3
0
def init(dllpath=None, root="C:\\", bypass_check=False):
    """ Initialize the underlying tos-databridge DLL

    dllpath: string of the exact path of the DLL
    root: string of the directory to start walking/searching to find the DLL
    """  
    global _dll, _dll_depend1
    rel = set()
    if not bypass_check and dllpath is None and root == "C:\\":
        if abort_init_after_warn():
            return False

    def _remove_older_versions():
        nonlocal rel  
        getver = lambda x: _search(_REGEX_VER_SFFX,x).group().strip('-')
        vers = tuple(zip(map(getver, rel), rel))
        vers_max = max(vers)[0].split('.')[0]
        mtup = tuple(( x[0].split('.')[1],x[1]) \
                       for x in vers if x[0].split('.')[0] == vers_max )         
        mtup_max = max(mtup)[0]
        rel = set(x[1] for x in mtup if x[0] == mtup_max)

    def _get_depends1_dll_path(dllpath):
        d = _path.dirname(dllpath)
        return d + "/" + DLL_DEPENDS1_NAME + "-" + SYS_ARCH_TYPE + ".dll"
    
    try:   
        if dllpath is None:
            matcher = _partial(_match, _REGEX_DLL_NAME)  
            for nfile in map(matcher, _listdir(_curdir)):
                if nfile: # try the current dir first             
                    rel.add(_curdir+ _sep + nfile.string)                    
            if not rel: # no luck, walk the dir tree              
                for root, dirs, files in _walk(root):  
                    for file in map(matcher, files):  
                        if file:                           
                            rel.add(root + _sep + file.string)                           
                if not rel: # if still nothing throw
                    raise TOSDB_InitError(" could not locate DLL")          
            if len(rel) > 1:  # only use the most recent version(s)
                _remove_older_versions()              
            # most recently updated
            d = dict(zip(map(lambda x: _stat(x).st_mtime, rel), rel)) 
            rec = max(d)
            dllpath = d[rec]

        dllpath_depends1 = _get_depends1_dll_path(dllpath)
        _dll_depend1 = _CDLL(dllpath_depends1)
        _dll = _CDLL(dllpath)
        
        print("+ Using Module(s) ", dllpath)
        print("                  ", dllpath_depends1)
        print("+ Last Update ", _asctime(_localtime(_stat(dllpath).st_mtime)))
        if connect():
            print("+ Succesfully Connected to Service \ Engine")       
        else:
            print("- Failed to Connect to Service \ Engine")
        return True # indicate the lib was loaded (but not if connect succeeded)
    except TOSDB_Error:
        raise
    except Exception as e:
        raise TOSDB_InitError("unable to initialize library", e)        
Пример #4
0
def init(dllpath=None, root="C:\\", bypass_check=False):
    """ Initialize the underlying tos-databridge DLL and try to connect.

    Returns True if library was successfully loaded, not necessarily that
    it was also able to connect. Details are sent to stdout.
    
    init(dllpath=None, root="C:\\", bypass_check=False)
    
    dllpath      :: str  :: exact path of the DLL -or-
    root         :: str  :: directory to start walking/searching to find the DLL
    bypass_check :: bool :: used by virtual layer implemenation (DO NOT SET)

    returns -> bool 

    throws TOSDB_InitError TOSDB_Error
    """
    global _dll, _dll_depend1
    rel = set()
    if not bypass_check and dllpath is None and root == "C:\\":
        if abort_init_after_warn():
            return False

    def _remove_older_versions():
        nonlocal rel
        getver = lambda x: _search(_REGEX_VER_SFFX, x).group().strip('-')
        vers = tuple(zip(map(getver, rel), rel))
        vers_max = max(vers)[0].split('.')[0]
        mtup = tuple(( x[0].split('.')[1],x[1]) \
                       for x in vers if x[0].split('.')[0] == vers_max )
        mtup_max = max(mtup)[0]
        rel = set(x[1] for x in mtup if x[0] == mtup_max)

    def _get_depends1_dll_path(dllpath):
        d = _path.dirname(dllpath)
        dbg = _match(_REGEX_DBG_DLL_PATH, dllpath)
        base = d + "/" + DLL_DEPENDS1_NAME + "-" + SYS_ARCH_TYPE
        path = base + ("_d.dll" if dbg else ".dll")
        return path

    try:
        if dllpath is None:
            matcher = _partial(_match, _REGEX_DLL_NAME)
            for nfile in map(matcher, _listdir(_curdir)):
                if nfile:  # try the current dir first
                    rel.add(_curdir + _sep + nfile.string)
            if not rel:  # no luck, walk the dir tree
                for root, dirs, files in _walk(root):
                    for file in map(matcher, files):
                        if file:
                            rel.add(root + _sep + file.string)
                if not rel:  # if still nothing throw
                    raise TOSDB_InitError(" could not locate DLL")
            if len(rel) > 1:  # only use the most recent version(s)
                _remove_older_versions()
            # most recently updated
            d = dict(zip(map(lambda x: _stat(x).st_mtime, rel), rel))
            rec = max(d)
            dllpath = d[rec]

        dllpath_depends1 = _get_depends1_dll_path(dllpath)
        _dll_depend1 = _CDLL(dllpath_depends1)
        _dll = _CDLL(dllpath)
        print("+ Using Module(s) ", dllpath)
        print("                  ", dllpath_depends1)
        print("+ Last Update:", _asctime(_localtime(_stat(dllpath).st_mtime)))
        print("+ Process ID:", str(_getpid()))
        if connect():
            print("+ Succesfully Connected to Service\Engine")
            if connected():
                print("+ Succesfully Connected to TOS")
            else:
                print("- Failed to Connect to TOS")
        else:
            print("- Failed to Connect to Service\Engine")
            print("- Failed to Connect to TOS")
        return True  # indicate the lib was loaded (but not if connect succeeded)
    except Exception as e:
        raise TOSDB_InitError("unable to initialize library:", e)
Пример #5
0
#
# https://github.com/llvm-mirror/openmp/blob/8453ca8594e1a5dd8a250c39bf8fcfbfb1760e60/runtime/src/i18n/en_US.txt#L449
# https://github.com/dmlc/xgboost/issues/1715
import os
import sys
os.environ['KMP_DUPLICATE_LIB_OK'] = 'True'

__DEVICE_API__ = 'cpu'
from open3d._build_config import _build_config
if _build_config["BUILD_CUDA_MODULE"]:
    # Load CPU pybind dll gracefully without introducing new python variable.
    # Do this before loading the CUDA pybind dll to correctly resolve symbols
    from ctypes import CDLL as _CDLL
    from pathlib import Path as _Path
    try:  # StopIteration if cpu version not available
        _CDLL(next((_Path(__file__).parent / 'cpu').glob('pybind*')))
    except StopIteration:
        pass
    try:
        # Check CUDA availability without importing CUDA pybind symbols to
        # prevent "symbol already registered" errors if first import fails.
        _pybind_cuda = _CDLL(
            next((_Path(__file__).parent / 'cuda').glob('pybind*')))
        if _pybind_cuda.open3d_core_cuda_device_count() > 0:
            from open3d.cuda.pybind import (camera, geometry, io, pipelines,
                                            utility, t)
            from open3d.cuda import pybind
            __DEVICE_API__ = 'cuda'
    except OSError:  # CUDA not installed
        pass
    except StopIteration:  # pybind cuda library not available
Пример #6
0
# other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#

from ctypes import CDLL as _CDLL, RTLD_GLOBAL as _RTLD_GLOBAL, c_int32 as _c_int32, pointer as _pointer, c_char_p as _c_char_p
_x = _CDLL('libXt.so', _RTLD_GLOBAL)
_x = _CDLL('libXm.so', _RTLD_GLOBAL)
_x = _CDLL('libXpm.so', _RTLD_GLOBAL)
_x = _CDLL('libXinerama.so', _RTLD_GLOBAL)
_x = _CDLL('librt.so', _RTLD_GLOBAL)
try:
    _x = _CDLL('libtermcap.so', _RTLD_GLOBAL)
except:
    _x = _CDLL('libtinfo.so', _RTLD_GLOBAL)
_x = _CDLL('libgcc_s.so.1', _RTLD_GLOBAL)
_idl = _CDLL('libidl.so')
_zero = _c_int32(0)
_idl.IDL_Init(_c_int32(32768 | 64), _pointer(_zero), _c_int32(0))


def idl(command):