本文整理汇总了Python中numpy.distutils.misc_util.get_shared_lib_extension函数的典型用法代码示例。如果您正苦于以下问题:Python get_shared_lib_extension函数的具体用法?Python get_shared_lib_extension怎么用?Python get_shared_lib_extension使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_shared_lib_extension函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_get_shared_lib_extension
def test_get_shared_lib_extension(self):
import sys
ext = get_shared_lib_extension(is_python_ext=False)
if sys.platform.startswith('linux'):
assert_equal(ext, '.so')
elif sys.platform.startswith('gnukfreebsd'):
assert_equal(ext, '.so')
elif sys.platform.startswith('darwin'):
assert_equal(ext, '.dylib')
elif sys.platform.startswith('win'):
assert_equal(ext, '.dll')
# just check for no crash
assert_(get_shared_lib_extension(is_python_ext=True))
开发者ID:AlerzDev,项目名称:Brazo-Proyecto-Final,代码行数:13,代码来源:test_misc_util.py
示例2: load_library
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)
try:
import sysconfig
so_ext3 = '.%s-%s.so' % (sysconfig.get_config_var('SOABI'),
sysconfig.get_config_var('MULTIARCH'))
libname_ext.insert(0, libname + so_ext3)
except (KeyError, ImportError):
pass
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")
开发者ID:ArslanRafique,项目名称:dist-packages,代码行数:46,代码来源:ctypeslib.py
示例3: load_library
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]
if sys.version[:3] >= "3.2":
# For Python >= 3.2 a tag may be added to lib extension
# (platform dependent). If we find such a tag, try both with
# and without it.
so_ext2 = get_shared_lib_extension(is_python_ext=True)
if not so_ext2 == so_ext:
libname_ext.insert(0, libname + so_ext2)
if sys.platform == "win32":
libname_ext.insert(0, "%s.dll" % libname)
elif sys.platform == "darwin":
libname_ext.insert(0, "%s.dylib" % libname)
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")
开发者ID:WeatherGod,项目名称:numpy,代码行数:45,代码来源:ctypeslib.py
示例4: load_library
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]
if sys.version[:3] >= '3.2':
# For Python >= 3.2 a tag may be added to lib extension
# (platform dependent). If we find such a tag, try both with
# and without it.
so_ext2 = get_shared_lib_extension(is_python_ext=True)
if not so_ext2 == so_ext:
libname_ext.insert(0, libname + so_ext2)
if sys.platform == 'win32':
libname_ext.insert(0, '%s.dll' % libname)
elif sys.platform == 'darwin':
libname_ext.insert(0, '%s.dylib' % libname)
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
# Need to save exception when using Python 3k, see PEP 3110.
exc = None
for ln in libname_ext:
libpath = os.path.join(libdir, ln)
if os.path.exists(libpath):
try:
return ctypes.cdll[libpath]
except OSError, exc:
## defective lib file
raise exc
开发者ID:loujine,项目名称:numpy,代码行数:44,代码来源:ctypeslib.py
示例5: test_basic2
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)
开发者ID:nforro,项目名称:numpy,代码行数:13,代码来源:test_ctypeslib.py
示例6: test_basic2
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
开发者ID:MrBago,项目名称:numpy,代码行数:14,代码来源:test_ctypeslib.py
示例7: load_library
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
# Need to save exception when using Python 3k, see PEP 3110.
exc = None
for ln in libname_ext:
try:
libpath = os.path.join(libdir, ln)
return ctypes.cdll[libpath]
except OSError as e:
exc = e
raise exc
开发者ID:MolecularFlipbook,项目名称:FlipbookApp,代码行数:37,代码来源:ctypeslib.py
示例8: load_library
def load_library(libname, loader_path):
"""
It is possible to load a library using
>>> lib = ctypes.cdll[<full_path_name>]
But there are cross-platform considerations, such as library file extensions,
plus the fact Windows will just load the first library it finds with that name.
NumPy supplies the load_library function as a convenience.
Parameters
----------
libname : str
Name of the library, which can have 'lib' as a prefix,
but without an extension.
loader_path : str
Where the library can be found.
Returns
-------
ctypes.cdll[libpath] : library object
A ctypes library object
Raises
------
OSError
If there is no library with the expected extension, or the
library is defective and cannot be loaded.
"""
if ctypes.__version__ < '1.0.1':
import warnings
warnings.warn("All features of ctypes interface may not work " \
"with ctypes < 1.0.1", stacklevel=2)
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")
开发者ID:gabriekq,项目名称:Text-pic-Mendonca,代码行数:65,代码来源:ctypeslib.py
示例9: get_lib_extension
def get_lib_extension():
return misc_util.get_shared_lib_extension()
开发者ID:pyroalf,项目名称:pydstool,代码行数:2,代码来源:utils.py
注:本文中的numpy.distutils.misc_util.get_shared_lib_extension函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论