[h5py] 125/455: Move all HDF5/stdlib defines into one pxd; new init mechanism, general cleanup
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Thu Jul 2 18:19:24 UTC 2015
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to annotated tag 1.3.0
in repository h5py.
commit d6b3d16d7a898d72b22daffedc3a600d4e8da4f6
Author: andrewcollette <andrew.collette at gmail.com>
Date: Tue Sep 23 03:58:27 2008 +0000
Move all HDF5/stdlib defines into one pxd; new init mechanism, general cleanup
---
h5py/defs.pxd | 1154 +++++++++++++++++++++++++++++++++++++++
h5py/h5.pxd | 128 +----
h5py/h5.pyx | 160 +++---
h5py/h5a.pxd | 31 +-
h5py/h5a.pyx | 26 +-
h5py/h5d.pxd | 87 +--
h5py/h5d.pyx | 33 +-
h5py/h5f.pxd | 64 +--
h5py/h5f.pyx | 24 +-
h5py/h5fd.pxd | 2 +-
h5py/h5fd.pyx | 6 +
h5py/h5g.pxd | 83 +--
h5py/h5g.pyx | 24 +-
h5py/h5i.pxd | 37 +-
h5py/h5i.pyx | 13 +-
h5py/h5l.pxd | 107 +---
h5py/h5l.pyx | 14 +-
h5py/h5o.pxd | 79 +--
h5py/h5o.pyx | 8 +-
h5py/h5p.pxd | 155 +-----
h5py/h5p.pyx | 24 +-
h5py/h5r.pxd | 30 +-
h5py/h5r.pyx | 10 +-
h5py/h5s.pxd | 95 +---
h5py/h5s.pyx | 16 +-
h5py/h5t.pxd | 241 +-------
h5py/h5t.pyx | 21 +-
h5py/h5z.pxd | 50 +-
h5py/h5z.pyx | 13 +-
h5py/std_defs.pxi | 74 ---
h5py/{std_code.pxi => sync.pxi} | 11 +-
h5py/utils.pxd | 4 +-
h5py/utils.pyx | 13 +-
setup.py | 35 +-
34 files changed, 1431 insertions(+), 1441 deletions(-)
diff --git a/h5py/defs.pxd b/h5py/defs.pxd
new file mode 100644
index 0000000..f9e76bd
--- /dev/null
+++ b/h5py/defs.pxd
@@ -0,0 +1,1154 @@
+#+
+#
+# This file is part of h5py, a low-level Python interface to the HDF5 library.
+#
+# Copyright (C) 2008 Andrew Collette
+# http://h5py.alfven.org
+# License: BSD (See LICENSE.txt for full license)
+#
+# $Date$
+#
+#-
+
+# This file provides all external libraries for h5py.
+
+include "config.pxi" # Needed for H5PY_*API defines
+
+# === Standard C library types and functions ==================================
+
+cdef extern from "stdlib.h":
+ ctypedef long size_t
+ void *malloc(size_t size)
+ void free(void *ptr)
+
+cdef extern from "string.h":
+ char *strchr(char *s, int c)
+ char *strcpy(char *dest, char *src)
+ char *strncpy(char *dest, char *src, size_t n)
+ int strcmp(char *s1, char *s2)
+ char *strdup(char *s)
+ void *memcpy(void *dest, void *src, size_t n)
+
+cdef extern from "time.h":
+ ctypedef int time_t
+
+cdef extern from "unistd.h":
+ ctypedef long ssize_t
+
+cdef extern from "stdint.h":
+ ctypedef signed char int8_t
+ ctypedef unsigned char uint8_t
+ ctypedef signed int int16_t
+ ctypedef unsigned int uint16_t
+ ctypedef signed long int int32_t
+ ctypedef unsigned long int uint32_t
+ ctypedef signed long long int int64_t
+ ctypedef signed long long int uint64_t
+
+# === H5 - Common definitions and library functions ===========================
+
+cdef extern from "hdf5.h":
+
+ # Basic types
+ ctypedef int hid_t
+ ctypedef int hbool_t
+ ctypedef int herr_t
+ ctypedef int htri_t
+ ctypedef long long hsize_t
+ ctypedef signed long long hssize_t
+ ctypedef signed long long haddr_t
+
+ ctypedef struct hvl_t:
+ size_t len # Length of VL data (in base type units)
+ void *p # Pointer to VL data
+
+ int HADDR_UNDEF
+
+ # H5 API
+ herr_t H5open() except *
+ herr_t H5close() except *
+
+ herr_t H5get_libversion(unsigned *majnum, unsigned *minnum,
+ unsigned *relnum ) except *
+
+
+# === H5E - Error handling API ================================================
+
+cdef extern from "hdf5.h":
+
+ # Major error numbers
+ ctypedef enum H5E_major_t:
+ H5E_NONE_MAJOR = 0, # special zero, no error
+ H5E_ARGS, # invalid arguments to routine
+ H5E_RESOURCE, # resource unavailable
+ H5E_INTERNAL, # Internal error (too specific to document)
+ H5E_FILE, # file Accessability
+ H5E_IO, # Low-level I/O
+ H5E_FUNC, # function Entry/Exit
+ H5E_ATOM, # object Atom
+ H5E_CACHE, # object Cache
+ H5E_BTREE, # B-Tree Node
+ H5E_SYM, # symbol Table
+ H5E_HEAP, # Heap
+ H5E_OHDR, # object Header
+ H5E_DATATYPE, # Datatype
+ H5E_DATASPACE, # Dataspace
+ H5E_DATASET, # Dataset
+ H5E_STORAGE, # data storage
+ H5E_PLIST, # Property lists
+ H5E_ATTR, # Attribute
+ H5E_PLINE, # Data filters
+ H5E_EFL, # External file list
+ H5E_REFERENCE, # References
+ H5E_VFL, # Virtual File Layer
+# H5E_TBBT, # Threaded, Balanced, Binary Trees (not in 1.8)
+ H5E_TST, # Ternary Search Trees
+ H5E_RS, # Reference Counted Strings
+ H5E_ERROR, # Error API
+ H5E_SLIST # Skip Lists
+
+ # This is not useful since 1.8.X
+ ctypedef enum H5E_minor_t:
+ pass
+
+ cdef enum H5E_direction_t:
+ H5E_WALK_UPWARD = 0 # begin deep, end at API function
+ H5E_WALK_DOWNWARD = 1 # begin at API function, end deep
+
+ ctypedef struct H5E_error_t:
+ H5E_major_t maj_num # major error number
+ H5E_minor_t min_num # minor error number
+ char *func_name # function in which error occurred
+ char *file_name # file in which error occurred
+ unsigned line # line in file where error occurs
+ char *desc # optional supplied description
+
+ char *H5Eget_major(H5E_major_t n)
+ char *H5Eget_minor(H5E_minor_t n)
+ herr_t H5Eclear() except *
+
+ ctypedef herr_t (*H5E_auto_t)(void *client_data)
+ herr_t H5Eset_auto(H5E_auto_t func, void *client_data)
+ herr_t H5Eget_auto(H5E_auto_t *func, void** client_data)
+
+ ctypedef herr_t (*H5E_walk_t)(int n, H5E_error_t *err_desc, void* client_data)
+ herr_t H5Ewalk(H5E_direction_t direction, H5E_walk_t func, void* client_data)
+
+
+# === H5A - Attributes API ====================================================
+
+cdef extern from "hdf5.h":
+
+ hid_t H5Acreate(hid_t loc_id, char *name, hid_t type_id, hid_t space_id, hid_t create_plist) except *
+ hid_t H5Aopen_idx(hid_t loc_id, unsigned int idx) except *
+ hid_t H5Aopen_name(hid_t loc_id, char *name) except *
+ herr_t H5Aclose(hid_t attr_id) except *
+ herr_t H5Adelete(hid_t loc_id, char *name) except *
+
+ herr_t H5Aread(hid_t attr_id, hid_t mem_type_id, void *buf) except *
+ herr_t H5Awrite(hid_t attr_id, hid_t mem_type_id, void *buf ) except *
+
+ int H5Aget_num_attrs(hid_t loc_id) except *
+ ssize_t H5Aget_name(hid_t attr_id, size_t buf_size, char *buf) except *
+ hid_t H5Aget_space(hid_t attr_id) except *
+ hid_t H5Aget_type(hid_t attr_id) except *
+
+ ctypedef herr_t (*H5A_operator_t)(hid_t loc_id, char *attr_name, operator_data) except -1
+ herr_t H5Aiterate(hid_t loc_id, unsigned * idx, H5A_operator_t op, op_data) except *
+
+
+# === H5D - Dataset API =======================================================
+
+cdef extern from "hdf5.h":
+
+ # HDF5 layouts
+ ctypedef enum H5D_layout_t:
+ H5D_LAYOUT_ERROR = -1,
+ H5D_COMPACT = 0, # raw data is very small
+ H5D_CONTIGUOUS = 1, # the default
+ H5D_CHUNKED = 2, # slow and fancy
+ H5D_NLAYOUTS = 3 # this one must be last!
+
+ ctypedef enum H5D_alloc_time_t:
+ H5D_ALLOC_TIME_ERROR =-1,
+ H5D_ALLOC_TIME_DEFAULT =0,
+ H5D_ALLOC_TIME_EARLY =1,
+ H5D_ALLOC_TIME_LATE =2,
+ H5D_ALLOC_TIME_INCR =3
+
+ ctypedef enum H5D_space_status_t:
+ H5D_SPACE_STATUS_ERROR =-1,
+ H5D_SPACE_STATUS_NOT_ALLOCATED =0,
+ H5D_SPACE_STATUS_PART_ALLOCATED =1,
+ H5D_SPACE_STATUS_ALLOCATED =2
+
+ ctypedef enum H5D_fill_time_t:
+ H5D_FILL_TIME_ERROR =-1,
+ H5D_FILL_TIME_ALLOC =0,
+ H5D_FILL_TIME_NEVER =1,
+ H5D_FILL_TIME_IFSET =2
+
+ ctypedef enum H5D_fill_value_t:
+ H5D_FILL_VALUE_ERROR =-1,
+ H5D_FILL_VALUE_UNDEFINED =0,
+ H5D_FILL_VALUE_DEFAULT =1,
+ H5D_FILL_VALUE_USER_DEFINED =2
+
+ hid_t H5Dcreate(hid_t loc, char* name, hid_t type_id, hid_t space_id,
+ hid_t create_plist_id) except *
+ hid_t H5Dopen(hid_t file_id, char *name) except *
+ herr_t H5Dclose(hid_t dset_id) except *
+
+ hid_t H5Dget_space(hid_t dset_id) except *
+ herr_t H5Dget_space_status(hid_t dset_id,
+ H5D_space_status_t *status) except *
+ hid_t H5Dget_type(hid_t dset_id) except *
+ hid_t H5Dget_create_plist(hid_t dataset_id) except *
+
+ haddr_t H5Dget_offset(hid_t dset_id) except *
+ hsize_t H5Dget_storage_size(hid_t dset_id) except? 0
+
+ # These must have their return values checked manually. The functions
+ # H5PY_H5Dread and H5PY_HDwrite return -1 specifically, for use when
+ # the GIL is released and PyErr_Occurred() is inadvisable.
+ herr_t H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id,
+ hid_t file_space_id, hid_t plist_id, void *buf) nogil
+ herr_t H5Dwrite(hid_t dset_id, hid_t mem_type, hid_t mem_space, hid_t
+ file_space, hid_t xfer_plist, void* buf) nogil
+
+ herr_t H5Dextend(hid_t dataset_id, hsize_t *size) except *
+
+ herr_t H5Dfill(void *fill, hid_t fill_type_id, void *buf,
+ hid_t buf_type_id, hid_t space_id ) except *
+ herr_t H5Dvlen_get_buf_size(hid_t dset_id, hid_t type_id,
+ hid_t space_id, hsize_t *size) except *
+ herr_t H5Dvlen_reclaim(hid_t type_id, hid_t space_id,
+ hid_t plist, void *buf) except *
+ ctypedef herr_t (*H5D_operator_t)(void *elem, hid_t type_id, unsigned ndim,
+ hsize_t *point, void *operator_data)
+ herr_t H5Diterate(void *buf, hid_t type_id, hid_t space_id,
+ H5D_operator_t operator, void* operator_data) except *
+
+
+# === H5F - File API ==========================================================
+
+cdef extern from "hdf5.h":
+
+ # File constants
+ cdef enum:
+ H5F_ACC_TRUNC
+ H5F_ACC_RDONLY
+ H5F_ACC_RDWR
+ H5F_ACC_EXCL
+ H5F_ACC_DEBUG
+ H5F_ACC_CREAT
+
+ # The difference between a single file and a set of mounted files
+ cdef enum H5F_scope_t:
+ H5F_SCOPE_LOCAL = 0, # specified file handle only
+ H5F_SCOPE_GLOBAL = 1, # entire virtual file
+ H5F_SCOPE_DOWN = 2 # for internal use only
+
+ cdef enum H5F_close_degree_t:
+ H5F_CLOSE_WEAK = 0,
+ H5F_CLOSE_SEMI = 1,
+ H5F_CLOSE_STRONG = 2,
+ H5F_CLOSE_DEFAULT = 3
+
+ int H5F_OBJ_FILE
+ int H5F_OBJ_DATASET
+ int H5F_OBJ_GROUP
+ int H5F_OBJ_DATATYPE
+ int H5F_OBJ_ATTR
+ int H5F_OBJ_ALL
+ int H5F_OBJ_LOCAL
+
+ hid_t H5Fcreate(char *filename, unsigned int flags,
+ hid_t create_plist, hid_t access_plist) except *
+ hid_t H5Fopen(char *name, unsigned flags, hid_t access_id) except *
+ herr_t H5Fclose (hid_t file_id) except *
+ htri_t H5Fis_hdf5(char *name) except *
+ herr_t H5Fflush(hid_t object_id, H5F_scope_t scope) except *
+
+ hid_t H5Freopen(hid_t file_id) except *
+ herr_t H5Fmount(hid_t loc_id, char *name, hid_t child_id, hid_t plist_id) except *
+ herr_t H5Funmount(hid_t loc_id, char *name) except *
+ herr_t H5Fget_filesize(hid_t file_id, hsize_t *size) except *
+ hid_t H5Fget_create_plist(hid_t file_id ) except *
+ hid_t H5Fget_access_plist(hid_t file_id) except *
+ hssize_t H5Fget_freespace(hid_t file_id) except *
+ ssize_t H5Fget_name(hid_t obj_id, char *name, size_t size) except *
+ int H5Fget_obj_count(hid_t file_id, unsigned int types) except *
+ int H5Fget_obj_ids(hid_t file_id, unsigned int types, int max_objs, hid_t *obj_id_list) except *
+
+
+# === H5FD - Low-level file descriptor API ====================================
+
+cdef extern from "hdf5.h":
+
+ ctypedef enum H5FD_mem_t:
+ H5FD_MEM_NOLIST = -1,
+ H5FD_MEM_DEFAULT = 0,
+ H5FD_MEM_SUPER = 1,
+ H5FD_MEM_BTREE = 2,
+ H5FD_MEM_DRAW = 3,
+ H5FD_MEM_GHEAP = 4,
+ H5FD_MEM_LHEAP = 5,
+ H5FD_MEM_OHDR = 6,
+ H5FD_MEM_NTYPES
+
+ # HDF5 uses a clever scheme wherein these are actually init() calls
+ # Hopefully Pyrex won't have a problem with this.
+ # Thankfully they are defined but -1 if unavailable
+ hid_t H5FD_CORE
+ hid_t H5FD_FAMILY
+# hid_t H5FD_GASS not in 1.8.X
+ hid_t H5FD_LOG
+ hid_t H5FD_MPIO
+ hid_t H5FD_MULTI
+ hid_t H5FD_SEC2
+ hid_t H5FD_STDIO
+
+ int H5FD_LOG_LOC_READ # 0x0001
+ int H5FD_LOG_LOC_WRITE # 0x0002
+ int H5FD_LOG_LOC_SEEK # 0x0004
+ int H5FD_LOG_LOC_IO # (H5FD_LOG_LOC_READ|H5FD_LOG_LOC_WRITE|H5FD_LOG_LOC_SEEK)
+
+ # Flags for tracking number of times each byte is read/written
+ int H5FD_LOG_FILE_READ # 0x0008
+ int H5FD_LOG_FILE_WRITE # 0x0010
+ int H5FD_LOG_FILE_IO # (H5FD_LOG_FILE_READ|H5FD_LOG_FILE_WRITE)
+
+ # Flag for tracking "flavor" (type) of information stored at each byte
+ int H5FD_LOG_FLAVOR # 0x0020
+
+ # Flags for tracking total number of reads/writes/seeks
+ int H5FD_LOG_NUM_READ # 0x0040
+ int H5FD_LOG_NUM_WRITE # 0x0080
+ int H5FD_LOG_NUM_SEEK # 0x0100
+ int H5FD_LOG_NUM_IO # (H5FD_LOG_NUM_READ|H5FD_LOG_NUM_WRITE|H5FD_LOG_NUM_SEEK)
+
+ # Flags for tracking time spent in open/read/write/seek/close
+ int H5FD_LOG_TIME_OPEN # 0x0200 # Not implemented yet
+ int H5FD_LOG_TIME_READ # 0x0400 # Not implemented yet
+ int H5FD_LOG_TIME_WRITE # 0x0800 # Partially implemented (need to track total time)
+ int H5FD_LOG_TIME_SEEK # 0x1000 # Partially implemented (need to track total time & track time for seeks during reading)
+ int H5FD_LOG_TIME_CLOSE # 0x2000 # Fully implemented
+ int H5FD_LOG_TIME_IO # (H5FD_LOG_TIME_OPEN|H5FD_LOG_TIME_READ|H5FD_LOG_TIME_WRITE|H5FD_LOG_TIME_SEEK|H5FD_LOG_TIME_CLOSE)
+
+ # Flag for tracking allocation of space in file
+ int H5FD_LOG_ALLOC # 0x4000
+ int H5FD_LOG_ALL # (H5FD_LOG_ALLOC|H5FD_LOG_TIME_IO|H5FD_LOG_NUM_IO|H5FD_LOG_FLAVOR|H5FD_LOG_FILE_IO|H5FD_LOG_LOC_IO)
+
+
+# === H5G - Groups API ========================================================
+
+cdef extern from "hdf5.h":
+
+ ctypedef enum H5G_link_t:
+ H5G_LINK_ERROR = -1,
+ H5G_LINK_HARD = 0,
+ H5G_LINK_SOFT = 1
+
+ cdef enum H5G_obj_t:
+ H5G_UNKNOWN = -1, # Unknown object type
+ H5G_LINK, # Object is a symbolic link
+ H5G_GROUP, # Object is a group
+ H5G_DATASET, # Object is a dataset
+ H5G_TYPE, # Object is a named data type
+
+ ctypedef struct H5G_stat_t:
+ unsigned long fileno[2]
+ unsigned long objno[2]
+ unsigned int nlink
+ H5G_obj_t type # new in HDF5 1.6
+ time_t mtime
+ size_t linklen
+ #H5O_stat_t ohdr # Object header information. New in HDF5 1.6
+
+ hid_t H5Gcreate(hid_t loc_id, char *name, size_t size_hint ) except *
+ hid_t H5Gopen(hid_t loc_id, char *name ) except *
+ herr_t H5Gclose(hid_t group_id) except *
+ herr_t H5Glink2( hid_t curr_loc_id, char *current_name,
+ H5G_link_t link_type, hid_t new_loc_id, char *new_name ) except *
+
+ herr_t H5Gunlink (hid_t file_id, char *name) except *
+ herr_t H5Gmove2(hid_t src_loc_id, char *src_name,
+ hid_t dst_loc_id, char *dst_name ) except *
+ herr_t H5Gget_num_objs(hid_t loc_id, hsize_t* num_obj) except *
+ int H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char *name, size_t size ) except *
+ int H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx ) except *
+
+ ctypedef herr_t (*H5G_iterate_t)(hid_t group, char *name, op_data) except -1
+ herr_t H5Giterate(hid_t loc_id, char *name, int *idx, H5G_iterate_t operator, operator_data ) except *
+ herr_t H5Gget_objinfo(hid_t loc_id, char* name, int follow_link, H5G_stat_t *statbuf) except *
+
+ herr_t H5Gget_linkval(hid_t loc_id, char *name, size_t size, char *value) except *
+ herr_t H5Gset_comment(hid_t loc_id, char *name, char *comment ) except *
+ int H5Gget_comment(hid_t loc_id, char *name, size_t bufsize, char *comment ) except *
+
+ # New extensions in 1.8.X
+ IF H5PY_18API:
+ ctypedef enum H5G_storage_type_t:
+ H5G_STORAGE_TYPE_UNKNOWN = -1,
+ H5G_STORAGE_TYPE_SYMBOL_TABLE,
+ H5G_STORAGE_TYPE_COMPACT,
+ H5G_STORAGE_TYPE_DENSE
+
+ ctypedef struct H5G_info_t:
+ H5G_storage_type_t storage_type
+ hsize_t nlinks
+ long int max_corder # FIXME: not really long int
+
+ hid_t H5Gcreate_anon( hid_t loc_id, hid_t gcpl_id, hid_t gapl_id ) except *
+ hid_t H5Gcreate2(hid_t loc_id, char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id) except *
+ hid_t H5Gopen2( hid_t loc_id, char * name, hid_t gapl_id ) except *
+ herr_t H5Gget_info( hid_t group_id, H5G_info_t *group_info ) except *
+ herr_t H5Gget_info_by_name( hid_t loc_id, char *group_name, H5G_info_t *group_info, hid_t lapl_id ) except *
+
+
+# === H5I - Identifier and reflection interface ===============================
+
+cdef extern from "hdf5.h":
+
+ ctypedef enum H5I_type_t:
+ H5I_BADID = -1, # invalid Group
+ H5I_FILE = 1, # group ID for File objects
+ H5I_GROUP, # group ID for Group objects
+ H5I_DATATYPE, # group ID for Datatype objects
+ H5I_DATASPACE, # group ID for Dataspace objects
+ H5I_DATASET, # group ID for Dataset objects
+ H5I_ATTR, # group ID for Attribute objects
+ H5I_REFERENCE, # group ID for Reference objects
+ H5I_VFL, # group ID for virtual file layer
+ H5I_GENPROP_CLS, # group ID for generic property list classes
+ H5I_GENPROP_LST, # group ID for generic property lists
+ H5I_NGROUPS # number of valid groups, MUST BE LAST!
+
+ H5I_type_t H5Iget_type(hid_t obj_id) except *
+ ssize_t H5Iget_name( hid_t obj_id, char *name, size_t size) except *
+ hid_t H5Iget_file_id(hid_t obj_id) except *
+ int H5Idec_ref(hid_t obj_id) except *
+ int H5Iget_ref(hid_t obj_id) except *
+ int H5Iinc_ref(hid_t obj_id) except *
+
+
+# === H5L - Links interface (1.8.X only) ======================================
+
+IF H5PY_18API:
+
+ cdef extern from "hdf5.h":
+
+ # TODO: put both versions in h5t.pxd
+ ctypedef enum H5T_cset_t:
+ H5T_CSET_ERROR = -1, #
+ H5T_CSET_ASCII = 0, # US ASCII
+ H5T_CSET_UTF8 = 1, # UTF-8 Unicode encoding
+
+ unsigned int H5L_MAX_LINK_NAME_LEN # ((uint32_t) (-1)) (4GB - 1)
+
+ # Link class types.
+ # * Values less than 64 are reserved for the HDF5 library's internal use.
+ # * Values 64 to 255 are for "user-defined" link class types; these types are
+ # * defined by HDF5 but their behavior can be overridden by users.
+ # * Users who want to create new classes of links should contact the HDF5
+ # * development team at hdfhelp at ncsa.uiuc.edu .
+ # * These values can never change because they appear in HDF5 files.
+ #
+ ctypedef enum H5L_type_t:
+ H5L_TYPE_ERROR = (-1), # Invalid link type id
+ H5L_TYPE_HARD = 0, # Hard link id
+ H5L_TYPE_SOFT = 1, # Soft link id
+ H5L_TYPE_EXTERNAL = 64, # External link id
+ H5L_TYPE_MAX = 255 # Maximum link type id
+
+ # Information struct for link (for H5Lget_info/H5Lget_info_by_idx)
+ cdef union _add_u:
+ haddr_t address # Address hard link points to
+ size_t val_size # Size of a soft link or UD link value
+
+ ctypedef struct H5L_info_t:
+ H5L_type_t type # Type of link
+ hbool_t corder_valid # Indicate if creation order is valid
+ int64_t corder # Creation order
+ H5T_cset_t cset # Character set of link name
+ _add_u u
+
+ # Prototype for H5Literate/H5Literate_by_name() operator
+ ctypedef herr_t (*H5L_iterate_t) (hid_t group, char *name, H5L_info_t *info,
+ void *op_data)
+
+ ctypedef enum H5_index_t:
+ H5_INDEX_NAME,
+ H5_INDEX_CRT_ORDER
+
+ ctypedef enum H5_iter_order_t:
+ H5_ITER_INC, # Increasing order
+ H5_ITER_DEC, # Decreasing order
+ H5_ITER_NATIVE # Fastest available order
+
+ # API
+
+ herr_t H5Lmove(hid_t src_loc, char *src_name, hid_t dst_loc,
+ char *dst_name, hid_t lcpl_id, hid_t lapl_id) except *
+
+ herr_t H5Lcopy(hid_t src_loc, char *src_name, hid_t dst_loc,
+ char *dst_name, hid_t lcpl_id, hid_t lapl_id) except *
+
+ herr_t H5Lcreate_hard(hid_t cur_loc, char *cur_name,
+ hid_t dst_loc, char *dst_name, hid_t lcpl_id, hid_t lapl_id) except *
+
+ herr_t H5Lcreate_soft(char *link_target, hid_t link_loc_id,
+ char *link_name, hid_t lcpl_id, hid_t lapl_id) except *
+
+ herr_t H5Ldelete(hid_t loc_id, char *name, hid_t lapl_id) except *
+
+ herr_t H5Ldelete_by_idx(hid_t loc_id, char *group_name,
+ H5_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t lapl_id) except *
+
+ herr_t H5Lget_val(hid_t loc_id, char *name, void *bufout,
+ size_t size, hid_t lapl_id) except *
+
+ herr_t H5Lget_val_by_idx(hid_t loc_id, char *group_name,
+ H5_index_t idx_type, H5_iter_order_t order, hsize_t n,
+ void *bufout, size_t size, hid_t lapl_id) except *
+
+ htri_t H5Lexists(hid_t loc_id, char *name, hid_t lapl_id) except *
+
+ herr_t H5Lget_info(hid_t loc_id, char *name,
+ H5L_info_t *linfo, hid_t lapl_id) except *
+
+ herr_t H5Lget_info_by_idx(hid_t loc_id, char *group_name,
+ H5_index_t idx_type, H5_iter_order_t order, hsize_t n,
+ H5L_info_t *linfo, hid_t lapl_id) except *
+
+ ssize_t H5Lget_name_by_idx(hid_t loc_id, char *group_name,
+ H5_index_t idx_type, H5_iter_order_t order, hsize_t n,
+ char *name, size_t size, hid_t lapl_id) except *
+
+ herr_t H5Literate(hid_t grp_id, H5_index_t idx_type,
+ H5_iter_order_t order, hsize_t *idx, H5L_iterate_t op, void *op_data) except *
+
+ herr_t H5Literate_by_name(hid_t loc_id, char *group_name,
+ H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx,
+ H5L_iterate_t op, void *op_data, hid_t lapl_id) except *
+
+ herr_t H5Lvisit(hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order,
+ H5L_iterate_t op, void *op_data) except *
+
+ herr_t H5Lvisit_by_name(hid_t loc_id, char *group_name,
+ H5_index_t idx_type, H5_iter_order_t order, H5L_iterate_t op,
+ void *op_data, hid_t lapl_id) except *
+
+# === H5O - General object operations (1.8.X only) ============================
+
+IF H5PY_18API:
+ cdef extern from "hdf5.h":
+
+ ctypedef enum H5O_type_t:
+ H5O_TYPE_UNKNOWN = -1, # Unknown object type
+ H5O_TYPE_GROUP, # Object is a group
+ H5O_TYPE_DATASET, # Object is a dataset
+ H5O_TYPE_NAMED_DATATYPE, # Object is a named data type
+ H5O_TYPE_NTYPES # Number of different object types (must be last!)
+
+ # --- Components for the H5O_info_t struct ----------------------------------
+
+ cdef struct space:
+ hsize_t total # Total space for storing object header in file
+ hsize_t meta # Space within header for object header metadata information
+ hsize_t mesg # Space within header for actual message information
+ hsize_t free # Free space within object header
+
+ cdef struct mesg:
+ unsigned long present # Flags to indicate presence of message type in header
+ unsigned long shared # Flags to indicate message type is shared in header
+
+ cdef struct hdr:
+ unsigned version # Version number of header format in file
+ unsigned nmesgs # Number of object header messages
+ unsigned nchunks # Number of object header chunks
+ unsigned flags # Object header status flags
+ space space
+ mesg mesg
+
+ ctypedef struct H5_ih_info_t:
+ hsize_t index_size, # /* btree and/or list */
+ hsize_t heap_size
+
+ cdef struct meta_size:
+ H5_ih_info_t obj, # /* v1/v2 B-tree & local/fractal heap for groups, B-tree for chunked datasets */
+ H5_ih_info_t attr # /* v2 B-tree & heap for attributes */
+
+ ctypedef struct H5O_info_t:
+ unsigned long fileno # File number that object is located in
+ haddr_t addr # Object address in file
+ H5O_type_t type # Basic object type (group, dataset, etc.)
+ unsigned rc # Reference count of object
+ time_t atime # Access time
+ time_t mtime # Modification time
+ time_t ctime # Change time
+ time_t btime # Birth time
+ hsize_t num_attrs # # of attributes attached to object
+ hdr hdr
+ meta_size meta_size
+
+ ctypedef enum H5_index_t:
+ H5_INDEX_NAME,
+ H5_INDEX_CRT_ORDER
+
+ ctypedef enum H5_iter_order_t:
+ H5_ITER_INC, # Increasing order
+ H5_ITER_DEC, # Decreasing order
+ H5_ITER_NATIVE # Fastest available order
+
+ ctypedef herr_t (*H5O_iterate_t)(hid_t obj, char *name, H5O_info_t *info,
+ void *op_data)
+
+ herr_t H5Ovisit(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order,
+ H5O_iterate_t op, void *op_data) except *
+
+ herr_t H5Oget_info(hid_t loc_id, H5O_info_t *oinfo) except *
+
+# === H5P - Property list API =================================================
+
+cdef extern from "hdf5.h":
+
+ int H5P_DEFAULT
+
+ ctypedef int H5Z_filter_t
+
+ # HDF5 layouts
+ ctypedef enum H5D_layout_t:
+ H5D_LAYOUT_ERROR = -1,
+ H5D_COMPACT = 0, # raw data is very small
+ H5D_CONTIGUOUS = 1, # the default
+ H5D_CHUNKED = 2, # slow and fancy
+ H5D_NLAYOUTS = 3 # this one must be last!
+
+ ctypedef enum H5D_alloc_time_t:
+ H5D_ALLOC_TIME_ERROR =-1,
+ H5D_ALLOC_TIME_DEFAULT =0,
+ H5D_ALLOC_TIME_EARLY =1,
+ H5D_ALLOC_TIME_LATE =2,
+ H5D_ALLOC_TIME_INCR =3
+
+ ctypedef enum H5D_space_status_t:
+ H5D_SPACE_STATUS_ERROR =-1,
+ H5D_SPACE_STATUS_NOT_ALLOCATED =0,
+ H5D_SPACE_STATUS_PART_ALLOCATED =1,
+ H5D_SPACE_STATUS_ALLOCATED =2
+
+ ctypedef enum H5D_fill_time_t:
+ H5D_FILL_TIME_ERROR =-1,
+ H5D_FILL_TIME_ALLOC =0,
+ H5D_FILL_TIME_NEVER =1,
+ H5D_FILL_TIME_IFSET =2
+
+ ctypedef enum H5D_fill_value_t:
+ H5D_FILL_VALUE_ERROR =-1,
+ H5D_FILL_VALUE_UNDEFINED =0,
+ H5D_FILL_VALUE_DEFAULT =1,
+ H5D_FILL_VALUE_USER_DEFINED =2
+
+ cdef enum H5Z_EDC_t:
+ H5Z_ERROR_EDC = -1,
+ H5Z_DISABLE_EDC = 0,
+ H5Z_ENABLE_EDC = 1,
+ H5Z_NO_EDC = 2
+
+ cdef enum H5F_close_degree_t:
+ H5F_CLOSE_WEAK = 0,
+ H5F_CLOSE_SEMI = 1,
+ H5F_CLOSE_STRONG = 2,
+ H5F_CLOSE_DEFAULT = 3
+
+ ctypedef enum H5FD_mem_t:
+ H5FD_MEM_NOLIST = -1,
+ H5FD_MEM_DEFAULT = 0,
+ H5FD_MEM_SUPER = 1,
+ H5FD_MEM_BTREE = 2,
+ H5FD_MEM_DRAW = 3,
+ H5FD_MEM_GHEAP = 4,
+ H5FD_MEM_LHEAP = 5,
+ H5FD_MEM_OHDR = 6,
+ H5FD_MEM_NTYPES
+
+ # Property list classes
+ hid_t H5P_NO_CLASS
+ hid_t H5P_FILE_CREATE
+ hid_t H5P_FILE_ACCESS
+ hid_t H5P_DATASET_CREATE
+ hid_t H5P_DATASET_XFER
+
+ # General operations
+ hid_t H5Pcreate(hid_t plist_id) except *
+ hid_t H5Pcopy(hid_t plist_id) except *
+ int H5Pget_class(hid_t plist_id) except *
+ herr_t H5Pclose(hid_t plist_id) except *
+ htri_t H5Pequal( hid_t id1, hid_t id2 ) except *
+ herr_t H5Pclose_class(hid_t id) except *
+
+ # File creation properties
+ herr_t H5Pget_version(hid_t plist, unsigned int *super_, unsigned int* freelist,
+ unsigned int *stab, unsigned int *shhdr) except *
+ herr_t H5Pset_userblock(hid_t plist, hsize_t size) except *
+ herr_t H5Pget_userblock(hid_t plist, hsize_t * size) except *
+ herr_t H5Pset_sizes(hid_t plist, size_t sizeof_addr, size_t sizeof_size) except *
+ herr_t H5Pget_sizes(hid_t plist, size_t *sizeof_addr, size_t *sizeof_size) except *
+ herr_t H5Pset_sym_k(hid_t plist, unsigned int ik, unsigned int lk) except *
+ herr_t H5Pget_sym_k(hid_t plist, unsigned int *ik, unsigned int *lk) except *
+ herr_t H5Pset_istore_k(hid_t plist, unsigned int ik) except *
+ herr_t H5Pget_istore_k(hid_t plist, unsigned int *ik) except *
+
+ # File access
+ herr_t H5Pset_fclose_degree(hid_t fapl_id, H5F_close_degree_t fc_degree) except *
+ herr_t H5Pget_fclose_degree(hid_t fapl_id, H5F_close_degree_t *fc_degree) except *
+ herr_t H5Pset_fapl_core( hid_t fapl_id, size_t increment, hbool_t backing_store) except *
+ herr_t H5Pget_fapl_core( hid_t fapl_id, size_t *increment, hbool_t *backing_store) except *
+ herr_t H5Pset_fapl_family ( hid_t fapl_id, hsize_t memb_size, hid_t memb_fapl_id ) except *
+ herr_t H5Pget_fapl_family ( hid_t fapl_id, hsize_t *memb_size, hid_t *memb_fapl_id ) except *
+ herr_t H5Pset_family_offset ( hid_t fapl_id, hsize_t offset) except *
+ herr_t H5Pget_family_offset ( hid_t fapl_id, hsize_t *offset) except *
+ herr_t H5Pset_fapl_log(hid_t fapl_id, char *logfile, unsigned int flags, size_t buf_size) except *
+ herr_t H5Pset_fapl_multi(hid_t fapl_id, H5FD_mem_t *memb_map, hid_t *memb_fapl,
+ char **memb_name, haddr_t *memb_addr, hbool_t relax)
+ herr_t H5Pset_cache(hid_t plist_id, int mdc_nelmts, int rdcc_nelmts,
+ size_t rdcc_nbytes, double rdcc_w0) except *
+ herr_t H5Pget_cache(hid_t plist_id, int *mdc_nelmts, int *rdcc_nelmts,
+ size_t *rdcc_nbytes, double *rdcc_w0) except *
+ herr_t H5Pset_fapl_sec2(hid_t fapl_id) except *
+ herr_t H5Pset_fapl_stdio(hid_t fapl_id) except *
+ hid_t H5Pget_driver(hid_t fapl_id) except *
+
+ # Dataset creation properties
+ herr_t H5Pset_layout(hid_t plist, int layout) except *
+ H5D_layout_t H5Pget_layout(hid_t plist) except *
+ herr_t H5Pset_chunk(hid_t plist, int ndims, hsize_t * dim) except *
+ int H5Pget_chunk(hid_t plist, int max_ndims, hsize_t * dims ) except *
+ herr_t H5Pset_deflate( hid_t plist, int level) except *
+ herr_t H5Pset_fill_value(hid_t plist_id, hid_t type_id, void *value ) except *
+ herr_t H5Pget_fill_value(hid_t plist_id, hid_t type_id, void *value ) except *
+ herr_t H5Pfill_value_defined(hid_t plist_id, H5D_fill_value_t *status ) except *
+ herr_t H5Pset_fill_time(hid_t plist_id, H5D_fill_time_t fill_time ) except *
+ herr_t H5Pget_fill_time(hid_t plist_id, H5D_fill_time_t *fill_time ) except *
+ herr_t H5Pset_alloc_time(hid_t plist_id, H5D_alloc_time_t alloc_time ) except *
+ herr_t H5Pget_alloc_time(hid_t plist_id, H5D_alloc_time_t *alloc_time ) except *
+ herr_t H5Pset_filter(hid_t plist, H5Z_filter_t filter, unsigned int flags,
+ size_t cd_nelmts, unsigned int cd_values[] ) except *
+ htri_t H5Pall_filters_avail(hid_t dcpl_id) except *
+ int H5Pget_nfilters(hid_t plist) except *
+ H5Z_filter_t H5Pget_filter(hid_t plist, unsigned int filter_number,
+ unsigned int *flags, size_t *cd_nelmts,
+ unsigned int *cd_values, size_t namelen, char name[] ) except *
+ herr_t H5Pget_filter_by_id( hid_t plist_id, H5Z_filter_t filter,
+ unsigned int *flags, size_t *cd_nelmts,
+ unsigned int cd_values[], size_t namelen, char name[]) except *
+ herr_t H5Pmodify_filter(hid_t plist, H5Z_filter_t filter, unsigned int flags,
+ size_t cd_nelmts, unsigned int cd_values[] ) except *
+ herr_t H5Premove_filter(hid_t plist, H5Z_filter_t filter ) except *
+ herr_t H5Pset_fletcher32(hid_t plist) except *
+ herr_t H5Pset_shuffle(hid_t plist_id) except *
+ herr_t H5Pset_szip(hid_t plist, unsigned int options_mask, unsigned int pixels_per_block) except *
+
+
+ # Transfer properties
+ herr_t H5Pset_edc_check(hid_t plist, H5Z_EDC_t check) except *
+ H5Z_EDC_t H5Pget_edc_check(hid_t plist) except *
+
+ # Other properties
+ herr_t H5Pset_sieve_buf_size(hid_t fapl_id, hsize_t size) except *
+ herr_t H5Pset_fapl_log(hid_t fapl_id, char *logfile,
+ unsigned int flags, size_t buf_size) except *
+
+
+# === H5R - Reference API =====================================================
+
+cdef extern from "hdf5.h":
+
+ size_t H5R_DSET_REG_REF_BUF_SIZE
+ size_t H5R_OBJ_REF_BUF_SIZE
+
+ ctypedef enum H5R_type_t:
+ H5R_BADTYPE = (-1),
+ H5R_OBJECT,
+ H5R_DATASET_REGION,
+ H5R_INTERNAL,
+ H5R_MAXTYPE
+
+ ctypedef haddr_t hobj_ref_t
+ ctypedef unsigned char hdset_reg_ref_t[12]
+
+ herr_t H5Rcreate(void *ref, hid_t loc_id, char *name, H5R_type_t ref_type,
+ hid_t space_id) except *
+ hid_t H5Rdereference(hid_t obj_id, H5R_type_t ref_type, void *ref) except *
+ hid_t H5Rget_region(hid_t dataset, H5R_type_t ref_type, void *ref) except *
+ H5G_obj_t H5Rget_obj_type(hid_t id, H5R_type_t ref_type, void *ref) except *
+
+
+# === H5S - Dataspaces ========================================================
+
+cdef extern from "hdf5.h":
+
+ int H5S_ALL, H5S_MAX_RANK
+ hsize_t H5S_UNLIMITED
+
+ # Codes for defining selections
+ ctypedef enum H5S_seloper_t:
+ H5S_SELECT_NOOP = -1,
+ H5S_SELECT_SET = 0,
+ H5S_SELECT_OR,
+ H5S_SELECT_AND,
+ H5S_SELECT_XOR,
+ H5S_SELECT_NOTB,
+ H5S_SELECT_NOTA,
+ H5S_SELECT_APPEND,
+ H5S_SELECT_PREPEND,
+ H5S_SELECT_INVALID # Must be the last one
+
+ ctypedef enum H5S_class_t:
+ H5S_NO_CLASS = -1, #/*error */
+ H5S_SCALAR = 0, #/*scalar variable */
+ H5S_SIMPLE = 1, #/*simple data space */
+ # no longer defined in 1.8
+ #H5S_COMPLEX = 2 #/*complex data space */
+
+ ctypedef enum H5S_sel_type:
+ H5S_SEL_ERROR = -1, #/* Error */
+ H5S_SEL_NONE = 0, #/* Nothing selected */
+ H5S_SEL_POINTS = 1, #/* Sequence of points selected */
+ H5S_SEL_HYPERSLABS = 2, #/* "New-style" hyperslab selection defined */
+ H5S_SEL_ALL = 3, #/* Entire extent selected */
+ H5S_SEL_N = 4 #/*THIS MUST BE LAST */
+
+
+ # Basic operations
+ hid_t H5Screate(H5S_class_t type) except *
+ hid_t H5Scopy(hid_t space_id ) except *
+ herr_t H5Sclose(hid_t space_id) except *
+
+ # Simple dataspace operations
+ hid_t H5Screate_simple(int rank, hsize_t dims[], hsize_t maxdims[]) except *
+ htri_t H5Sis_simple(hid_t space_id) except *
+ herr_t H5Soffset_simple(hid_t space_id, hssize_t *offset ) except *
+
+ int H5Sget_simple_extent_ndims(hid_t space_id) except *
+ int H5Sget_simple_extent_dims(hid_t space_id, hsize_t dims[], hsize_t maxdims[]) except *
+ hssize_t H5Sget_simple_extent_npoints(hid_t space_id) except *
+ H5S_class_t H5Sget_simple_extent_type(hid_t space_id) except *
+
+ # Extents
+ herr_t H5Sextent_copy(hid_t dest_space_id, hid_t source_space_id ) except *
+ herr_t H5Sset_extent_simple(hid_t space_id, int rank,
+ hsize_t *current_size, hsize_t *maximum_size ) except *
+ herr_t H5Sset_extent_none(hid_t space_id) except *
+
+ # Dataspace selection
+ H5S_sel_type H5Sget_select_type(hid_t space_id) except *
+ hssize_t H5Sget_select_npoints(hid_t space_id) except *
+ herr_t H5Sget_select_bounds(hid_t space_id, hsize_t *start, hsize_t *end) except *
+
+ herr_t H5Sselect_all(hid_t space_id) except *
+ herr_t H5Sselect_none(hid_t space_id) except *
+ htri_t H5Sselect_valid(hid_t space_id) except *
+
+ hssize_t H5Sget_select_elem_npoints(hid_t space_id) except *
+ herr_t H5Sget_select_elem_pointlist(hid_t space_id, hsize_t startpoint,
+ hsize_t numpoints, hsize_t *buf) except *
+ herr_t H5Sselect_elements(hid_t space_id, H5S_seloper_t op,
+ size_t num_elements, hsize_t **coord) except *
+
+ hssize_t H5Sget_select_hyper_nblocks(hid_t space_id ) except *
+ herr_t H5Sget_select_hyper_blocklist(hid_t space_id,
+ hsize_t startblock, hsize_t numblocks, hsize_t *buf ) except *
+ herr_t H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op,
+ hsize_t start[], hsize_t _stride[],
+ hsize_t count[], hsize_t _block[]) except *
+
+ IF H5PY_18API:
+ herr_t H5Sencode(hid_t obj_id, void *buf, size_t *nalloc)
+ hid_t H5Sdecode(void *buf)
+
+
+# === H5T - Datatypes =========================================================
+
+cdef extern from "hdf5.h":
+
+ hid_t H5P_DEFAULT
+
+ # --- Enumerated constants --------------------------------------------------
+
+ # Byte orders
+ ctypedef enum H5T_order_t:
+ H5T_ORDER_ERROR = -1, # error
+ H5T_ORDER_LE = 0, # little endian
+ H5T_ORDER_BE = 1, # bit endian
+ H5T_ORDER_VAX = 2, # VAX mixed endian
+ H5T_ORDER_NONE = 3 # no particular order (strings, bits,..)
+
+ # HDF5 signed enums
+ ctypedef enum H5T_sign_t:
+ H5T_SGN_ERROR = -1, # error
+ H5T_SGN_NONE = 0, # this is an unsigned type
+ H5T_SGN_2 = 1, # two's complement
+ H5T_NSGN = 2 # this must be last!
+
+ ctypedef enum H5T_norm_t:
+ H5T_NORM_ERROR = -1,
+ H5T_NORM_IMPLIED = 0,
+ H5T_NORM_MSBSET = 1,
+ H5T_NORM_NONE = 2
+
+ ctypedef enum H5T_cset_t:
+ H5T_CSET_ERROR = -1,
+ H5T_CSET_ASCII = 0
+
+ ctypedef enum H5T_str_t:
+ H5T_STR_ERROR = -1,
+ H5T_STR_NULLTERM = 0,
+ H5T_STR_NULLPAD = 1,
+ H5T_STR_SPACEPAD = 2
+
+ # Atomic datatype padding
+ ctypedef enum H5T_pad_t:
+ H5T_PAD_ZERO = 0,
+ H5T_PAD_ONE = 1,
+ H5T_PAD_BACKGROUND = 2
+
+ # HDF5 type classes
+ cdef enum H5T_class_t:
+ H5T_NO_CLASS = -1, # error
+ H5T_INTEGER = 0, # integer types
+ H5T_FLOAT = 1, # floating-point types
+ H5T_TIME = 2, # date and time types
+ H5T_STRING = 3, # character string types
+ H5T_BITFIELD = 4, # bit field types
+ H5T_OPAQUE = 5, # opaque types
+ H5T_COMPOUND = 6, # compound types
+ H5T_REFERENCE = 7, # reference types
+ H5T_ENUM = 8, # enumeration types
+ H5T_VLEN = 9, # variable-length types
+ H5T_ARRAY = 10, # array types
+ H5T_NCLASSES # this must be last
+
+ # Native search direction
+ cdef enum H5T_direction_t:
+ H5T_DIR_DEFAULT,
+ H5T_DIR_ASCEND,
+ H5T_DIR_DESCEND
+
+ # --- Predefined datatypes --------------------------------------------------
+
+ cdef enum:
+ H5T_NATIVE_B8
+ H5T_NATIVE_CHAR
+ H5T_NATIVE_SCHAR
+ H5T_NATIVE_UCHAR
+ H5T_NATIVE_SHORT
+ H5T_NATIVE_USHORT
+ H5T_NATIVE_INT
+ H5T_NATIVE_UINT
+ H5T_NATIVE_LONG
+ H5T_NATIVE_ULONG
+ H5T_NATIVE_LLONG
+ H5T_NATIVE_ULLONG
+ H5T_NATIVE_FLOAT
+ H5T_NATIVE_DOUBLE
+ H5T_NATIVE_LDOUBLE
+
+ # "Standard" types
+ cdef enum:
+ H5T_STD_I8LE
+ H5T_STD_I16LE
+ H5T_STD_I32LE
+ H5T_STD_I64LE
+ H5T_STD_U8LE
+ H5T_STD_U16LE
+ H5T_STD_U32LE
+ H5T_STD_U64LE
+ H5T_STD_B8LE
+ H5T_STD_B16LE
+ H5T_STD_B32LE
+ H5T_STD_B64LE
+ H5T_IEEE_F32LE
+ H5T_IEEE_F64LE
+ H5T_STD_I8BE
+ H5T_STD_I16BE
+ H5T_STD_I32BE
+ H5T_STD_I64BE
+ H5T_STD_U8BE
+ H5T_STD_U16BE
+ H5T_STD_U32BE
+ H5T_STD_U64BE
+ H5T_STD_B8BE
+ H5T_STD_B16BE
+ H5T_STD_B32BE
+ H5T_STD_B64BE
+ H5T_IEEE_F32BE
+ H5T_IEEE_F64BE
+
+ cdef enum:
+ H5T_NATIVE_INT8
+ H5T_NATIVE_UINT8
+ H5T_NATIVE_INT16
+ H5T_NATIVE_UINT16
+ H5T_NATIVE_INT32
+ H5T_NATIVE_UINT32
+ H5T_NATIVE_INT64
+ H5T_NATIVE_UINT64
+
+ # Unix time types
+ cdef enum:
+ H5T_UNIX_D32LE
+ H5T_UNIX_D64LE
+ H5T_UNIX_D32BE
+ H5T_UNIX_D64BE
+
+ # String types
+ cdef enum:
+ H5T_FORTRAN_S1
+ H5T_C_S1
+
+ # References
+ cdef enum:
+ H5T_STD_REF_OBJ
+ H5T_STD_REF_DSETREG
+
+ # --- Datatype operations ---------------------------------------------------
+
+ # General operations
+ hid_t H5Tcreate(H5T_class_t type, size_t size) except *
+ hid_t H5Topen(hid_t loc, char* name) except *
+ herr_t H5Tcommit(hid_t loc_id, char* name, hid_t type) except *
+ htri_t H5Tcommitted(hid_t type) except *
+ hid_t H5Tcopy(hid_t type_id) except *
+ htri_t H5Tequal(hid_t type_id1, hid_t type_id2 ) except *
+ herr_t H5Tlock(hid_t type_id) except *
+ H5T_class_t H5Tget_class(hid_t type_id) except *
+ size_t H5Tget_size(hid_t type_id) except? 0
+ hid_t H5Tget_super(hid_t type) except *
+ htri_t H5Tdetect_class(hid_t type_id, H5T_class_t dtype_class) except *
+ herr_t H5Tclose(hid_t type_id) except *
+
+ hid_t H5Tget_native_type(hid_t type_id, H5T_direction_t direction) except *
+
+ # Not for public API
+ herr_t H5Tconvert(hid_t src_id, hid_t dst_id, size_t nelmts, void *buf, void *background, hid_t plist_id) except *
+
+ # Atomic datatypes
+ herr_t H5Tset_size(hid_t type_id, size_t size) except *
+
+ H5T_order_t H5Tget_order(hid_t type_id) except *
+ herr_t H5Tset_order(hid_t type_id, H5T_order_t order) except *
+
+ hsize_t H5Tget_precision(hid_t type_id) except? 0
+ herr_t H5Tset_precision(hid_t type_id, size_t prec) except *
+
+ int H5Tget_offset(hid_t type_id) except *
+ herr_t H5Tset_offset(hid_t type_id, size_t offset) except *
+
+ herr_t H5Tget_pad(hid_t type_id, H5T_pad_t * lsb, H5T_pad_t * msb ) except *
+ herr_t H5Tset_pad(hid_t type_id, H5T_pad_t lsb, H5T_pad_t msb ) except *
+
+ H5T_sign_t H5Tget_sign(hid_t type_id) except *
+ herr_t H5Tset_sign(hid_t type_id, H5T_sign_t sign) except *
+
+ herr_t H5Tget_fields(hid_t type_id, size_t *spos, size_t *epos,
+ size_t *esize, size_t *mpos, size_t *msize ) except *
+ herr_t H5Tset_fields(hid_t type_id, size_t spos, size_t epos,
+ size_t esize, size_t mpos, size_t msize ) except *
+
+ size_t H5Tget_ebias(hid_t type_id) except? 0
+ herr_t H5Tset_ebias(hid_t type_id, size_t ebias) except *
+ H5T_norm_t H5Tget_norm(hid_t type_id) except *
+ herr_t H5Tset_norm(hid_t type_id, H5T_norm_t norm) except *
+ H5T_pad_t H5Tget_inpad(hid_t type_id) except *
+ herr_t H5Tset_inpad(hid_t type_id, H5T_pad_t inpad) except *
+ H5T_cset_t H5Tget_cset(hid_t type_id) except *
+ herr_t H5Tset_cset(hid_t type_id, H5T_cset_t cset) except *
+ H5T_str_t H5Tget_strpad(hid_t type_id) except *
+ herr_t H5Tset_strpad(hid_t type_id, H5T_str_t strpad) except *
+
+ # VLENs
+ hid_t H5Tvlen_create(hid_t base_type_id) except *
+ htri_t H5Tis_variable_str(hid_t dtype_id) except *
+
+ # Compound data types
+ int H5Tget_nmembers(hid_t type_id) except *
+ H5T_class_t H5Tget_member_class(hid_t type_id, int member_no) except *
+ char* H5Tget_member_name(hid_t type_id, unsigned membno) except? NULL
+ hid_t H5Tget_member_type(hid_t type_id, unsigned membno) except *
+ int H5Tget_member_offset(hid_t type_id, int membno) except *
+ int H5Tget_member_index(hid_t type_id, char* name) except *
+ herr_t H5Tinsert(hid_t parent_id, char *name, size_t offset,
+ hid_t member_id) except *
+ herr_t H5Tpack(hid_t type_id) except *
+
+ # Enumerated types
+ hid_t H5Tenum_create(hid_t base_id) except *
+ herr_t H5Tenum_insert(hid_t type, char *name, void *value) except *
+ herr_t H5Tenum_nameof( hid_t type, void *value, char *name, size_t size ) except *
+ herr_t H5Tenum_valueof( hid_t type, char *name, void *value ) except *
+ herr_t H5Tget_member_value(hid_t type, unsigned int memb_no, void *value ) except *
+
+ # Array data types
+ hid_t H5Tarray_create(hid_t base_id, int ndims, hsize_t dims[], int perm[]) except *
+ int H5Tget_array_ndims(hid_t type_id) except *
+ int H5Tget_array_dims(hid_t type_id, hsize_t dims[], int perm[]) except *
+
+ # Opaque data types
+ herr_t H5Tset_tag(hid_t type_id, char* tag) except *
+ char* H5Tget_tag(hid_t type_id) except? NULL
+
+ IF H5PY_18API:
+ hid_t H5Tdecode(unsigned char *buf) except *
+ herr_t H5Tencode(hid_t obj_id, unsigned char *buf, size_t *nalloc) except *
+
+
+# === H5Z - Filters ===========================================================
+
+cdef extern from "hdf5.h":
+
+ ctypedef int H5Z_filter_t
+
+ int H5Z_FILTER_ERROR
+ int H5Z_FILTER_NONE
+ int H5Z_FILTER_ALL
+ int H5Z_FILTER_DEFLATE
+ int H5Z_FILTER_SHUFFLE
+ int H5Z_FILTER_FLETCHER32
+ int H5Z_FILTER_SZIP
+ int H5Z_FILTER_RESERVED
+ int H5Z_FILTER_MAX
+ int H5Z_MAX_NFILTERS
+
+ int H5Z_FLAG_DEFMASK
+ int H5Z_FLAG_MANDATORY
+ int H5Z_FLAG_OPTIONAL
+
+ int H5Z_FLAG_INVMASK
+ int H5Z_FLAG_REVERSE
+ int H5Z_FLAG_SKIP_EDC
+
+ int H5_SZIP_ALLOW_K13_OPTION_MASK #1
+ int H5_SZIP_CHIP_OPTION_MASK #2
+ int H5_SZIP_EC_OPTION_MASK #4
+ int H5_SZIP_NN_OPTION_MASK #32
+ int H5_SZIP_MAX_PIXELS_PER_BLOCK #32
+
+ int H5Z_FILTER_CONFIG_ENCODE_ENABLED #(0x0001)
+ int H5Z_FILTER_CONFIG_DECODE_ENABLED #(0x0002)
+
+ cdef enum H5Z_EDC_t:
+ H5Z_ERROR_EDC = -1,
+ H5Z_DISABLE_EDC = 0,
+ H5Z_ENABLE_EDC = 1,
+ H5Z_NO_EDC = 2
+
+ # --- Filter API ----------------------------------------------------------
+ htri_t H5Zfilter_avail(H5Z_filter_t id_) except *
+ herr_t H5Zget_filter_info(H5Z_filter_t filter_, unsigned int *filter_config_flags) except *
+
+
+
+
diff --git a/h5py/h5.pxd b/h5py/h5.pxd
index 1697524..c88d587 100644
--- a/h5py/h5.pxd
+++ b/h5py/h5.pxd
@@ -10,13 +10,7 @@
#
#-
-# This file is based on code from the PyTables project. The complete PyTables
-# license is available at licenses/pytables.txt, in the distribution root
-# directory.
-
-include "std_defs.pxi"
-
-# === Custom C extensions =====================================================
+include "defs.pxd"
cdef class PHIL:
@@ -38,129 +32,15 @@ cdef class H5PYConfig:
cdef readonly object THREADS
cdef class ObjectID:
- """ Base wrapper class for HDF5 object identifiers """
+
cdef object __weakref__
cdef readonly hid_t id
cdef readonly int _locked
- cdef object _hash # Used by subclasses to cache a hash value,
- # which may be expensive to compute.
+ cdef object _hash
cdef object standard_richcmp(object self, object other, int how)
cdef object obj_hash(ObjectID obj)
-
-# === HDF5 API ================================================================
-
-cdef extern from "hdf5.h":
-
- ctypedef struct hvl_t:
- size_t len # Length of VL data (in base type units)
- void *p # Pointer to VL data
-
- int HADDR_UNDEF
-
- herr_t H5open() except *
- herr_t H5close() except *
-
- # For object hashing
-
- ctypedef struct H5G_stat_t:
- unsigned long fileno[2]
- unsigned long objno[2]
-
- herr_t H5Gget_objinfo(hid_t loc_id, char* name, int follow_link, H5G_stat_t *statbuf) except *
-
- # --- Reflection ------------------------------------------------------------
- ctypedef enum H5I_type_t:
- H5I_BADID = -1
-
- H5I_type_t H5Iget_type(hid_t obj_id) except *
- int H5Idec_ref(hid_t obj_id) except *
- int H5Iget_ref(hid_t obj_id) except *
- int H5Iinc_ref(hid_t obj_id) except *
-
- # --- Version functions -----------------------------------------------------
- herr_t H5get_libversion(unsigned *majnum, unsigned *minnum,
- unsigned *relnum ) except *
-
- # --- Error handling --------------------------------------------------------
-
- # Major error numbers
- ctypedef enum H5E_major_t:
- H5E_NONE_MAJOR = 0, # special zero, no error
- H5E_ARGS, # invalid arguments to routine
- H5E_RESOURCE, # resource unavailable
- H5E_INTERNAL, # Internal error (too specific to document)
- H5E_FILE, # file Accessability
- H5E_IO, # Low-level I/O
- H5E_FUNC, # function Entry/Exit
- H5E_ATOM, # object Atom
- H5E_CACHE, # object Cache
- H5E_BTREE, # B-Tree Node
- H5E_SYM, # symbol Table
- H5E_HEAP, # Heap
- H5E_OHDR, # object Header
- H5E_DATATYPE, # Datatype
- H5E_DATASPACE, # Dataspace
- H5E_DATASET, # Dataset
- H5E_STORAGE, # data storage
- H5E_PLIST, # Property lists
- H5E_ATTR, # Attribute
- H5E_PLINE, # Data filters
- H5E_EFL, # External file list
- H5E_REFERENCE, # References
- H5E_VFL, # Virtual File Layer
-# H5E_TBBT, # Threaded, Balanced, Binary Trees (removed)
- H5E_TST, # Ternary Search Trees
- H5E_RS, # Reference Counted Strings
- H5E_ERROR, # Error API
- H5E_SLIST # Skip Lists
-
- ctypedef enum H5E_minor_t:
- pass
-
- cdef enum H5E_direction_t:
- H5E_WALK_UPWARD = 0 # begin deep, end at API function
- H5E_WALK_DOWNWARD = 1 # begin at API function, end deep
-
- ctypedef struct H5E_error_t:
- H5E_major_t maj_num # major error number
- H5E_minor_t min_num # minor error number
- char *func_name # function in which error occurred
- char *file_name # file in which error occurred
- unsigned line # line in file where error occurs
- char *desc # optional supplied description
-
- char *H5Eget_major(H5E_major_t n)
- char *H5Eget_minor(H5E_minor_t n)
- herr_t H5Eclear() except *
- ctypedef herr_t (*H5E_auto_t)(void *client_data)
- herr_t H5Eset_auto(H5E_auto_t func, void *client_data)
- herr_t H5Eget_auto(H5E_auto_t *func, void** client_data)
- ctypedef herr_t (*H5E_walk_t)(int n, H5E_error_t *err_desc, void* client_data)
- herr_t H5Ewalk(H5E_direction_t direction, H5E_walk_t func, void* client_data )
-
- int H5Fget_obj_count(hid_t file_id, unsigned int types) except *
- int H5Fget_obj_ids(hid_t file_id, unsigned int types, int max_objs, hid_t *obj_id_list) except *
- int H5F_OBJ_ALL
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+cdef int init_hdf5() except -1
diff --git a/h5py/h5.pyx b/h5py/h5.pyx
index 046baa4..5bcf12b 100644
--- a/h5py/h5.pyx
+++ b/h5py/h5.pyx
@@ -9,6 +9,7 @@
# $Date$
#
#-
+
"""
Common support and versioning module for the h5py HDF5 interface.
@@ -31,19 +32,33 @@
"""
include "config.pxi"
+
from python cimport PyErr_SetObject
import atexit
import threading
-# --- Module init -------------------------------------------------------------
-# Logging is only enabled when compiled with H5PY_DEBUG nonzero
+cdef class H5PYConfig:
+
+ """
+ Provides runtime access to the library compilation options.
+ """
+
+ def __init__(self):
+ self.API_16 = H5PY_16API
+ self.API_18 = H5PY_18API
+ self.DEBUG = H5PY_DEBUG
+ self.THREADS = H5PY_THREADS
+
+# === Bootstrap diagnostics and threading, before decorator is defined ===
+
IF H5PY_DEBUG:
import logging
- for x in ('h5py.identifiers', 'h5py.functions', 'h5py.threads'):
+ for x in ('h5py.library', 'h5py.identifiers', 'h5py.functions', 'h5py.threads'):
l = logging.getLogger(x)
l.setLevel(H5PY_DEBUG)
l.addHandler(logging.StreamHandler())
+ log_lib = logging.getLogger('h5py.library')
log_ident = logging.getLogger('h5py.identifiers')
log_threads = logging.getLogger('h5py.threads')
@@ -61,64 +76,6 @@ def loglevel(lev):
ELSE:
pass
-# --- C extensions and classes ------------------------------------------------
-
-cdef object standard_richcmp(object self, object other, int how):
- # HDF5 object identity is determined by comparing hash values. In the
- # absence of a logical comparision method (for example, TypeId.equal()),
- # this hash-based identity is used for comparison.
-
- # Subject to:
- # 1. Both must be of the same type
- # 2. Both must be hashable
- # 3. Only == and != comparisons are supported
- #
- # Otherwise NotImplemented is returned, for Python's fallback mechanics.
-
- if how != 2 and how != 3:
- return NotImplemented
-
- if not type(self) == type(other) and isinstance(self, ObjectID):
- return NotImplemented # Can't compare across types
-
- try:
- eq = (hash(self) == hash(other))
- except TypeError:
- return NotImplemented # Can't compare unhashable instances
-
- if how == 2:
- return eq
- return not eq
-
-cdef object obj_hash(ObjectID obj):
- # Try to compute the hash of the given file-resident object, raising
- # TypeError if it can't be done.
-
- # This is a counterpart to standard_richcmp.
-
- cdef H5G_stat_t stat
-
- phil.acquire()
- try:
- H5Gget_objinfo(obj.id, '.', 0, &stat)
- return hash((stat.fileno[0], stat.fileno[1], stat.objno[0], stat.objno[1]))
- except:
- raise TypeError("Objects of class %s cannot be hashed" % obj.__class__.__name__)
- finally:
- phil.release()
-
-cdef class H5PYConfig:
-
- """
- Global configuration object for the h5py package.
- """
-
- def __init__(self):
- self.API_16 = H5PY_16API
- self.API_18 = H5PY_18API
- self.DEBUG = H5PY_DEBUG
- self.THREADS = H5PY_THREADS
-
cdef class PHIL:
"""
@@ -165,8 +122,55 @@ cpdef PHIL get_phil():
""" Obtain a reference to the PHIL. """
return phil
-# Now that the PHIL is defined we can import the decorator
-include "std_code.pxi"
+# Everything required for the decorator is now defined
+
+include "sync.pxi"
+
+# === Public C API for object identifiers =====================================
+
+cdef object standard_richcmp(object self, object other, int how):
+ # HDF5 object identity is determined by comparing hash values. In the
+ # absence of a logical comparision method (for example, TypeId.equal()),
+ # this hash-based identity is used for comparison.
+
+ # Subject to:
+ # 1. Both must be of the same type
+ # 2. Both must be hashable
+ # 3. Only == and != comparisons are supported
+ #
+ # Otherwise NotImplemented is returned, for Python's fallback mechanics.
+
+ if how != 2 and how != 3:
+ return NotImplemented
+
+ if not type(self) == type(other) and isinstance(self, ObjectID):
+ return NotImplemented # Can't compare across types
+
+ try:
+ eq = (hash(self) == hash(other))
+ except TypeError:
+ return NotImplemented # Can't compare unhashable instances
+
+ if how == 2:
+ return eq
+ return not eq
+
+cdef object obj_hash(ObjectID obj):
+ # Try to compute the hash of the given file-resident object, raising
+ # TypeError if it can't be done.
+
+ # This is a counterpart to standard_richcmp.
+
+ cdef H5G_stat_t stat
+
+ phil.acquire()
+ try:
+ H5Gget_objinfo(obj.id, '.', 0, &stat)
+ return hash((stat.fileno[0], stat.fileno[1], stat.objno[0], stat.objno[1]))
+ except:
+ raise TypeError("Objects of class %s cannot be hashed" % obj.__class__.__name__)
+ finally:
+ phil.release()
cdef class ObjectID:
@@ -303,9 +307,6 @@ class H5Error(Exception):
"""
pass
-# --- New classes -------------------------------------------------------------
-
-
# H5E_ARGS, # invalid arguments to routine
class ArgsError(H5Error):
""" H5E_ARGS """
@@ -415,8 +416,6 @@ class RefError(H5Error):
class VirtualFileError(H5Error):
""" H5E_VFL """
pass
-
-# H5E_TBBT removed; does not appear in 1.8.X
# H5E_TST, # Ternary Search Trees
class TSTError(H5Error):
@@ -438,7 +437,7 @@ class SkipListError(H5Error):
""" H5E_SLIST """
pass
-_exceptions = {
+cdef dict _exceptions = {
H5E_ARGS: ArgsError,
H5E_RESOURCE: ResourceError,
H5E_INTERNAL: InternalError,
@@ -633,16 +632,25 @@ def _exithack():
finally:
free(objs)
-cdef int import_hdf5() except -1:
- if H5open() < 0:
- raise RuntimeError("Failed to initialize the HDF5 library.")
- _enable_exceptions()
- atexit.register(_exithack)
+cdef int _hdf5_inited = 0
+
+cdef int init_hdf5() except -1:
+ # Initialize the library and set register Python callbacks for exception
+ # handling. Safe to call more than once.
+
+ if not _hdf5_inited:
+ IF H5PY_DEBUG:
+ log_lib.info("* Initializing h5py library")
+ if H5open() < 0:
+ raise RuntimeError("Failed to initialize the HDF5 library.")
+ _enable_exceptions()
+ atexit.register(_exithack)
+ _hdf5_inited = 1
return 0
-import_hdf5()
+init_hdf5()
-# --- Public versioning info ---
+# === Module init =============================================================
hdf5_version_tuple = get_libversion()
hdf5_version = "%d.%d.%d" % hdf5_version_tuple
diff --git a/h5py/h5a.pxd b/h5py/h5a.pxd
index 687fb10..153ef89 100644
--- a/h5py/h5a.pxd
+++ b/h5py/h5a.pxd
@@ -10,39 +10,10 @@
#
#-
-# This file is based on code from the PyTables project. The complete PyTables
-# license is available at licenses/pytables.txt, in the distribution root
-# directory.
+include "defs.pxd"
-include "std_defs.pxi"
from h5 cimport ObjectID
-from numpy cimport class ndarray
cdef class AttrID(ObjectID):
pass
-cdef extern from "hdf5.h":
-
- # --- Attribute operations --------------------------------------------------
- hid_t H5Acreate(hid_t loc_id, char *name, hid_t type_id, hid_t space_id, hid_t create_plist) except *
- hid_t H5Aopen_idx(hid_t loc_id, unsigned int idx) except *
- hid_t H5Aopen_name(hid_t loc_id, char *name) except *
- herr_t H5Aclose(hid_t attr_id) except *
- herr_t H5Adelete(hid_t loc_id, char *name) except *
-
- herr_t H5Aread(hid_t attr_id, hid_t mem_type_id, void *buf) except *
- herr_t H5Awrite(hid_t attr_id, hid_t mem_type_id, void *buf ) except *
-
- int H5Aget_num_attrs(hid_t loc_id) except *
- ssize_t H5Aget_name(hid_t attr_id, size_t buf_size, char *buf) except *
- hid_t H5Aget_space(hid_t attr_id) except *
- hid_t H5Aget_type(hid_t attr_id) except *
-
- ctypedef herr_t (*H5A_operator_t)(hid_t loc_id, char *attr_name, operator_data) except -1
- herr_t H5Aiterate(hid_t loc_id, unsigned * idx, H5A_operator_t op, op_data) except *
-
-
-
-
-
-
diff --git a/h5py/h5a.pyx b/h5py/h5a.pyx
index 2c55166..885eda8 100644
--- a/h5py/h5a.pyx
+++ b/h5py/h5a.pyx
@@ -12,29 +12,25 @@
"""
Provides access to the low-level HDF5 "H5A" attribute interface.
-
- Python extensions:
- py_listattrs(ObjectID) Get a list of attribute names
- py_exists(ObjectID, STRING) Test if a named attribute exists
"""
-include "std_code.pxi"
+include "config.pxi"
+include "sync.pxi"
-# Pyrex compile-time imports
-from h5p cimport H5P_DEFAULT
+# Compile-time imports
+from h5 cimport init_hdf5
from h5t cimport TypeID, typewrap
-from h5s cimport SpaceID, H5Sclose
-
+from h5s cimport SpaceID
from numpy cimport import_array, ndarray, PyArray_DATA
from utils cimport check_numpy_read, check_numpy_write, \
- emalloc, efree, pybool
+ emalloc, efree
+
+# Initialization
+init_hdf5()
+import_array()
# Runtime imports
-import h5
import h5t
-import h5s
-
-import_array()
# === General attribute operations ============================================
@@ -163,7 +159,7 @@ def py_exists(ObjectID loc not None, object ref_name):
retval = H5Aiterate(loc.id, &i, <H5A_operator_t>cb_exist, ref_name)
- return pybool(retval)
+ return <bint>retval
# === Attribute class & methods ===============================================
diff --git a/h5py/h5d.pxd b/h5py/h5d.pxd
index 04148f1..79bc60f 100644
--- a/h5py/h5d.pxd
+++ b/h5py/h5d.pxd
@@ -10,93 +10,10 @@
#
#-
-# This file is based on code from the PyTables project. The complete PyTables
-# license is available at licenses/pytables.txt, in the distribution root
-# directory.
-
-include "std_defs.pxi"
-from h5 cimport class ObjectID
-
-from h5t cimport class TypeID, typewrap
-from h5s cimport class SpaceID
-from h5p cimport class PropID, pdefault, propwrap, PropDCID, PropDXID
-from numpy cimport class ndarray
+include "defs.pxd"
+from h5 cimport ObjectID
cdef class DatasetID(ObjectID):
cdef object _dtype
-cdef extern from "hdf5.h":
-
- # HDF5 layouts
- ctypedef enum H5D_layout_t:
- H5D_LAYOUT_ERROR = -1,
- H5D_COMPACT = 0, # raw data is very small
- H5D_CONTIGUOUS = 1, # the default
- H5D_CHUNKED = 2, # slow and fancy
- H5D_NLAYOUTS = 3 # this one must be last!
-
- ctypedef enum H5D_alloc_time_t:
- H5D_ALLOC_TIME_ERROR =-1,
- H5D_ALLOC_TIME_DEFAULT =0,
- H5D_ALLOC_TIME_EARLY =1,
- H5D_ALLOC_TIME_LATE =2,
- H5D_ALLOC_TIME_INCR =3
-
- ctypedef enum H5D_space_status_t:
- H5D_SPACE_STATUS_ERROR =-1,
- H5D_SPACE_STATUS_NOT_ALLOCATED =0,
- H5D_SPACE_STATUS_PART_ALLOCATED =1,
- H5D_SPACE_STATUS_ALLOCATED =2
-
- ctypedef enum H5D_fill_time_t:
- H5D_FILL_TIME_ERROR =-1,
- H5D_FILL_TIME_ALLOC =0,
- H5D_FILL_TIME_NEVER =1,
- H5D_FILL_TIME_IFSET =2
-
- ctypedef enum H5D_fill_value_t:
- H5D_FILL_VALUE_ERROR =-1,
- H5D_FILL_VALUE_UNDEFINED =0,
- H5D_FILL_VALUE_DEFAULT =1,
- H5D_FILL_VALUE_USER_DEFINED =2
-
-
- hid_t H5Dcreate(hid_t loc, char* name, hid_t type_id, hid_t space_id,
- hid_t create_plist_id) except *
- hid_t H5Dopen(hid_t file_id, char *name) except *
- herr_t H5Dclose(hid_t dset_id) except *
-
- hid_t H5Dget_space(hid_t dset_id) except *
- herr_t H5Dget_space_status(hid_t dset_id,
- H5D_space_status_t *status) except *
- hid_t H5Dget_type(hid_t dset_id) except *
- hid_t H5Dget_create_plist(hid_t dataset_id) except *
-
- haddr_t H5Dget_offset(hid_t dset_id) except *
- hsize_t H5Dget_storage_size(hid_t dset_id) except? 0
-
- # These must have their return values checked manually. The functions
- # H5PY_H5Dread and H5PY_HDwrite return -1 specifically, for use when
- # the GIL is released and PyErr_Occurred() is inadvisable.
- herr_t H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id,
- hid_t file_space_id, hid_t plist_id, void *buf) nogil
- herr_t H5Dwrite(hid_t dset_id, hid_t mem_type, hid_t mem_space, hid_t
- file_space, hid_t xfer_plist, void* buf) nogil
-
- herr_t H5Dextend(hid_t dataset_id, hsize_t *size) except *
-
- herr_t H5Dfill(void *fill, hid_t fill_type_id, void *buf,
- hid_t buf_type_id, hid_t space_id ) except *
- herr_t H5Dvlen_get_buf_size(hid_t dset_id, hid_t type_id,
- hid_t space_id, hsize_t *size) except *
- herr_t H5Dvlen_reclaim(hid_t type_id, hid_t space_id,
- hid_t plist, void *buf) except *
- ctypedef herr_t (*H5D_operator_t)(void *elem, hid_t type_id, unsigned ndim,
- hsize_t *point, void *operator_data)
- herr_t H5Diterate(void *buf, hid_t type_id, hid_t space_id,
- H5D_operator_t operator, void* operator_data) except *
-
-
-
-
diff --git a/h5py/h5d.pyx b/h5py/h5d.pyx
index 7db815a..0129130 100644
--- a/h5py/h5d.pyx
+++ b/h5py/h5d.pyx
@@ -13,25 +13,26 @@
"""
Provides access to the low-level HDF5 "H5D" dataset interface.
"""
-include "std_code.pxi"
-# Pyrex compile-time imports
-from h5s cimport H5S_ALL, H5S_UNLIMITED, H5S_SCALAR, H5S_SIMPLE, \
- H5Sget_simple_extent_type, H5Sclose, H5Sselect_all, \
- H5Sget_simple_extent_ndims, H5Sget_select_npoints
-from numpy cimport import_array, PyArray_DATA, NPY_WRITEABLE
+include "config.pxi"
+include "sync.pxi"
+
+# Compile-time imports
+from h5 cimport init_hdf5
+from numpy cimport ndarray, import_array, PyArray_DATA, NPY_WRITEABLE
from utils cimport check_numpy_read, check_numpy_write, \
- require_tuple, \
- convert_tuple, \
- emalloc, efree
-from h5 cimport HADDR_UNDEF
+ require_tuple, convert_tuple, emalloc, efree
+from h5t cimport TypeID, typewrap
+from h5s cimport SpaceID
+from h5p cimport PropID, propwrap, pdefault
+
+# Initialization
+init_hdf5()
+import_array()
# Runtime imports
-import h5
import h5t
-import_array()
-
# === Public constants and data structures ====================================
COMPACT = H5D_COMPACT
@@ -59,7 +60,7 @@ FILL_VALUE_USER_DEFINED = H5D_FILL_VALUE_USER_DEFINED
@sync
def create(ObjectID loc not None, char* name, TypeID tid not None,
- SpaceID space not None, PropDCID dcpl=None):
+ SpaceID space not None, PropID dcpl=None):
""" (ObjectID loc, STRING name, TypeID tid, SpaceID space,
PropDCID dcpl=None )
=> DatasetID
@@ -157,7 +158,7 @@ cdef class DatasetID(ObjectID):
@sync
def read(self, SpaceID mspace not None, SpaceID fspace not None,
- ndarray arr_obj not None, PropDXID dxpl=None):
+ ndarray arr_obj not None, PropID dxpl=None):
""" (SpaceID mspace, SpaceID fspace, NDARRAY arr_obj,
PropDXID dxpl=None)
@@ -204,7 +205,7 @@ cdef class DatasetID(ObjectID):
@sync
def write(self, SpaceID mspace not None, SpaceID fspace not None,
- ndarray arr_obj not None, PropDXID dxpl=None):
+ ndarray arr_obj not None, PropID dxpl=None):
""" (SpaceID mspace, SpaceID fspace, NDARRAY arr_obj,
PropDXID dxpl=None)
diff --git a/h5py/h5f.pxd b/h5py/h5f.pxd
index d60b831..7ff9425 100644
--- a/h5py/h5f.pxd
+++ b/h5py/h5f.pxd
@@ -10,75 +10,15 @@
#
#-
-# This file is based on code from the PyTables project. The complete PyTables
-# license is available at licenses/pytables.txt, in the distribution root
-# directory.
+include "defs.pxd"
-include "std_defs.pxi"
from h5 cimport class ObjectID
cdef class FileID(ObjectID):
pass
# Internal h5py function to wrap file-resident identifiers
+# TODO: move this to h5i
cdef object wrap_identifier(hid_t ident)
-cdef extern from "hdf5.h":
-
- # File constants
- cdef enum:
- H5F_ACC_TRUNC
- H5F_ACC_RDONLY
- H5F_ACC_RDWR
- H5F_ACC_EXCL
- H5F_ACC_DEBUG
- H5F_ACC_CREAT
-
- # The difference between a single file and a set of mounted files
- cdef enum H5F_scope_t:
- H5F_SCOPE_LOCAL = 0, # specified file handle only
- H5F_SCOPE_GLOBAL = 1, # entire virtual file
- H5F_SCOPE_DOWN = 2 # for internal use only
-
- cdef enum H5F_close_degree_t:
- H5F_CLOSE_WEAK = 0,
- H5F_CLOSE_SEMI = 1,
- H5F_CLOSE_STRONG = 2,
- H5F_CLOSE_DEFAULT = 3
-
- int H5F_OBJ_FILE
- int H5F_OBJ_DATASET
- int H5F_OBJ_GROUP
- int H5F_OBJ_DATATYPE
- int H5F_OBJ_ATTR
- int H5F_OBJ_ALL
- int H5F_OBJ_LOCAL
-
- # --- File operations -------------------------------------------------------
- hid_t H5Fcreate(char *filename, unsigned int flags,
- hid_t create_plist, hid_t access_plist) except *
- hid_t H5Fopen(char *name, unsigned flags, hid_t access_id) except *
- herr_t H5Fclose (hid_t file_id) except *
- htri_t H5Fis_hdf5(char *name) except *
- herr_t H5Fflush(hid_t object_id, H5F_scope_t scope) except *
-
- hid_t H5Freopen(hid_t file_id) except *
- herr_t H5Fmount(hid_t loc_id, char *name, hid_t child_id, hid_t plist_id) except *
- herr_t H5Funmount(hid_t loc_id, char *name) except *
- herr_t H5Fget_filesize(hid_t file_id, hsize_t *size) except *
- hid_t H5Fget_create_plist(hid_t file_id ) except *
- hid_t H5Fget_access_plist(hid_t file_id) except *
- hssize_t H5Fget_freespace(hid_t file_id) except *
- ssize_t H5Fget_name(hid_t obj_id, char *name, size_t size) except *
- int H5Fget_obj_count(hid_t file_id, unsigned int types) except *
- int H5Fget_obj_ids(hid_t file_id, unsigned int types, int max_objs, hid_t *obj_id_list) except *
-
-
-
-
-
-
-
-
-
diff --git a/h5py/h5f.pyx b/h5py/h5f.pyx
index d132e34..bff07c2 100644
--- a/h5py/h5f.pyx
+++ b/h5py/h5f.pyx
@@ -13,20 +13,21 @@
"""
Low-level operations on HDF5 file objects.
"""
-include "std_code.pxi"
-# Pyrex compile-time imports
-from h5p cimport propwrap, pdefault, PropFAID, PropFCID, H5P_DEFAULT
+include "config.pxi"
+include "sync.pxi"
+
+# Compile-time imports
+from h5 cimport init_hdf5
+from h5p cimport propwrap, pdefault, PropFAID, PropFCID
from h5t cimport typewrap
from h5a cimport AttrID
from h5d cimport DatasetID
from h5g cimport GroupID
-from h5i cimport H5Iget_type, H5Iinc_ref, H5I_type_t, \
- H5I_FILE, H5I_GROUP, H5I_ATTR, H5I_DATASET, H5I_DATATYPE
-from utils cimport emalloc, efree, pybool
+from utils cimport emalloc, efree
-# Runtime imports
-import h5
+# Initialization
+init_hdf5()
# === Public constants and data structures ====================================
@@ -98,7 +99,7 @@ def is_hdf5(char* name):
Determine if a given file is an HDF5 file. Note this raises an
exception if the file doesn't exist.
"""
- return pybool(H5Fis_hdf5(name))
+ return <bint>(H5Fis_hdf5(name))
@sync
def mount(ObjectID loc not None, char* name, FileID fid not None):
@@ -164,6 +165,7 @@ def get_obj_count(object where=OBJ_ALL, int types=H5F_OBJ_ALL):
cdef object wrap_identifier(hid_t ident):
# Support function for get_obj_ids
+ # TODO: move this to H5I
cdef H5I_type_t typecode
cdef ObjectID obj
@@ -181,8 +183,6 @@ cdef object wrap_identifier(hid_t ident):
else:
raise ValueError("Unrecognized type code %d" % typecode)
- # The HDF5 function doesn't seem to inc_ref these identifiers.
- H5Iinc_ref(ident)
return obj
@sync
@@ -223,6 +223,8 @@ def get_obj_ids(object where=OBJ_ALL, int types=H5F_OBJ_ALL):
H5Fget_obj_ids(where_id, types, count, obj_list)
for i from 0<=i<count:
py_obj_list.append(wrap_identifier(obj_list[i]))
+ # The HDF5 function returns a borrowed reference for each hid_t.
+ H5Iinc_ref(obj_list[i])
return py_obj_list
finally:
diff --git a/h5py/h5fd.pxd b/h5py/h5fd.pxd
index a4dcfc9..ced8b14 100644
--- a/h5py/h5fd.pxd
+++ b/h5py/h5fd.pxd
@@ -13,7 +13,7 @@
# This file contains code or comments from the HDF5 library. See the file
# licenses/hdf5.txt for the full HDF5 software license.
-include "std_defs.pxi"
+include "defs.pxd"
cdef extern from "hdf5.h":
diff --git a/h5py/h5fd.pyx b/h5py/h5fd.pyx
index d1fe854..24aa7bc 100644
--- a/h5py/h5fd.pyx
+++ b/h5py/h5fd.pyx
@@ -13,6 +13,12 @@
# This file contains code or comments from the HDF5 library. See the file
# licenses/hdf5.txt for the full HDF5 software license.
+include "config.pxi"
+include "sync.pxi"
+
+from h5 cimport init_hdf5
+init_hdf5()
+
# === Multi-file driver =======================================================
MEM_DEFAULT = H5FD_MEM_DEFAULT
diff --git a/h5py/h5g.pxd b/h5py/h5g.pxd
index bb5dd72..b4dd5ee 100644
--- a/h5py/h5g.pxd
+++ b/h5py/h5g.pxd
@@ -10,12 +10,10 @@
#
#-
-# This file is based on code from the PyTables project. The complete PyTables
-# license is available at licenses/pytables.txt, in the distribution root
-# directory.
+include "config.pxi"
+include "defs.pxd"
-include "std_defs.pxi"
-from h5 cimport class ObjectID
+from h5 cimport ObjectID
cdef class GroupID(ObjectID):
@@ -23,79 +21,4 @@ cdef class GroupID(ObjectID):
cdef readonly object links
pass
-cdef extern from "hdf5.h":
-
- ctypedef enum H5G_link_t:
- H5G_LINK_ERROR = -1,
- H5G_LINK_HARD = 0,
- H5G_LINK_SOFT = 1
-
- cdef enum H5G_obj_t:
- H5G_UNKNOWN = -1, # Unknown object type
- H5G_LINK, # Object is a symbolic link
- H5G_GROUP, # Object is a group
- H5G_DATASET, # Object is a dataset
- H5G_TYPE, # Object is a named data type
-
- ctypedef struct H5G_stat_t:
- unsigned long fileno[2]
- unsigned long objno[2]
- unsigned int nlink
- H5G_obj_t type # new in HDF5 1.6
- time_t mtime
- size_t linklen
- #H5O_stat_t ohdr # Object header information. New in HDF5 1.6
-
- # --- Group operations ------------------------------------------------------
- hid_t H5Gcreate(hid_t loc_id, char *name, size_t size_hint ) except *
- hid_t H5Gopen(hid_t loc_id, char *name ) except *
- herr_t H5Gclose(hid_t group_id) except *
- herr_t H5Glink2( hid_t curr_loc_id, char *current_name,
- H5G_link_t link_type, hid_t new_loc_id, char *new_name ) except *
-
- herr_t H5Gunlink (hid_t file_id, char *name) except *
- herr_t H5Gmove2(hid_t src_loc_id, char *src_name,
- hid_t dst_loc_id, char *dst_name ) except *
- herr_t H5Gget_num_objs(hid_t loc_id, hsize_t* num_obj) except *
- int H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char *name, size_t size ) except *
- int H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx ) except *
-
- ctypedef herr_t (*H5G_iterate_t)(hid_t group, char *name, op_data) except -1
- herr_t H5Giterate(hid_t loc_id, char *name, int *idx, H5G_iterate_t operator, operator_data ) except *
- herr_t H5Gget_objinfo(hid_t loc_id, char* name, int follow_link, H5G_stat_t *statbuf) except *
-
- herr_t H5Gget_linkval(hid_t loc_id, char *name, size_t size, char *value) except *
- herr_t H5Gset_comment(hid_t loc_id, char *name, char *comment ) except *
- int H5Gget_comment(hid_t loc_id, char *name, size_t bufsize, char *comment ) except *
-
- # --- New 1.8.X functions ---------------------------------------------------
-
- IF H5PY_18API:
- ctypedef enum H5G_storage_type_t:
- H5G_STORAGE_TYPE_UNKNOWN = -1,
- H5G_STORAGE_TYPE_SYMBOL_TABLE,
- H5G_STORAGE_TYPE_COMPACT,
- H5G_STORAGE_TYPE_DENSE
-
- ctypedef struct H5G_info_t:
- H5G_storage_type_t storage_type
- hsize_t nlinks
- long int max_corder # FIXME: not really long int
-
- hid_t H5Gcreate_anon( hid_t loc_id, hid_t gcpl_id, hid_t gapl_id ) except *
- hid_t H5Gcreate2(hid_t loc_id, char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id) except *
- hid_t H5Gopen2( hid_t loc_id, char * name, hid_t gapl_id ) except *
- herr_t H5Gget_info( hid_t group_id, H5G_info_t *group_info ) except *
- herr_t H5Gget_info_by_name( hid_t loc_id, char *group_name, H5G_info_t *group_info, hid_t lapl_id ) except *
-
-
-
-
-
-
-
-
-
-
-
diff --git a/h5py/h5g.pyx b/h5py/h5g.pyx
index 50a8bbb..7a0205d 100644
--- a/h5py/h5g.pyx
+++ b/h5py/h5g.pyx
@@ -13,19 +13,23 @@
"""
Low-level HDF5 "H5G" group interface.
"""
-include "std_code.pxi"
-# Pyrex compile-time imports
+include "config.pxi"
+include "sync.pxi"
+
+# Compile-time imports
+from h5 cimport init_hdf5, standard_richcmp
from utils cimport emalloc, efree
-from h5 cimport standard_richcmp
-from h5p cimport H5P_DEFAULT, PropID, pdefault
+from h5p cimport PropID, pdefault
IF H5PY_18API:
from h5l cimport LinkProxy
+# Initialization
+init_hdf5()
+
# Runtime imports
-import h5
from h5 import H5Error
-import h5i
+
# === Public constants and data structures ====================================
@@ -347,7 +351,7 @@ cdef class GroupID(ObjectID):
Get the name of a group member given its zero-based index.
Due to a limitation of the HDF5 library, the generic exception
- H5Error (errno 1) is raised if the idx parameter is out-of-range.
+ H5Error is raised if the idx parameter is out-of-range.
"""
cdef int size
cdef char* buf
@@ -356,7 +360,7 @@ cdef class GroupID(ObjectID):
# This function does not properly raise an exception
size = H5Gget_objname_by_idx(self.id, idx, NULL, 0)
if size < 0:
- raise H5Error((1,"Invalid argument"))
+ raise H5Error("Invalid index")
buf = <char*>emalloc(sizeof(char)*(size+1))
try:
@@ -380,13 +384,13 @@ cdef class GroupID(ObjectID):
- DATATYPE
Due to a limitation of the HDF5 library, the generic exception
- H5Error (errno 1) is raised if the idx parameter is out-of-range.
+ H5Error is raised if the idx parameter is out-of-range.
"""
# This function does not properly raise an exception
cdef herr_t retval
retval = H5Gget_objtype_by_idx(self.id, idx)
if retval < 0:
- raise H5Error((1,"Invalid argument."))
+ raise H5Error("Invalid index")
return retval
# COMPAT: 1.8 deprecation
diff --git a/h5py/h5i.pxd b/h5py/h5i.pxd
index 15df417..2116324 100644
--- a/h5py/h5i.pxd
+++ b/h5py/h5i.pxd
@@ -10,40 +10,5 @@
#
#-
-# This file contains code or comments from the HDF5 library. The complete HDF5
-# license is available in the file licenses/hdf5.txt in the distribution
-# root directory.
-
-include "std_defs.pxi"
-from h5 cimport class ObjectID
-#from h5f cimport class FileID
-
-cdef extern from "hdf5.h":
-
- # reflection
- ctypedef enum H5I_type_t:
- H5I_BADID = -1, # /*invalid Group */
- H5I_FILE = 1, # /*group ID for File objects */
- H5I_GROUP, # /*group ID for Group objects */
- H5I_DATATYPE, # /*group ID for Datatype objects */
- H5I_DATASPACE, # /*group ID for Dataspace objects */
- H5I_DATASET, # /*group ID for Dataset objects */
- H5I_ATTR, # /*group ID for Attribute objects */
- H5I_REFERENCE, # /*group ID for Reference objects */
- H5I_VFL, # /*group ID for virtual file layer */
- H5I_GENPROP_CLS, # /*group ID for generic property list classes */
- H5I_GENPROP_LST, # /*group ID for generic property lists */
- H5I_NGROUPS # /*number of valid groups, MUST BE LAST! */
-
- # --- Reflection ------------------------------------------------------------
- H5I_type_t H5Iget_type(hid_t obj_id) except *
- ssize_t H5Iget_name( hid_t obj_id, char *name, size_t size) except *
- hid_t H5Iget_file_id(hid_t obj_id) except *
- int H5Idec_ref(hid_t obj_id) except *
- int H5Iget_ref(hid_t obj_id) except *
- int H5Iinc_ref(hid_t obj_id) except *
-
-
-
-
+include "defs.pxd"
diff --git a/h5py/h5i.pyx b/h5py/h5i.pyx
index 575e07c..7b78fc8 100644
--- a/h5py/h5i.pyx
+++ b/h5py/h5i.pyx
@@ -14,12 +14,17 @@
Identifier interface for object inspection.
"""
+include "config.pxi"
+include "sync.pxi"
+
# Pyrex compile-time imports
+from h5 cimport init_hdf5, ObjectID
from h5f cimport FileID
from utils cimport emalloc, efree
+init_hdf5()
+
# Runtime imports
-import h5
from h5 import H5Error
# === Public constants and data structures ====================================
@@ -37,6 +42,7 @@ DATATYPE = H5I_DATATYPE
# === Identifier API ==========================================================
+ at sync
def get_type(ObjectID obj not None):
""" (ObjectID obj) => INT type_code
@@ -46,6 +52,7 @@ def get_type(ObjectID obj not None):
"""
return <int>H5Iget_type(obj.id)
+ at sync
def get_name(ObjectID obj not None):
""" (ObjectID obj) => STRING name, or None
@@ -77,6 +84,7 @@ def get_name(ObjectID obj not None):
finally:
efree(name)
+ at sync
def get_file_id(ObjectID obj not None):
""" (ObjectID obj) => FileID
@@ -84,6 +92,7 @@ def get_file_id(ObjectID obj not None):
"""
return FileID(H5Iget_file_id(obj.id))
+ at sync
def inc_ref(ObjectID obj not None):
""" (ObjectID obj)
@@ -95,6 +104,7 @@ def inc_ref(ObjectID obj not None):
"""
H5Iinc_ref(obj.id)
+ at sync
def get_ref(ObjectID obj not None):
""" (ObjectID obj) => INT
@@ -102,6 +112,7 @@ def get_ref(ObjectID obj not None):
"""
return H5Iget_ref(obj.id)
+ at sync
def dec_ref(ObjectID obj not None):
""" (ObjectID obj)
diff --git a/h5py/h5l.pxd b/h5py/h5l.pxd
index 84bdc8a..debc749 100644
--- a/h5py/h5l.pxd
+++ b/h5py/h5l.pxd
@@ -10,116 +10,11 @@
#
#-
-include "std_defs.pxi"
+include "defs.pxd"
from h5 cimport ObjectID
-# Public classes
cdef class LinkProxy(ObjectID):
pass
-cdef extern from "hdf5.h":
-
- # TODO: put both versions in h5t.pxd
- ctypedef enum H5T_cset_t:
- H5T_CSET_ERROR = -1, #
- H5T_CSET_ASCII = 0, # US ASCII
- H5T_CSET_UTF8 = 1, # UTF-8 Unicode encoding
-
- unsigned int H5L_MAX_LINK_NAME_LEN # ((uint32_t) (-1)) (4GB - 1)
-
- # Link class types.
- # * Values less than 64 are reserved for the HDF5 library's internal use.
- # * Values 64 to 255 are for "user-defined" link class types; these types are
- # * defined by HDF5 but their behavior can be overridden by users.
- # * Users who want to create new classes of links should contact the HDF5
- # * development team at hdfhelp at ncsa.uiuc.edu .
- # * These values can never change because they appear in HDF5 files.
- #
- ctypedef enum H5L_type_t:
- H5L_TYPE_ERROR = (-1), # Invalid link type id
- H5L_TYPE_HARD = 0, # Hard link id
- H5L_TYPE_SOFT = 1, # Soft link id
- H5L_TYPE_EXTERNAL = 64, # External link id
- H5L_TYPE_MAX = 255 # Maximum link type id
-
- # Information struct for link (for H5Lget_info/H5Lget_info_by_idx)
- cdef union _add_u:
- haddr_t address # Address hard link points to
- size_t val_size # Size of a soft link or UD link value
-
- ctypedef struct H5L_info_t:
- H5L_type_t type # Type of link
- hbool_t corder_valid # Indicate if creation order is valid
- int64_t corder # Creation order
- H5T_cset_t cset # Character set of link name
- _add_u u
-
- # Prototype for H5Literate/H5Literate_by_name() operator
- ctypedef herr_t (*H5L_iterate_t) (hid_t group, char *name, H5L_info_t *info,
- void *op_data)
-
- ctypedef enum H5_index_t:
- H5_INDEX_NAME,
- H5_INDEX_CRT_ORDER
-
- ctypedef enum H5_iter_order_t:
- H5_ITER_INC, # Increasing order
- H5_ITER_DEC, # Decreasing order
- H5_ITER_NATIVE # Fastest available order
-
- # API
-
- herr_t H5Lmove(hid_t src_loc, char *src_name, hid_t dst_loc,
- char *dst_name, hid_t lcpl_id, hid_t lapl_id) except *
-
- herr_t H5Lcopy(hid_t src_loc, char *src_name, hid_t dst_loc,
- char *dst_name, hid_t lcpl_id, hid_t lapl_id) except *
-
- herr_t H5Lcreate_hard(hid_t cur_loc, char *cur_name,
- hid_t dst_loc, char *dst_name, hid_t lcpl_id, hid_t lapl_id) except *
-
- herr_t H5Lcreate_soft(char *link_target, hid_t link_loc_id,
- char *link_name, hid_t lcpl_id, hid_t lapl_id) except *
-
- herr_t H5Ldelete(hid_t loc_id, char *name, hid_t lapl_id) except *
-
- herr_t H5Ldelete_by_idx(hid_t loc_id, char *group_name,
- H5_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t lapl_id) except *
-
- herr_t H5Lget_val(hid_t loc_id, char *name, void *bufout,
- size_t size, hid_t lapl_id) except *
-
- herr_t H5Lget_val_by_idx(hid_t loc_id, char *group_name,
- H5_index_t idx_type, H5_iter_order_t order, hsize_t n,
- void *bufout, size_t size, hid_t lapl_id) except *
-
- htri_t H5Lexists(hid_t loc_id, char *name, hid_t lapl_id) except *
-
- herr_t H5Lget_info(hid_t loc_id, char *name,
- H5L_info_t *linfo, hid_t lapl_id) except *
-
- herr_t H5Lget_info_by_idx(hid_t loc_id, char *group_name,
- H5_index_t idx_type, H5_iter_order_t order, hsize_t n,
- H5L_info_t *linfo, hid_t lapl_id) except *
-
- ssize_t H5Lget_name_by_idx(hid_t loc_id, char *group_name,
- H5_index_t idx_type, H5_iter_order_t order, hsize_t n,
- char *name, size_t size, hid_t lapl_id) except *
-
- herr_t H5Literate(hid_t grp_id, H5_index_t idx_type,
- H5_iter_order_t order, hsize_t *idx, H5L_iterate_t op, void *op_data) except *
-
- herr_t H5Literate_by_name(hid_t loc_id, char *group_name,
- H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx,
- H5L_iterate_t op, void *op_data, hid_t lapl_id) except *
-
- herr_t H5Lvisit(hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order,
- H5L_iterate_t op, void *op_data) except *
-
- herr_t H5Lvisit_by_name(hid_t loc_id, char *group_name,
- H5_index_t idx_type, H5_iter_order_t order, H5L_iterate_t op,
- void *op_data, hid_t lapl_id) except *
-
-
diff --git a/h5py/h5l.pyx b/h5py/h5l.pyx
index a93f674..0d39abd 100644
--- a/h5py/h5l.pyx
+++ b/h5py/h5l.pyx
@@ -15,11 +15,11 @@ from utils cimport pybool
API for the "H5L" family of link-related operations
"""
+include "config.pxi"
+include "sync.pxi"
-cdef extern from "hdf5.h":
-
- int H5Iinc_ref(hid_t obj_id) except *
- int H5P_DEFAULT
+from h5 cimport init_hdf5
+init_hdf5()
cdef class LinkProxy(ObjectID):
@@ -28,7 +28,7 @@ cdef class LinkProxy(ObjectID):
These come attached to GroupID objects as "obj.links". Since every
H5L function operates on at least one group, the methods provided
- operate on their parent group operator. For example:
+ operate on their parent group identifier. For example:
>>> g = h5g.open(fid, '/')
>>> g.links.exists("MyGroup")
@@ -41,10 +41,12 @@ cdef class LinkProxy(ObjectID):
def __cinit__(self, hid_t id_):
# At this point the ObjectID constructor has already been called.
+ # The identifier in question is the hid_t for the parent GroupID.
# We need to manually incref the identifier because it's now
- # shared by both this object and its parent GroupID object.
+ # shared by both this object and the parent.
H5Iinc_ref(self.id)
+ @sync
def exists(self, char* name):
""" (STRING name) => BOOL
diff --git a/h5py/h5o.pxd b/h5py/h5o.pxd
index 2aadac2..2116324 100644
--- a/h5py/h5o.pxd
+++ b/h5py/h5o.pxd
@@ -10,82 +10,5 @@
#
#-
-include "std_defs.pxi"
-
-from h5 cimport ObjectID
-from h5g cimport GroupID
-
-cdef extern from "hdf5.h":
-
- ctypedef enum H5O_type_t:
- H5O_TYPE_UNKNOWN = -1, # Unknown object type
- H5O_TYPE_GROUP, # Object is a group
- H5O_TYPE_DATASET, # Object is a dataset
- H5O_TYPE_NAMED_DATATYPE, # Object is a named data type
- H5O_TYPE_NTYPES # Number of different object types (must be last!)
-
- # --- Components for the H5O_info_t struct ----------------------------------
-
- cdef struct space:
- hsize_t total # Total space for storing object header in file
- hsize_t meta # Space within header for object header metadata information
- hsize_t mesg # Space within header for actual message information
- hsize_t free # Free space within object header
-
- cdef struct mesg:
- unsigned long present # Flags to indicate presence of message type in header
- unsigned long shared # Flags to indicate message type is shared in header
-
- cdef struct hdr:
- unsigned version # Version number of header format in file
- unsigned nmesgs # Number of object header messages
- unsigned nchunks # Number of object header chunks
- unsigned flags # Object header status flags
- space space
- mesg mesg
-
- ctypedef struct H5_ih_info_t:
- hsize_t index_size, # /* btree and/or list */
- hsize_t heap_size
-
- cdef struct meta_size:
- H5_ih_info_t obj, # /* v1/v2 B-tree & local/fractal heap for groups, B-tree for chunked datasets */
- H5_ih_info_t attr # /* v2 B-tree & heap for attributes */
-
- ctypedef struct H5O_info_t:
- unsigned long fileno # File number that object is located in
- haddr_t addr # Object address in file
- H5O_type_t type # Basic object type (group, dataset, etc.)
- unsigned rc # Reference count of object
- time_t atime # Access time
- time_t mtime # Modification time
- time_t ctime # Change time
- time_t btime # Birth time
- hsize_t num_attrs # # of attributes attached to object
- hdr hdr
- meta_size meta_size
-
- ctypedef enum H5_index_t:
- H5_INDEX_NAME,
- H5_INDEX_CRT_ORDER
-
- ctypedef enum H5_iter_order_t:
- H5_ITER_INC, # Increasing order
- H5_ITER_DEC, # Decreasing order
- H5_ITER_NATIVE # Fastest available order
-
- ctypedef herr_t (*H5O_iterate_t)(hid_t obj, char *name, H5O_info_t *info,
- void *op_data)
-
- herr_t H5Ovisit(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order,
- H5O_iterate_t op, void *op_data) except *
-
- herr_t H5Oget_info(hid_t loc_id, H5O_info_t *oinfo) except *
-
-
-
-
-
-
-
+include "defs.pxd"
diff --git a/h5py/h5o.pyx b/h5py/h5o.pyx
index 023ecaa..8a03b1e 100644
--- a/h5py/h5o.pyx
+++ b/h5py/h5o.pyx
@@ -10,14 +10,18 @@
#
#-
+include "config.pxi"
+include "sync.pxi"
+
# Module for the new "H5O" functions introduced in HDF5 1.8.0. Not even
# built with API compatibility level below 1.8.
# Pyrex compile-time imports
+from h5 cimport init_hdf5
from h5f cimport wrap_identifier
-# Runtime imports
-import h5
+# Initialization
+init_hdf5()
cdef class ObjInfo:
diff --git a/h5py/h5p.pxd b/h5py/h5p.pxd
index 0255652..44da86e 100644
--- a/h5py/h5p.pxd
+++ b/h5py/h5p.pxd
@@ -14,9 +14,9 @@
# license is available at licenses/pytables.txt, in the distribution root
# directory.
-include "std_defs.pxi"
-from h5 cimport class ObjectID
-from numpy cimport ndarray, import_array
+include "defs.pxd"
+
+from h5 cimport ObjectID
cdef class PropID(ObjectID):
""" Base class for all property lists """
@@ -53,154 +53,5 @@ cdef class PropFAID(PropInstanceID):
cdef hid_t pdefault(PropID pid)
cdef object propwrap(hid_t id_in)
-cdef extern from "hdf5.h":
-
- int H5P_DEFAULT
-
- ctypedef int H5Z_filter_t
-
- # HDF5 layouts
- ctypedef enum H5D_layout_t:
- H5D_LAYOUT_ERROR = -1,
- H5D_COMPACT = 0, # raw data is very small
- H5D_CONTIGUOUS = 1, # the default
- H5D_CHUNKED = 2, # slow and fancy
- H5D_NLAYOUTS = 3 # this one must be last!
-
- ctypedef enum H5D_alloc_time_t:
- H5D_ALLOC_TIME_ERROR =-1,
- H5D_ALLOC_TIME_DEFAULT =0,
- H5D_ALLOC_TIME_EARLY =1,
- H5D_ALLOC_TIME_LATE =2,
- H5D_ALLOC_TIME_INCR =3
-
- ctypedef enum H5D_space_status_t:
- H5D_SPACE_STATUS_ERROR =-1,
- H5D_SPACE_STATUS_NOT_ALLOCATED =0,
- H5D_SPACE_STATUS_PART_ALLOCATED =1,
- H5D_SPACE_STATUS_ALLOCATED =2
-
- ctypedef enum H5D_fill_time_t:
- H5D_FILL_TIME_ERROR =-1,
- H5D_FILL_TIME_ALLOC =0,
- H5D_FILL_TIME_NEVER =1,
- H5D_FILL_TIME_IFSET =2
-
- ctypedef enum H5D_fill_value_t:
- H5D_FILL_VALUE_ERROR =-1,
- H5D_FILL_VALUE_UNDEFINED =0,
- H5D_FILL_VALUE_DEFAULT =1,
- H5D_FILL_VALUE_USER_DEFINED =2
-
- cdef enum H5Z_EDC_t:
- H5Z_ERROR_EDC = -1,
- H5Z_DISABLE_EDC = 0,
- H5Z_ENABLE_EDC = 1,
- H5Z_NO_EDC = 2
-
- cdef enum H5F_close_degree_t:
- H5F_CLOSE_WEAK = 0,
- H5F_CLOSE_SEMI = 1,
- H5F_CLOSE_STRONG = 2,
- H5F_CLOSE_DEFAULT = 3
-
- ctypedef enum H5FD_mem_t:
- H5FD_MEM_NOLIST = -1,
- H5FD_MEM_DEFAULT = 0,
- H5FD_MEM_SUPER = 1,
- H5FD_MEM_BTREE = 2,
- H5FD_MEM_DRAW = 3,
- H5FD_MEM_GHEAP = 4,
- H5FD_MEM_LHEAP = 5,
- H5FD_MEM_OHDR = 6,
- H5FD_MEM_NTYPES
-
- # Property list classes
- hid_t H5P_NO_CLASS
- hid_t H5P_FILE_CREATE
- hid_t H5P_FILE_ACCESS
- hid_t H5P_DATASET_CREATE
- hid_t H5P_DATASET_XFER
-
- # --- Property list operations ----------------------------------------------
- # General operations
- hid_t H5Pcreate(hid_t plist_id) except *
- hid_t H5Pcopy(hid_t plist_id) except *
- int H5Pget_class(hid_t plist_id) except *
- herr_t H5Pclose(hid_t plist_id) except *
- htri_t H5Pequal( hid_t id1, hid_t id2 ) except *
- herr_t H5Pclose_class(hid_t id) except *
-
- # File creation properties
- herr_t H5Pget_version(hid_t plist, unsigned int *super_, unsigned int* freelist,
- unsigned int *stab, unsigned int *shhdr) except *
- herr_t H5Pset_userblock(hid_t plist, hsize_t size) except *
- herr_t H5Pget_userblock(hid_t plist, hsize_t * size) except *
- herr_t H5Pset_sizes(hid_t plist, size_t sizeof_addr, size_t sizeof_size) except *
- herr_t H5Pget_sizes(hid_t plist, size_t *sizeof_addr, size_t *sizeof_size) except *
- herr_t H5Pset_sym_k(hid_t plist, unsigned int ik, unsigned int lk) except *
- herr_t H5Pget_sym_k(hid_t plist, unsigned int *ik, unsigned int *lk) except *
- herr_t H5Pset_istore_k(hid_t plist, unsigned int ik) except *
- herr_t H5Pget_istore_k(hid_t plist, unsigned int *ik) except *
-
- # File access
- herr_t H5Pset_fclose_degree(hid_t fapl_id, H5F_close_degree_t fc_degree) except *
- herr_t H5Pget_fclose_degree(hid_t fapl_id, H5F_close_degree_t *fc_degree) except *
- herr_t H5Pset_fapl_core( hid_t fapl_id, size_t increment, hbool_t backing_store) except *
- herr_t H5Pget_fapl_core( hid_t fapl_id, size_t *increment, hbool_t *backing_store) except *
- herr_t H5Pset_fapl_family ( hid_t fapl_id, hsize_t memb_size, hid_t memb_fapl_id ) except *
- herr_t H5Pget_fapl_family ( hid_t fapl_id, hsize_t *memb_size, hid_t *memb_fapl_id ) except *
- herr_t H5Pset_family_offset ( hid_t fapl_id, hsize_t offset) except *
- herr_t H5Pget_family_offset ( hid_t fapl_id, hsize_t *offset) except *
- herr_t H5Pset_fapl_log(hid_t fapl_id, char *logfile, unsigned int flags, size_t buf_size) except *
- herr_t H5Pset_fapl_multi(hid_t fapl_id, H5FD_mem_t *memb_map, hid_t *memb_fapl,
- char **memb_name, haddr_t *memb_addr, hbool_t relax)
- herr_t H5Pset_cache(hid_t plist_id, int mdc_nelmts, int rdcc_nelmts,
- size_t rdcc_nbytes, double rdcc_w0) except *
- herr_t H5Pget_cache(hid_t plist_id, int *mdc_nelmts, int *rdcc_nelmts,
- size_t *rdcc_nbytes, double *rdcc_w0) except *
- herr_t H5Pset_fapl_sec2(hid_t fapl_id) except *
- herr_t H5Pset_fapl_stdio(hid_t fapl_id) except *
- hid_t H5Pget_driver(hid_t fapl_id) except *
-
- # Dataset creation properties
- herr_t H5Pset_layout(hid_t plist, int layout) except *
- H5D_layout_t H5Pget_layout(hid_t plist) except *
- herr_t H5Pset_chunk(hid_t plist, int ndims, hsize_t * dim) except *
- int H5Pget_chunk(hid_t plist, int max_ndims, hsize_t * dims ) except *
- herr_t H5Pset_deflate( hid_t plist, int level) except *
- herr_t H5Pset_fill_value(hid_t plist_id, hid_t type_id, void *value ) except *
- herr_t H5Pget_fill_value(hid_t plist_id, hid_t type_id, void *value ) except *
- herr_t H5Pfill_value_defined(hid_t plist_id, H5D_fill_value_t *status ) except *
- herr_t H5Pset_fill_time(hid_t plist_id, H5D_fill_time_t fill_time ) except *
- herr_t H5Pget_fill_time(hid_t plist_id, H5D_fill_time_t *fill_time ) except *
- herr_t H5Pset_alloc_time(hid_t plist_id, H5D_alloc_time_t alloc_time ) except *
- herr_t H5Pget_alloc_time(hid_t plist_id, H5D_alloc_time_t *alloc_time ) except *
- herr_t H5Pset_filter(hid_t plist, H5Z_filter_t filter, unsigned int flags,
- size_t cd_nelmts, unsigned int cd_values[] ) except *
- htri_t H5Pall_filters_avail(hid_t dcpl_id) except *
- int H5Pget_nfilters(hid_t plist) except *
- H5Z_filter_t H5Pget_filter(hid_t plist, unsigned int filter_number,
- unsigned int *flags, size_t *cd_nelmts,
- unsigned int *cd_values, size_t namelen, char name[] ) except *
- herr_t H5Pget_filter_by_id( hid_t plist_id, H5Z_filter_t filter,
- unsigned int *flags, size_t *cd_nelmts,
- unsigned int cd_values[], size_t namelen, char name[]) except *
- herr_t H5Pmodify_filter(hid_t plist, H5Z_filter_t filter, unsigned int flags,
- size_t cd_nelmts, unsigned int cd_values[] ) except *
- herr_t H5Premove_filter(hid_t plist, H5Z_filter_t filter ) except *
- herr_t H5Pset_fletcher32(hid_t plist) except *
- herr_t H5Pset_shuffle(hid_t plist_id) except *
- herr_t H5Pset_szip(hid_t plist, unsigned int options_mask, unsigned int pixels_per_block) except *
-
-
- # Transfer properties
- herr_t H5Pset_edc_check(hid_t plist, H5Z_EDC_t check) except *
- H5Z_EDC_t H5Pget_edc_check(hid_t plist) except *
-
- # Other properties
- herr_t H5Pset_sieve_buf_size(hid_t fapl_id, hsize_t size) except *
- herr_t H5Pset_fapl_log(hid_t fapl_id, char *logfile,
- unsigned int flags, size_t buf_size) except *
diff --git a/h5py/h5p.pyx b/h5py/h5p.pyx
index b02d229..1bb31c4 100644
--- a/h5py/h5p.pyx
+++ b/h5py/h5p.pyx
@@ -15,21 +15,23 @@
HDF5 property list interface.
"""
-# Pyrex compile-time imports
+include "config.pxi"
+include "sync.pxi"
-from h5 cimport standard_richcmp
+# Compile-time imports
+from h5 cimport init_hdf5, standard_richcmp
from utils cimport require_tuple, convert_dims, convert_tuple, \
- emalloc, efree, pybool, require_list, \
+ emalloc, efree, require_list, \
check_numpy_write, check_numpy_read
-
+from numpy cimport ndarray, import_array
from h5t cimport TypeID
+# Initialization
+init_hdf5()
+import_array()
+
# Runtime imports
-import h5
import h5t
-import numpy
-
-import_array()
# === C API ===================================================================
@@ -121,7 +123,7 @@ cdef class PropID(ObjectID):
Compare this property list (or class) to another for equality.
"""
- return pybool(H5Pequal(self.id, plist.id))
+ return <bint>(H5Pequal(self.id, plist.id))
cdef class PropInstanceID(PropID):
@@ -462,7 +464,7 @@ cdef class PropDCID(PropInstanceID):
Determine if all the filters in the pipelist are available to
the library.
"""
- return pybool(H5Pall_filters_avail(self.id))
+ return <bint>(H5Pall_filters_avail(self.id))
def get_filter(self, int filter_idx):
""" (UINT filter_idx) => TUPLE filter_info
@@ -626,7 +628,7 @@ cdef class PropFAID(PropInstanceID):
cdef size_t increment
cdef hbool_t backing_store
H5Pget_fapl_core(self.id, &increment, &backing_store)
- return (increment, pybool(backing_store))
+ return (increment, <bint>(backing_store))
def set_fapl_family(self, hsize_t memb_size, PropID memb_fapl=None):
""" (UINT memb_size, PropFAID memb_fapl=None)
diff --git a/h5py/h5r.pxd b/h5py/h5r.pxd
index 0c00357..bf9fd89 100644
--- a/h5py/h5r.pxd
+++ b/h5py/h5r.pxd
@@ -10,31 +10,7 @@
#
#-
-include "std_defs.pxi"
-from h5 cimport class ObjectID
-from h5s cimport class SpaceID
-from h5g cimport H5G_obj_t
-
-cdef extern from "hdf5.h":
-
- size_t H5R_DSET_REG_REF_BUF_SIZE
- size_t H5R_OBJ_REF_BUF_SIZE
-
- ctypedef enum H5R_type_t:
- H5R_BADTYPE = (-1),
- H5R_OBJECT,
- H5R_DATASET_REGION,
- H5R_INTERNAL,
- H5R_MAXTYPE
-
- ctypedef haddr_t hobj_ref_t
- ctypedef unsigned char hdset_reg_ref_t[12]
-
- herr_t H5Rcreate(void *ref, hid_t loc_id, char *name, H5R_type_t ref_type,
- hid_t space_id) except *
- hid_t H5Rdereference(hid_t obj_id, H5R_type_t ref_type, void *ref) except *
- hid_t H5Rget_region(hid_t dataset, H5R_type_t ref_type, void *ref) except *
- H5G_obj_t H5Rget_obj_type(hid_t id, H5R_type_t ref_type, void *ref) except *
+include "defs.pxd"
cdef union ref_u:
hobj_ref_t obj_ref
@@ -45,7 +21,3 @@ cdef class Reference:
cdef ref_u ref
cdef readonly int typecode
-
-
-
-
diff --git a/h5py/h5r.pyx b/h5py/h5r.pyx
index e40cdd7..88c53df 100644
--- a/h5py/h5r.pyx
+++ b/h5py/h5r.pyx
@@ -16,13 +16,17 @@
Functions in this module are not well tested.
"""
+include "config.pxi"
+include "sync.pxi"
+
# Pyrex compile-time imports
-from h5g cimport H5G_obj_t
+from h5 cimport init_hdf5, ObjectID
from h5f cimport wrap_identifier
from h5s cimport SpaceID
-# Runtime imports
-import h5
+# Initialization
+init_hdf5()
+
# === Public constants and data structures ====================================
diff --git a/h5py/h5s.pxd b/h5py/h5s.pxd
index 0c2864d..7291bd4 100644
--- a/h5py/h5s.pxd
+++ b/h5py/h5s.pxd
@@ -10,104 +10,11 @@
#
#-
-# This file is based on code from the PyTables project. The complete PyTables
-# license is available at licenses/pytables.txt, in the distribution root
-# directory.
+include "defs.pxd"
-# This file contains code or comments from the HDF5 library. The complete HDF5
-# license is available in the file licenses/hdf5.txt in the distribution
-# root directory.
-
-include "config.pxi"
-include "std_defs.pxi"
from h5 cimport class ObjectID
-from numpy cimport ndarray
cdef class SpaceID(ObjectID):
pass
-cdef extern from "hdf5.h":
-
- int H5S_ALL, H5S_MAX_RANK
- hsize_t H5S_UNLIMITED
-
- # Codes for defining selections
- ctypedef enum H5S_seloper_t:
- H5S_SELECT_NOOP = -1,
- H5S_SELECT_SET = 0,
- H5S_SELECT_OR,
- H5S_SELECT_AND,
- H5S_SELECT_XOR,
- H5S_SELECT_NOTB,
- H5S_SELECT_NOTA,
- H5S_SELECT_APPEND,
- H5S_SELECT_PREPEND,
- H5S_SELECT_INVALID # Must be the last one
-
- ctypedef enum H5S_class_t:
- H5S_NO_CLASS = -1, #/*error */
- H5S_SCALAR = 0, #/*scalar variable */
- H5S_SIMPLE = 1, #/*simple data space */
- # no longer defined in 1.8
- #H5S_COMPLEX = 2 #/*complex data space */
-
- ctypedef enum H5S_sel_type:
- H5S_SEL_ERROR = -1, #/* Error */
- H5S_SEL_NONE = 0, #/* Nothing selected */
- H5S_SEL_POINTS = 1, #/* Sequence of points selected */
- H5S_SEL_HYPERSLABS = 2, #/* "New-style" hyperslab selection defined */
- H5S_SEL_ALL = 3, #/* Entire extent selected */
- H5S_SEL_N = 4 #/*THIS MUST BE LAST */
-
-
- # --- Basic operations ------------------------------------------------------
- hid_t H5Screate(H5S_class_t type) except *
- hid_t H5Scopy(hid_t space_id ) except *
- herr_t H5Sclose(hid_t space_id) except *
-
- # --- Simple dataspace operations -------------------------------------------
- hid_t H5Screate_simple(int rank, hsize_t dims[], hsize_t maxdims[]) except *
- htri_t H5Sis_simple(hid_t space_id) except *
- herr_t H5Soffset_simple(hid_t space_id, hssize_t *offset ) except *
-
- int H5Sget_simple_extent_ndims(hid_t space_id) except *
- int H5Sget_simple_extent_dims(hid_t space_id, hsize_t dims[], hsize_t maxdims[]) except *
- hssize_t H5Sget_simple_extent_npoints(hid_t space_id) except *
- H5S_class_t H5Sget_simple_extent_type(hid_t space_id) except *
-
- # --- Extents ---------------------------------------------------------------
- herr_t H5Sextent_copy(hid_t dest_space_id, hid_t source_space_id ) except *
- herr_t H5Sset_extent_simple(hid_t space_id, int rank,
- hsize_t *current_size, hsize_t *maximum_size ) except *
- herr_t H5Sset_extent_none(hid_t space_id) except *
-
- # --- Dataspace selection ---------------------------------------------------
- H5S_sel_type H5Sget_select_type(hid_t space_id) except *
- hssize_t H5Sget_select_npoints(hid_t space_id) except *
- herr_t H5Sget_select_bounds(hid_t space_id, hsize_t *start, hsize_t *end) except *
-
- herr_t H5Sselect_all(hid_t space_id) except *
- herr_t H5Sselect_none(hid_t space_id) except *
- htri_t H5Sselect_valid(hid_t space_id) except *
-
- hssize_t H5Sget_select_elem_npoints(hid_t space_id) except *
- herr_t H5Sget_select_elem_pointlist(hid_t space_id, hsize_t startpoint,
- hsize_t numpoints, hsize_t *buf) except *
- herr_t H5Sselect_elements(hid_t space_id, H5S_seloper_t op,
- size_t num_elements, hsize_t **coord) except *
-
- hssize_t H5Sget_select_hyper_nblocks(hid_t space_id ) except *
- herr_t H5Sget_select_hyper_blocklist(hid_t space_id,
- hsize_t startblock, hsize_t numblocks, hsize_t *buf ) except *
- herr_t H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op,
- hsize_t start[], hsize_t _stride[],
- hsize_t count[], hsize_t _block[]) except *
-
- IF H5PY_18API:
- herr_t H5Sencode(hid_t obj_id, void *buf, size_t *nalloc)
- hid_t H5Sdecode(void *buf)
-
-
-
-
diff --git a/h5py/h5s.pyx b/h5py/h5s.pyx
index 600af26..b9b4086 100644
--- a/h5py/h5s.pyx
+++ b/h5py/h5s.pyx
@@ -13,15 +13,19 @@
"""
Low-level interface to the "H5S" family of data-space functions.
"""
-include "std_code.pxi"
+
+include "config.pxi"
+include "sync.pxi"
# Pyrex compile-time imports
+from h5 cimport init_hdf5
from utils cimport require_tuple, require_list, convert_dims, convert_tuple, \
- emalloc, efree, pybool, create_numpy_hsize, create_hsize_array
+ emalloc, efree, create_numpy_hsize, create_hsize_array
+from numpy cimport ndarray
from python cimport PyString_FromStringAndSize
-# Runtime imports
-import h5
+# Initialization
+init_hdf5()
cdef object lockid(hid_t id_):
cdef SpaceID space
@@ -189,7 +193,7 @@ cdef class SpaceID(ObjectID):
Determine if an existing dataspace is "simple" (including scalar
dataspaces). Currently all HDF5 dataspaces are simple.
"""
- return pybool(H5Sis_simple(self.id))
+ return <bint>(H5Sis_simple(self.id))
def offset_simple(self, object offset=None):
""" (TUPLE offset=None)
@@ -390,7 +394,7 @@ cdef class SpaceID(ObjectID):
Determine if the current selection falls within
the dataspace extent.
"""
- return pybool(H5Sselect_valid(self.id))
+ return <bint>(H5Sselect_valid(self.id))
# === Point selection functions ===========================================
diff --git a/h5py/h5t.pxd b/h5py/h5t.pxd
index b63aee4..1b8076c 100644
--- a/h5py/h5t.pxd
+++ b/h5py/h5t.pxd
@@ -10,12 +10,8 @@
#
#-
-# This file is based on code from the PyTables project. The complete PyTables
-# license is available at licenses/pytables.txt, in the distribution root
-# directory.
+include "defs.pxd"
-include "config.pxi"
-include "std_defs.pxi"
from h5 cimport class ObjectID
cdef class TypeID(ObjectID):
@@ -70,242 +66,7 @@ cdef class TypeEnumID(TypeCompositeID):
cdef class TypeCompoundID(TypeCompositeID):
pass
-
cdef object typewrap(hid_t id_)
-
-# === HDF5 imports ============================================================
-
-cdef extern from "hdf5.h":
-
- hid_t H5P_DEFAULT
-
- # --- Enumerated constants --------------------------------------------------
-
- # Byte orders
- ctypedef enum H5T_order_t:
- H5T_ORDER_ERROR = -1, # error
- H5T_ORDER_LE = 0, # little endian
- H5T_ORDER_BE = 1, # bit endian
- H5T_ORDER_VAX = 2, # VAX mixed endian
- H5T_ORDER_NONE = 3 # no particular order (strings, bits,..)
-
- # HDF5 signed enums
- ctypedef enum H5T_sign_t:
- H5T_SGN_ERROR = -1, # error
- H5T_SGN_NONE = 0, # this is an unsigned type
- H5T_SGN_2 = 1, # two's complement
- H5T_NSGN = 2 # this must be last!
-
- ctypedef enum H5T_norm_t:
- H5T_NORM_ERROR = -1,
- H5T_NORM_IMPLIED = 0,
- H5T_NORM_MSBSET = 1,
- H5T_NORM_NONE = 2
-
- ctypedef enum H5T_cset_t:
- H5T_CSET_ERROR = -1,
- H5T_CSET_ASCII = 0
-
- ctypedef enum H5T_str_t:
- H5T_STR_ERROR = -1,
- H5T_STR_NULLTERM = 0,
- H5T_STR_NULLPAD = 1,
- H5T_STR_SPACEPAD = 2
-
- # Atomic datatype padding
- ctypedef enum H5T_pad_t:
- H5T_PAD_ZERO = 0,
- H5T_PAD_ONE = 1,
- H5T_PAD_BACKGROUND = 2
-
- # HDF5 type classes
- cdef enum H5T_class_t:
- H5T_NO_CLASS = -1, # error
- H5T_INTEGER = 0, # integer types
- H5T_FLOAT = 1, # floating-point types
- H5T_TIME = 2, # date and time types
- H5T_STRING = 3, # character string types
- H5T_BITFIELD = 4, # bit field types
- H5T_OPAQUE = 5, # opaque types
- H5T_COMPOUND = 6, # compound types
- H5T_REFERENCE = 7, # reference types
- H5T_ENUM = 8, # enumeration types
- H5T_VLEN = 9, # variable-length types
- H5T_ARRAY = 10, # array types
- H5T_NCLASSES # this must be last
-
- # Native search direction
- cdef enum H5T_direction_t:
- H5T_DIR_DEFAULT,
- H5T_DIR_ASCEND,
- H5T_DIR_DESCEND
-
- # --- Predefined datatypes --------------------------------------------------
-
- cdef enum:
- H5T_NATIVE_B8
- H5T_NATIVE_CHAR
- H5T_NATIVE_SCHAR
- H5T_NATIVE_UCHAR
- H5T_NATIVE_SHORT
- H5T_NATIVE_USHORT
- H5T_NATIVE_INT
- H5T_NATIVE_UINT
- H5T_NATIVE_LONG
- H5T_NATIVE_ULONG
- H5T_NATIVE_LLONG
- H5T_NATIVE_ULLONG
- H5T_NATIVE_FLOAT
- H5T_NATIVE_DOUBLE
- H5T_NATIVE_LDOUBLE
-
- # "Standard" types
- cdef enum:
- H5T_STD_I8LE
- H5T_STD_I16LE
- H5T_STD_I32LE
- H5T_STD_I64LE
- H5T_STD_U8LE
- H5T_STD_U16LE
- H5T_STD_U32LE
- H5T_STD_U64LE
- H5T_STD_B8LE
- H5T_STD_B16LE
- H5T_STD_B32LE
- H5T_STD_B64LE
- H5T_IEEE_F32LE
- H5T_IEEE_F64LE
- H5T_STD_I8BE
- H5T_STD_I16BE
- H5T_STD_I32BE
- H5T_STD_I64BE
- H5T_STD_U8BE
- H5T_STD_U16BE
- H5T_STD_U32BE
- H5T_STD_U64BE
- H5T_STD_B8BE
- H5T_STD_B16BE
- H5T_STD_B32BE
- H5T_STD_B64BE
- H5T_IEEE_F32BE
- H5T_IEEE_F64BE
-
- cdef enum:
- H5T_NATIVE_INT8
- H5T_NATIVE_UINT8
- H5T_NATIVE_INT16
- H5T_NATIVE_UINT16
- H5T_NATIVE_INT32
- H5T_NATIVE_UINT32
- H5T_NATIVE_INT64
- H5T_NATIVE_UINT64
-
- # Unix time types
- cdef enum:
- H5T_UNIX_D32LE
- H5T_UNIX_D64LE
- H5T_UNIX_D32BE
- H5T_UNIX_D64BE
-
- # String types
- cdef enum:
- H5T_FORTRAN_S1
- H5T_C_S1
-
- # References
- cdef enum:
- H5T_STD_REF_OBJ
- H5T_STD_REF_DSETREG
-
- # --- Datatype operations ---------------------------------------------------
-
- # General operations
- hid_t H5Tcreate(H5T_class_t type, size_t size) except *
- hid_t H5Topen(hid_t loc, char* name) except *
- herr_t H5Tcommit(hid_t loc_id, char* name, hid_t type) except *
- htri_t H5Tcommitted(hid_t type) except *
- hid_t H5Tcopy(hid_t type_id) except *
- htri_t H5Tequal(hid_t type_id1, hid_t type_id2 ) except *
- herr_t H5Tlock(hid_t type_id) except *
- H5T_class_t H5Tget_class(hid_t type_id) except *
- size_t H5Tget_size(hid_t type_id) except? 0
- hid_t H5Tget_super(hid_t type) except *
- htri_t H5Tdetect_class(hid_t type_id, H5T_class_t dtype_class) except *
- herr_t H5Tclose(hid_t type_id) except *
-
- hid_t H5Tget_native_type(hid_t type_id, H5T_direction_t direction) except *
-
- # Not for public API
- herr_t H5Tconvert(hid_t src_id, hid_t dst_id, size_t nelmts, void *buf, void *background, hid_t plist_id) except *
-
- # Atomic datatypes
- herr_t H5Tset_size(hid_t type_id, size_t size) except *
-
- H5T_order_t H5Tget_order(hid_t type_id) except *
- herr_t H5Tset_order(hid_t type_id, H5T_order_t order) except *
-
- hsize_t H5Tget_precision(hid_t type_id) except? 0
- herr_t H5Tset_precision(hid_t type_id, size_t prec) except *
-
- int H5Tget_offset(hid_t type_id) except *
- herr_t H5Tset_offset(hid_t type_id, size_t offset) except *
-
- herr_t H5Tget_pad(hid_t type_id, H5T_pad_t * lsb, H5T_pad_t * msb ) except *
- herr_t H5Tset_pad(hid_t type_id, H5T_pad_t lsb, H5T_pad_t msb ) except *
-
- H5T_sign_t H5Tget_sign(hid_t type_id) except *
- herr_t H5Tset_sign(hid_t type_id, H5T_sign_t sign) except *
-
- herr_t H5Tget_fields(hid_t type_id, size_t *spos, size_t *epos,
- size_t *esize, size_t *mpos, size_t *msize ) except *
- herr_t H5Tset_fields(hid_t type_id, size_t spos, size_t epos,
- size_t esize, size_t mpos, size_t msize ) except *
-
- size_t H5Tget_ebias(hid_t type_id) except? 0
- herr_t H5Tset_ebias(hid_t type_id, size_t ebias) except *
- H5T_norm_t H5Tget_norm(hid_t type_id) except *
- herr_t H5Tset_norm(hid_t type_id, H5T_norm_t norm) except *
- H5T_pad_t H5Tget_inpad(hid_t type_id) except *
- herr_t H5Tset_inpad(hid_t type_id, H5T_pad_t inpad) except *
- H5T_cset_t H5Tget_cset(hid_t type_id) except *
- herr_t H5Tset_cset(hid_t type_id, H5T_cset_t cset) except *
- H5T_str_t H5Tget_strpad(hid_t type_id) except *
- herr_t H5Tset_strpad(hid_t type_id, H5T_str_t strpad) except *
-
- # VLENs
- hid_t H5Tvlen_create(hid_t base_type_id) except *
- htri_t H5Tis_variable_str(hid_t dtype_id) except *
-
- # Compound data types
- int H5Tget_nmembers(hid_t type_id) except *
- H5T_class_t H5Tget_member_class(hid_t type_id, int member_no) except *
- char* H5Tget_member_name(hid_t type_id, unsigned membno) except? NULL
- hid_t H5Tget_member_type(hid_t type_id, unsigned membno) except *
- int H5Tget_member_offset(hid_t type_id, int membno) except *
- int H5Tget_member_index(hid_t type_id, char* name) except *
- herr_t H5Tinsert(hid_t parent_id, char *name, size_t offset,
- hid_t member_id) except *
- herr_t H5Tpack(hid_t type_id) except *
-
- # Enumerated types
- hid_t H5Tenum_create(hid_t base_id) except *
- herr_t H5Tenum_insert(hid_t type, char *name, void *value) except *
- herr_t H5Tenum_nameof( hid_t type, void *value, char *name, size_t size ) except *
- herr_t H5Tenum_valueof( hid_t type, char *name, void *value ) except *
- herr_t H5Tget_member_value(hid_t type, unsigned int memb_no, void *value ) except *
-
- # Array data types
- hid_t H5Tarray_create(hid_t base_id, int ndims, hsize_t dims[], int perm[]) except *
- int H5Tget_array_ndims(hid_t type_id) except *
- int H5Tget_array_dims(hid_t type_id, hsize_t dims[], int perm[]) except *
-
- # Opaque data types
- herr_t H5Tset_tag(hid_t type_id, char* tag) except *
- char* H5Tget_tag(hid_t type_id) except? NULL
-
- IF H5PY_18API:
- hid_t H5Tdecode(unsigned char *buf) except *
- herr_t H5Tencode(hid_t obj_id, unsigned char *buf, size_t *nalloc) except *
diff --git a/h5py/h5t.pyx b/h5py/h5t.pyx
index 7484a3b..9b1b994 100644
--- a/h5py/h5t.pyx
+++ b/h5py/h5t.pyx
@@ -58,24 +58,23 @@
"""
include "config.pxi"
+include "sync.pxi"
# Pyrex compile-time imports
-from h5 cimport PHIL, get_phil
+from h5 cimport init_hdf5, PHIL, get_phil
from numpy cimport dtype, ndarray
from python cimport PyString_FromStringAndSize
-from utils cimport emalloc, efree, pybool, \
+from utils cimport emalloc, efree, \
create_ieee_complex64, create_ieee_complex128, \
require_tuple, convert_dims, convert_tuple
+# Initialization
+init_hdf5()
+
# Runtime imports
-import h5
import sys
-cdef PHIL phil
-phil = get_phil()
-phil.acquire()
-phil.release()
# === Custom C API ============================================================
@@ -359,7 +358,7 @@ cdef class TypeID(ObjectID):
Determine if a given type object is named (T) or transient (F).
"""
- return pybool(H5Tcommitted(self.id))
+ return <bint>(H5Tcommitted(self.id))
def copy(self):
""" () => TypeID
@@ -374,7 +373,7 @@ cdef class TypeID(ObjectID):
Test whether two identifiers refer to the same datatype. Seems
to perform a logical comparison.
"""
- return pybool(H5Tequal(self.id, typeid.id))
+ return <bint>(H5Tequal(self.id, typeid.id))
def lock(self):
""" ()
@@ -419,7 +418,7 @@ cdef class TypeID(ObjectID):
Determine if a member of the given class exists in a compound
datatype. The search is recursive.
"""
- return pybool(H5Tdetect_class(self.id, <H5T_class_t>classtype))
+ return <bint>(H5Tdetect_class(self.id, <H5T_class_t>classtype))
def _close(self):
""" Close this datatype. If it's locked, nothing happens.
@@ -555,7 +554,7 @@ cdef class TypeStringID(TypeID):
Please note that reading/writing data in this format is impossible;
only fixed-length strings are currently supported.
"""
- return pybool(H5Tis_variable_str(self.id))
+ return <bint>(H5Tis_variable_str(self.id))
def get_cset(self):
""" () => INT character_set
diff --git a/h5py/h5z.pxd b/h5py/h5z.pxd
index d8b3bc9..2116324 100644
--- a/h5py/h5z.pxd
+++ b/h5py/h5z.pxd
@@ -10,53 +10,5 @@
#
#-
-include "std_defs.pxi"
-
-cdef extern from "hdf5.h":
-
- ctypedef int H5Z_filter_t
-
- int H5Z_FILTER_ERROR
- int H5Z_FILTER_NONE
- int H5Z_FILTER_ALL
- int H5Z_FILTER_DEFLATE
- int H5Z_FILTER_SHUFFLE
- int H5Z_FILTER_FLETCHER32
- int H5Z_FILTER_SZIP
- int H5Z_FILTER_RESERVED
- int H5Z_FILTER_MAX
- int H5Z_MAX_NFILTERS
-
- int H5Z_FLAG_DEFMASK
- int H5Z_FLAG_MANDATORY
- int H5Z_FLAG_OPTIONAL
-
- int H5Z_FLAG_INVMASK
- int H5Z_FLAG_REVERSE
- int H5Z_FLAG_SKIP_EDC
-
- int H5_SZIP_ALLOW_K13_OPTION_MASK #1
- int H5_SZIP_CHIP_OPTION_MASK #2
- int H5_SZIP_EC_OPTION_MASK #4
- int H5_SZIP_NN_OPTION_MASK #32
- int H5_SZIP_MAX_PIXELS_PER_BLOCK #32
-
- int H5Z_FILTER_CONFIG_ENCODE_ENABLED #(0x0001)
- int H5Z_FILTER_CONFIG_DECODE_ENABLED #(0x0002)
-
- cdef enum H5Z_EDC_t:
- H5Z_ERROR_EDC = -1,
- H5Z_DISABLE_EDC = 0,
- H5Z_ENABLE_EDC = 1,
- H5Z_NO_EDC = 2
-
- # --- Filter API ----------------------------------------------------------
- htri_t H5Zfilter_avail(H5Z_filter_t id_) except *
- herr_t H5Zget_filter_info(H5Z_filter_t filter_, unsigned int *filter_config_flags) except *
-
-
-
-
-
-
+include "defs.pxd"
diff --git a/h5py/h5z.pyx b/h5py/h5z.pyx
index 2a437ef..1374264 100644
--- a/h5py/h5z.pyx
+++ b/h5py/h5z.pyx
@@ -14,11 +14,16 @@
"""
Filter API and constants
"""
+
+include "config.pxi"
+include "sync.pxi"
+
# Pyrex compile-time imports
-from utils cimport pybool
+from h5 cimport init_hdf5
+
+# Initialization
+init_hdf5()
-# Runtime imports
-import h5
# === Public constants and data structures ====================================
@@ -66,7 +71,7 @@ def filter_avail(int filter_code):
FILTER_FLETCHER32
FILTER_SZIP
"""
- return pybool(H5Zfilter_avail(<H5Z_filter_t>filter_code))
+ return <bint>H5Zfilter_avail(<H5Z_filter_t>filter_code)
def get_filter_info(int filter_code):
""" (INT filter_code) => INT filter_flags
diff --git a/h5py/std_defs.pxi b/h5py/std_defs.pxi
deleted file mode 100644
index 7805324..0000000
--- a/h5py/std_defs.pxi
+++ /dev/null
@@ -1,74 +0,0 @@
-#+
-#
-# This file is part of h5py, a low-level Python interface to the HDF5 library.
-#
-# Copyright (C) 2008 Andrew Collette
-# http://h5py.alfven.org
-# License: BSD (See LICENSE.txt for full license)
-#
-# $Date$
-#
-#-
-
-# "Boilerplate" definitions which are used in every .pxd file. Also includes
-# the dynamically-generated config.pxi interface file. A companion file
-# "std_code.pxi" goes in every .pyx file.
-
-include "config.pxi"
-
-# === Standard C functions and definitions ===
-
-cdef extern from "stdlib.h":
- ctypedef long size_t
- void *malloc(size_t size)
- void free(void *ptr)
-
-cdef extern from "string.h":
- char *strchr(char *s, int c)
- char *strcpy(char *dest, char *src)
- char *strncpy(char *dest, char *src, size_t n)
- int strcmp(char *s1, char *s2)
- char *strdup(char *s)
- void *memcpy(void *dest, void *src, size_t n)
-
-cdef extern from "time.h":
- ctypedef int time_t
-
-cdef extern from "unistd.h":
- ctypedef long ssize_t
-
-cdef extern from "stdint.h":
- ctypedef signed char int8_t
- ctypedef unsigned char uint8_t
- ctypedef signed int int16_t
- ctypedef unsigned int uint16_t
- ctypedef signed long int int32_t
- ctypedef unsigned long int uint32_t
- ctypedef signed long long int int64_t
- ctypedef signed long long int uint64_t
-
-# === HDF5 types ===
-
-cdef extern from "hdf5.h":
-
- ctypedef int hid_t # In H5Ipublic.h
- ctypedef int hbool_t
- ctypedef int herr_t
- ctypedef int htri_t
- # hsize_t should be unsigned, but Windows platform does not support
- # such an unsigned long long type.
- ctypedef long long hsize_t
- ctypedef signed long long hssize_t
- ctypedef signed long long haddr_t # I suppose this must be signed as well...
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/h5py/std_code.pxi b/h5py/sync.pxi
similarity index 76%
rename from h5py/std_code.pxi
rename to h5py/sync.pxi
index ff7d280..c81e704 100644
--- a/h5py/std_code.pxi
+++ b/h5py/sync.pxi
@@ -10,8 +10,11 @@
#
#-
-# Common, stateless code safe for inclusion in each .pyx file. Also brings
-# in config.pxi.
+# Header file which goes as the first line in all .pyx files. Currently its
+# main function is to help simplify the .pxi-based import fiasco.
+
+# hdr_pxd already brought in hdf5 and stdlib defines. So we just need to
+# include the configs, and define things like synchronization decorators.
include "config.pxi"
@@ -43,7 +46,3 @@ ELSE:
ELSE:
cdef inline object sync(object func):
return func
-
-
-
-
diff --git a/h5py/utils.pxd b/h5py/utils.pxd
index e74ba97..f0042e3 100644
--- a/h5py/utils.pxd
+++ b/h5py/utils.pxd
@@ -10,7 +10,7 @@
#
#-
-include "std_defs.pxi"
+include "defs.pxd"
from numpy cimport ndarray
@@ -20,7 +20,6 @@ cdef extern from "utils_low.h":
hid_t create_ieee_complex64(char byteorder, char* real_name, char* img_name) except -1
hid_t create_ieee_complex128(char byteorder, char* real_name, char* img_name) except -1
-
# Numpy array validation
int check_numpy_read(ndarray arr, hid_t space_id) except 0
int check_numpy_write(ndarray arr, hid_t space_id) except 0
@@ -37,7 +36,6 @@ cdef object convert_dims(hsize_t* dims, hsize_t rank)
cdef int require_tuple(object tpl, int none_allowed, int size, char* name) except -1
cdef int require_list(object lst, int none_allowed, int size, char* name) except -1
-cdef object pybool(long long val)
cdef object create_numpy_hsize(int rank, hsize_t* dims)
cdef object create_hsize_array(object arr)
diff --git a/h5py/utils.pyx b/h5py/utils.pyx
index f6a490a..0cd1fd1 100644
--- a/h5py/utils.pyx
+++ b/h5py/utils.pyx
@@ -10,12 +10,19 @@
#
#-
+include "config.pxi"
+include "sync.pxi"
+
+# Compile-time imports
+from h5 cimport init_hdf5
from python cimport PyTuple_Check, PyList_Check, PyErr_SetString, Py_INCREF
from numpy cimport import_array, NPY_UINT16, NPY_UINT32, NPY_UINT64, \
npy_intp, PyArray_SimpleNew, PyArray_ContiguousFromAny, \
PyArray_FROM_OTF, NPY_CONTIGUOUS, NPY_NOTSWAPPED, \
NPY_FORCECAST
+# Initialization
+init_hdf5()
import_array()
cdef int convert_tuple(object tpl, hsize_t *dims, hsize_t rank) except -1:
@@ -131,12 +138,6 @@ cdef int require_list(object lst, int none_allowed, int size, char* name) except
PyErr_SetString(ValueError, msg)
return -1
-cdef object pybool(long long val):
- # It seems Pyrex's bool() actually returns some sort of int.
- # This is OK for C, but ugly in Python.
- if val:
- return True
- return False
diff --git a/setup.py b/setup.py
index 96c37b3..4827d04 100644
--- a/setup.py
+++ b/setup.py
@@ -217,7 +217,7 @@ DEF H5PY_THREADS = %(THREADS)d # Enable thread-safety and non-blocking reads
pxi_str %= {"VERSION": VERSION, "API_MAX": max(self.api),
"API_16": 16 in self.api, "API_18": 18 in self.api,
"DEBUG": 10 if self.diag else 0, "THREADS": self.threads,
- "HDF5": HDF5}
+ "HDF5": "Default" if HDF5 is None else HDF5}
return pxi_str
@@ -257,7 +257,7 @@ DEF H5PY_THREADS = %(THREADS)d # Enable thread-safety and non-blocking reads
if self.cython or recompile_all:
print "Running Cython..."
try:
- from Cython.Compiler.Main import Version, compile, CompilationOptions
+ from Cython.Compiler.Main import Version, compile, compile_multiple, CompilationOptions
from Cython.Distutils import build_ext
except ImportError:
fatal("Cython recompilation required, but Cython not installed.")
@@ -270,22 +270,29 @@ DEF H5PY_THREADS = %(THREADS)d # Enable thread-safety and non-blocking reads
print " Diagnostic mode: %s" % ('yes' if self.diag else 'no')
print " HDF5: %s" % ('default' if HDF5 is None else HDF5)
- cyopts = CompilationOptions(verbose=False)
# Build each extension
# This should be a single call to compile_multiple, but it's
# broken in Cython 0.9.8.1.1
- for module in modules:
- pyx_path = op.join(SRC_PATH,module+'.pyx')
- c_path = op.join(SRC_PATH,module+'.c')
- if not op.exists(c_path) or \
- os.stat(pyx_path).st_mtime > os.stat(c_path).st_mtime or \
- recompile_all or\
- self.force:
- print "Cythoning %s" % pyx_path
- result = compile(pyx_path, cyopts)
- if result.num_errors != 0:
- fatal("Cython error; aborting.")
+ if 1:
+ cyopts = CompilationOptions(verbose=False)
+ for module in modules:
+ pyx_path = op.join(SRC_PATH,module+'.pyx')
+ c_path = op.join(SRC_PATH,module+'.c')
+ if not op.exists(c_path) or \
+ os.stat(pyx_path).st_mtime > os.stat(c_path).st_mtime or \
+ recompile_all or\
+ self.force:
+ print "Cythoning %s" % pyx_path
+ result = compile(pyx_path, cyopts)
+ if result.num_errors != 0:
+ fatal("Cython error; aborting.")
+ else:
+ cyopts = CompilationOptions(verbose=True, timestamps=True)
+ modpaths = [op.join(SRC_PATH, x+'.pyx') for x in modules]
+ result = compile_multiple(modpaths, cyopts)
+ if result.num_errors != 0:
+ fatal("%d Cython errors; aborting" % result.num_errors)
if self.cython_only:
exit(0)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/h5py.git
More information about the debian-science-commits
mailing list