Python numpy.distutils.misc_util.get_shared_lib_extension() Examples
The following are 19
code examples of numpy.distutils.misc_util.get_shared_lib_extension().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
numpy.distutils.misc_util
, or try the search function
.
Example #1
Source File: ctypeslib.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def load_library(libname, loader_path): if ctypes.__version__ < '1.0.1': import warnings warnings.warn("All features of ctypes interface may not work " \ "with ctypes < 1.0.1") ext = os.path.splitext(libname)[1] if not ext: # Try to load library with platform-specific name, otherwise # default to libname.[so|pyd]. Sometimes, these files are built # erroneously on non-linux platforms. from numpy.distutils.misc_util import get_shared_lib_extension so_ext = get_shared_lib_extension() libname_ext = [libname + so_ext] # mac, windows and linux >= py3.2 shared library and loadable # module have different extensions so try both so_ext2 = get_shared_lib_extension(is_python_ext=True) if not so_ext2 == so_ext: libname_ext.insert(0, libname + so_ext2) else: libname_ext = [libname] loader_path = os.path.abspath(loader_path) if not os.path.isdir(loader_path): libdir = os.path.dirname(loader_path) else: libdir = loader_path for ln in libname_ext: libpath = os.path.join(libdir, ln) if os.path.exists(libpath): try: return ctypes.cdll[libpath] except OSError: ## defective lib file raise ## if no successful return in the libname_ext loop: raise OSError("no file with expected extension")
Example #2
Source File: test_ctypeslib.py From keras-lambda with MIT License | 5 votes |
def test_basic2(self): # Regression for #801: load_library with a full library name # (including extension) does not work. try: try: so = get_shared_lib_extension(is_python_ext=True) # Should succeed load_library('multiarray%s' % so, np.core.multiarray.__file__) except ImportError: print("No distutils available, skipping test.") except ImportError as e: msg = ("ctypes is not available on this python: skipping the test" " (import error was: %s)" % str(e)) print(msg)
Example #3
Source File: test_ctypeslib.py From twitter-stock-recommendation with MIT License | 5 votes |
def test_basic2(self): # Regression for #801: load_library with a full library name # (including extension) does not work. try: try: so = get_shared_lib_extension(is_python_ext=True) # Should succeed load_library('multiarray%s' % so, np.core.multiarray.__file__) except ImportError: print("No distutils available, skipping test.") except ImportError as e: msg = ("ctypes is not available on this python: skipping the test" " (import error was: %s)" % str(e)) print(msg)
Example #4
Source File: test_ctypeslib.py From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License | 5 votes |
def test_basic2(self): # Regression for #801: load_library with a full library name # (including extension) does not work. try: try: so = get_shared_lib_extension(is_python_ext=True) # Should succeed load_library('multiarray%s' % so, np.core.multiarray.__file__) except ImportError: print("No distutils available, skipping test.") except ImportError as e: msg = ("ctypes is not available on this python: skipping the test" " (import error was: %s)" % str(e)) print(msg)
Example #5
Source File: test_ctypeslib.py From coffeegrindsize with MIT License | 5 votes |
def test_basic2(self): # Regression for #801: load_library with a full library name # (including extension) does not work. try: try: so = get_shared_lib_extension(is_python_ext=True) # Should succeed load_library('_multiarray_umath%s' % so, np.core._multiarray_umath.__file__) except ImportError: print("No distutils available, skipping test.") except ImportError as e: msg = ("ctypes is not available on this python: skipping the test" " (import error was: %s)" % str(e)) print(msg)
Example #6
Source File: test_ctypeslib.py From elasticintel with GNU General Public License v3.0 | 5 votes |
def test_basic2(self): # Regression for #801: load_library with a full library name # (including extension) does not work. try: try: so = get_shared_lib_extension(is_python_ext=True) # Should succeed load_library('multiarray%s' % so, np.core.multiarray.__file__) except ImportError: print("No distutils available, skipping test.") except ImportError as e: msg = ("ctypes is not available on this python: skipping the test" " (import error was: %s)" % str(e)) print(msg)
Example #7
Source File: test_ctypeslib.py From ImageFusion with MIT License | 5 votes |
def test_basic2(self): """Regression for #801: load_library with a full library name (including extension) does not work.""" try: try: so = get_shared_lib_extension(is_python_ext=True) cdll = load_library('multiarray%s' % so, np.core.multiarray.__file__) except ImportError: print("No distutils available, skipping test.") except ImportError as e: msg = "ctypes is not available on this python: skipping the test" \ " (import error was: %s)" % str(e) print(msg)
Example #8
Source File: ctypeslib.py From ImageFusion with MIT License | 5 votes |
def load_library(libname, loader_path): if ctypes.__version__ < '1.0.1': import warnings warnings.warn("All features of ctypes interface may not work " \ "with ctypes < 1.0.1") ext = os.path.splitext(libname)[1] if not ext: # Try to load library with platform-specific name, otherwise # default to libname.[so|pyd]. Sometimes, these files are built # erroneously on non-linux platforms. from numpy.distutils.misc_util import get_shared_lib_extension so_ext = get_shared_lib_extension() libname_ext = [libname + so_ext] # mac, windows and linux >= py3.2 shared library and loadable # module have different extensions so try both so_ext2 = get_shared_lib_extension(is_python_ext=True) if not so_ext2 == so_ext: libname_ext.insert(0, libname + so_ext2) else: libname_ext = [libname] loader_path = os.path.abspath(loader_path) if not os.path.isdir(loader_path): libdir = os.path.dirname(loader_path) else: libdir = loader_path for ln in libname_ext: libpath = os.path.join(libdir, ln) if os.path.exists(libpath): try: return ctypes.cdll[libpath] except OSError: ## defective lib file raise ## if no successful return in the libname_ext loop: raise OSError("no file with expected extension")
Example #9
Source File: test_ctypeslib.py From mxnet-lambda with Apache License 2.0 | 5 votes |
def test_basic2(self): # Regression for #801: load_library with a full library name # (including extension) does not work. try: try: so = get_shared_lib_extension(is_python_ext=True) # Should succeed load_library('multiarray%s' % so, np.core.multiarray.__file__) except ImportError: print("No distutils available, skipping test.") except ImportError as e: msg = ("ctypes is not available on this python: skipping the test" " (import error was: %s)" % str(e)) print(msg)
Example #10
Source File: test_ctypeslib.py From pySINDy with MIT License | 5 votes |
def test_basic2(self): # Regression for #801: load_library with a full library name # (including extension) does not work. try: try: so = get_shared_lib_extension(is_python_ext=True) # Should succeed load_library('multiarray%s' % so, np.core.multiarray.__file__) except ImportError: print("No distutils available, skipping test.") except ImportError as e: msg = ("ctypes is not available on this python: skipping the test" " (import error was: %s)" % str(e)) print(msg)
Example #11
Source File: test_ctypeslib.py From recruit with Apache License 2.0 | 5 votes |
def test_basic2(self): # Regression for #801: load_library with a full library name # (including extension) does not work. try: try: so = get_shared_lib_extension(is_python_ext=True) # Should succeed load_library('_multiarray_umath%s' % so, np.core._multiarray_umath.__file__) except ImportError: print("No distutils available, skipping test.") except ImportError as e: msg = ("ctypes is not available on this python: skipping the test" " (import error was: %s)" % str(e)) print(msg)
Example #12
Source File: test_ctypeslib.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 5 votes |
def test_basic2(self): # Regression for #801: load_library with a full library name # (including extension) does not work. try: try: so = get_shared_lib_extension(is_python_ext=True) # Should succeed load_library('_multiarray_umath%s' % so, np.core._multiarray_umath.__file__) except ImportError: print("No distutils available, skipping test.") except ImportError as e: msg = ("ctypes is not available on this python: skipping the test" " (import error was: %s)" % str(e)) print(msg)
Example #13
Source File: test_ctypeslib.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def test_basic2(self): # Regression for #801: load_library with a full library name # (including extension) does not work. try: try: so = get_shared_lib_extension(is_python_ext=True) # Should succeed load_library('multiarray%s' % so, np.core.multiarray.__file__) except ImportError: print("No distutils available, skipping test.") except ImportError as e: msg = ("ctypes is not available on this python: skipping the test" " (import error was: %s)" % str(e)) print(msg)
Example #14
Source File: test_ctypeslib.py From Mastering-Elasticsearch-7.0 with MIT License | 5 votes |
def test_basic2(self): # Regression for #801: load_library with a full library name # (including extension) does not work. try: try: so = get_shared_lib_extension(is_python_ext=True) # Should succeed load_library('_multiarray_umath%s' % so, np.core._multiarray_umath.__file__) except ImportError: print("No distutils available, skipping test.") except ImportError as e: msg = ("ctypes is not available on this python: skipping the test" " (import error was: %s)" % str(e)) print(msg)
Example #15
Source File: test_ctypeslib.py From Computable with MIT License | 5 votes |
def test_basic2(self): """Regression for #801: load_library with a full library name (including extension) does not work.""" try: try: so = get_shared_lib_extension(is_python_ext=True) cdll = load_library('multiarray%s' % so, np.core.multiarray.__file__) except ImportError: print("No distutils available, skipping test.") except ImportError as e: msg = "ctypes is not available on this python: skipping the test" \ " (import error was: %s)" % str(e) print(msg)
Example #16
Source File: test_ctypeslib.py From vnpy_crypto with MIT License | 5 votes |
def test_basic2(self): # Regression for #801: load_library with a full library name # (including extension) does not work. try: try: so = get_shared_lib_extension(is_python_ext=True) # Should succeed load_library('multiarray%s' % so, np.core.multiarray.__file__) except ImportError: print("No distutils available, skipping test.") except ImportError as e: msg = ("ctypes is not available on this python: skipping the test" " (import error was: %s)" % str(e)) print(msg)
Example #17
Source File: test_ctypeslib.py From auto-alt-text-lambda-api with MIT License | 5 votes |
def test_basic2(self): # Regression for #801: load_library with a full library name # (including extension) does not work. try: try: so = get_shared_lib_extension(is_python_ext=True) # Should succeed load_library('multiarray%s' % so, np.core.multiarray.__file__) except ImportError: print("No distutils available, skipping test.") except ImportError as e: msg = ("ctypes is not available on this python: skipping the test" " (import error was: %s)" % str(e)) print(msg)
Example #18
Source File: test_ctypeslib.py From lambda-packs with MIT License | 5 votes |
def test_basic2(self): # Regression for #801: load_library with a full library name # (including extension) does not work. try: try: so = get_shared_lib_extension(is_python_ext=True) # Should succeed load_library('multiarray%s' % so, np.core.multiarray.__file__) except ImportError: print("No distutils available, skipping test.") except ImportError as e: msg = ("ctypes is not available on this python: skipping the test" " (import error was: %s)" % str(e)) print(msg)
Example #19
Source File: ctypeslib.py From Computable with MIT License | 4 votes |
def load_library(libname, loader_path): if ctypes.__version__ < '1.0.1': import warnings warnings.warn("All features of ctypes interface may not work " \ "with ctypes < 1.0.1") ext = os.path.splitext(libname)[1] if not ext: # Try to load library with platform-specific name, otherwise # default to libname.[so|pyd]. Sometimes, these files are built # erroneously on non-linux platforms. from numpy.distutils.misc_util import get_shared_lib_extension so_ext = get_shared_lib_extension() libname_ext = [libname + so_ext] # mac, windows and linux >= py3.2 shared library and loadable # module have different extensions so try both so_ext2 = get_shared_lib_extension(is_python_ext=True) if not so_ext2 == so_ext: libname_ext.insert(0, libname + so_ext2) else: libname_ext = [libname] loader_path = os.path.abspath(loader_path) if not os.path.isdir(loader_path): libdir = os.path.dirname(loader_path) else: libdir = loader_path for ln in libname_ext: libpath = os.path.join(libdir, ln) if os.path.exists(libpath): try: return ctypes.cdll[libpath] except OSError: ## defective lib file raise ## if no successful return in the libname_ext loop: raise OSError("no file with expected extension")