1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220
|
# -*- coding: utf-8 -*-
########################################################################
#
# License: BSD
# Created: October 1, 2002
# Author: Francesc Alted - faltet@pytables.com
#
# $Id$
#
########################################################################
"""PyTables, hierarchical datasets in Python.
:URL: http://www.pytables.org/
PyTables is a package for managing hierarchical datasets and designed
to efficiently cope with extremely large amounts of data.
"""
from __future__ import absolute_import
import os
# On Windows, pre-load the HDF5 DLLs into the process via Ctypes
# to improve diagnostics and avoid issues when loading DLLs during runtime.
if os.name == 'nt':
import ctypes
def _load_library(dllname, loadfunction, dllpaths=('', )):
"""Load a DLL via ctypes load function. Return None on failure.
By default, try to load the DLL from the current package
directory first, then from the Windows DLL search path.
"""
try:
dllpaths = (os.path.abspath(
os.path.dirname(__file__)), ) + dllpaths
except NameError:
pass # PyPy and frozen distributions have no __file__ attribute
for path in dllpaths:
if path:
# Temporarily add the path to the PATH environment variable
# so Windows can find additional DLL dependencies.
try:
oldenv = os.environ['PATH']
os.environ['PATH'] = path + ';' + oldenv
except KeyError:
oldenv = None
try:
return loadfunction(os.path.join(path, dllname))
except WindowsError:
pass
finally:
if path and oldenv is not None:
os.environ['PATH'] = oldenv
return None
# In order to improve diagnosis of a common Windows dependency
# issue, we explicitly test that we can load the HDF5 dll before
# loading tables.utilsextensions.
import sys
hdf5_dlls = ['hdf5.dll', 'hdf5dll.dll']
if hasattr(sys, 'gettotalrefcount'): # running with debug interpreter
hdf5_dlls = ['hdf5_D.dll', 'hdf5ddll.dll']
for dll in hdf5_dlls:
if _load_library(dll, ctypes.cdll.LoadLibrary):
break
else:
raise ImportError(
'Could not load any of %s, please ensure'
' that it can be found in the system path' % hdf5_dlls)
# Some PyTables binary distributions place the dependency DLLs in the
# tables package directory.
# The lzo2 and libbz2 DLLs are loaded dynamically at runtime but can't be
# found because the package directory is not in the Windows DLL search
# path.
# This pre-loads lzo2 and libbz2 DLLs from the tables package directory.
if not _load_library('lzo2.dll', ctypes.cdll.LoadLibrary):
pass
if not _load_library('libbz2.dll', ctypes.cdll.LoadLibrary):
pass
# Necessary imports to get versions stored on the cython extension
from .utilsextension import (
get_pytables_version, get_hdf5_version, blosc_compressor_list,
blosc_compcode_to_compname_ as blosc_compcode_to_compname,
blosc_get_complib_info_ as blosc_get_complib_info)
__version__ = get_pytables_version()
"""The PyTables version number."""
hdf5_version = get_hdf5_version()
"""The underlying HDF5 library version number.
.. versionadded:: 3.0
"""
hdf5Version = hdf5_version
"""The underlying HDF5 library version number.
.. deprecated:: 3.0
hdf5Version is pending deprecation, use :data:`hdf5_version`
instead.
"""
from .utilsextension import (is_hdf5_file, is_pytables_file,
which_lib_version, set_blosc_max_threads,
silence_hdf5_messages)
from .misc.enum import Enum
from .atom import *
from .flavor import restrict_flavors
from .description import *
from .filters import Filters
# Import the user classes from the proper modules
from .exceptions import *
from .file import File, open_file, copy_file
from .node import Node
from .group import Group
from .leaf import Leaf
from .table import Table, Cols, Column
from .array import Array
from .carray import CArray
from .earray import EArray
from .vlarray import VLArray
from .unimplemented import UnImplemented, Unknown
from .expression import Expr
from .tests import print_versions, test
# List here only the objects we want to be publicly available
__all__ = [
# Exceptions and warnings:
'HDF5ExtError',
'ClosedNodeError', 'ClosedFileError', 'FileModeError',
'NaturalNameWarning', 'NodeError', 'NoSuchNodeError',
'UndoRedoError', 'UndoRedoWarning',
'PerformanceWarning',
'FlavorError', 'FlavorWarning',
'FiltersWarning', 'DataTypeWarning',
# Functions:
'is_hdf5_file', 'is_pytables_file', 'which_lib_version',
'copy_file', 'open_file', 'print_versions', 'test',
'split_type', 'restrict_flavors', 'set_blosc_max_threads',
'silence_hdf5_messages',
# Helper classes:
'IsDescription', 'Description', 'Filters', 'Cols', 'Column',
# Types:
'Enum',
# Atom types:
'Atom', 'StringAtom', 'BoolAtom',
'IntAtom', 'UIntAtom', 'Int8Atom', 'UInt8Atom', 'Int16Atom', 'UInt16Atom',
'Int32Atom', 'UInt32Atom', 'Int64Atom', 'UInt64Atom',
'FloatAtom', 'Float32Atom', 'Float64Atom',
'ComplexAtom', 'Complex32Atom', 'Complex64Atom', 'Complex128Atom',
'TimeAtom', 'Time32Atom', 'Time64Atom',
'EnumAtom',
'PseudoAtom', 'ObjectAtom', 'VLStringAtom', 'VLUnicodeAtom',
# Column types:
'Col', 'StringCol', 'BoolCol',
'IntCol', 'UIntCol', 'Int8Col', 'UInt8Col', 'Int16Col', 'UInt16Col',
'Int32Col', 'UInt32Col', 'Int64Col', 'UInt64Col',
'FloatCol', 'Float32Col', 'Float64Col',
'ComplexCol', 'Complex32Col', 'Complex64Col', 'Complex128Col',
'TimeCol', 'Time32Col', 'Time64Col',
'EnumCol',
# Node classes:
'Node', 'Group', 'Leaf', 'Table', 'Array', 'CArray', 'EArray', 'VLArray',
'UnImplemented', 'Unknown',
# The File class:
'File',
# Expr class
'Expr',
]
if 'Float16Atom' in locals():
# float16 is new in numpy 1.6.0
__all__.extend(('Float16Atom', 'Float16Col'))
from .utilsextension import _broken_hdf5_long_double
if not _broken_hdf5_long_double():
if 'Float96Atom' in locals():
__all__.extend(('Float96Atom', 'Float96Col'))
__all__.extend(('Complex192Atom', 'Complex192Col')) # XXX check
if 'Float128Atom' in locals():
__all__.extend(('Float128Atom', 'Float128Col'))
__all__.extend(('Complex256Atom', 'Complex256Col')) # XXX check
else:
from . import atom as _atom
from . import description as _description
try:
del _atom.Float96Atom, _atom.Complex192Col
del _description.Float96Col, _description.Complex192Col
_atom.all_types.discard('complex192')
_atom.ComplexAtom._isizes.remove(24)
except AttributeError:
try:
del _atom.Float128Atom, _atom.Complex256Atom
del _description.Float128Col, _description.Complex256Col
_atom.all_types.discard('complex256')
_atom.ComplexAtom._isizes.remove(32)
except AttributeError:
pass
del _atom, _description
del _broken_hdf5_long_double
|