Commit 366281a4 authored by Jan Kotanski's avatar Jan Kotanski
Browse files

New upstream version 2.9.0

parent 96ff622b
Announcing HDF5 for Python (h5py) 2.5.0
The h5py team is happy to announce the availability of h5py 2.5.0.
This release introduces experimental support for the highly-anticipated
"Single Writer Multiple Reader" (SWMR) feature in the upcoming HDF5 1.10
release. SWMR allows sharing of a single HDF5 file between multiple processes
without the complexity of MPI or multiprocessing-based solutions.
This is an experimental feature that should NOT be used in production code.
We are interested in getting feedback from the broader community with respect
to performance and the API design.
For more details, check out the h5py user guide:
SWMR support was contributed by Ulrik Pedersen.
What's h5py?
The h5py package is a Pythonic interface to the HDF5 binary data format.
It lets you store huge amounts of numerical data, and easily manipulate
that data from NumPy. For example, you can slice into multi-terabyte
datasets stored on disk, as if they were real NumPy arrays. Thousands of
datasets can be stored in a single file, categorized and tagged however
you want.
Documentation is at:
* Experimental SWMR support
* Group and AttributeManager classes now inherit from the appropriate ABCs
* Fixed an issue with 64-bit float VLENS
* Cython warning cleanups related to "const"
* Entire code base ported to "six"; 2to3 removed from
This release incorporates changes from, among others:
* Ulrik Pedersen
* James Tocknell
* Will Parkin
* Antony Lee
* Peter H. Li
* Peter Colberg
* Ghislain Antony Vaillant
Where to get it
Downloads, documentation, and more are available at the h5py website:
include ANN.rst
include pylintrc
include README.rst
include tox.ini
recursive-include docs *
prune docs/_build
recursive-include docs_api *
prune docs_api/_build
recursive-include examples *.py
recursive-include h5py *.h *.pyx *.pxd *.pxi *.py *.txt
exclude h5py/config.pxi
exclude h5py/defs.pxd
exclude h5py/defs.pyx
recursive-include licenses *
recursive-include lzf *
recursive-include windows *
recursive-exclude * .DS_Store
exclude ci other .github
recursive-exclude ci *
recursive-exclude other *
recursive-exclude .github *
exclude *.yml
exclude *.yaml
recursive-exclude * __pycache__
recursive-exclude * *.py[co]
Metadata-Version: 1.1
Name: h5py
Version: 2.9.0
Summary: Read and write HDF5 files from Python
Author: Andrew Collette
License: BSD
The h5py package provides both a high- and low-level interface to the HDF5
library from Python. The low-level interface is intended to be a complete
wrapping of the HDF5 API, while the high-level component supports access to
HDF5 files, datasets and groups using established Python and NumPy concepts.
A strong emphasis on automatic conversion between Python (Numpy) datatypes and
data structures and their HDF5 equivalents vastly simplifies the process of
reading and writing data from Python.
Supports HDF5 versions 1.8.4 and higher. On Windows, HDF5 is included with
the installer.
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Cython
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Database
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Operating System :: Unix
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Operating System :: Microsoft :: Windows
.. image::
.. image::
HDF5 for Python
`h5py` is a thin, pythonic wrapper around the `HDF5 <>`_, which runs on Python 2.7, and Python 3 (3.4+).
* Main website:
* Source code:
* Mailing list:
Pre-build `h5py` can either be installed via your Python Distribution (e.g.
`Continuum Anaconda`_, `Enthought Canopy`_) or from `PyPI`_ via `pip`_.
`h5py` is also distributed in many Linux Distributions (e.g. Ubuntu, Fedora),
and in the MacOS package managers `Homebrew <>`_,
`Macports <>`_, or `Fink <>`_.
More detailed installation instructions, including how to install `h5py` with
MPI support, can be found at:
Reporting bugs
Open a bug at For general questions, ask
on the list (
.. _`Continuum Anaconda`:
.. _`Enthought Canopy`:
.. _`PyPI`:
.. _`pip`:
Generate the lowest-level Cython bindings to HDF5.
In order to translate HDF5 errors to exceptions, the raw HDF5 API is
wrapped with Cython "error wrappers". These are cdef functions with
the same names and signatures as their HDF5 equivalents, but implemented
in the h5py.defs extension module.
The h5py.defs files (defs.pyx and defs.pxd), along with the "real" HDF5
function definitions (_hdf5.pxd), are auto-generated by this script from
api_functions.txt. This file also contains annotations which indicate
whether a function requires a certain minimum version of HDF5, an
MPI-aware build of h5py, or special error handling.
This script is called automatically by the h5py build system when the
output files are missing, or api_functions.txt has been updated.
See the Line class in this module for documentation of the format for
h5py/_hdf5.pxd: Cython "extern" definitions for HDF5 functions
h5py/defs.pxd: Cython definitions for error wrappers
h5py/defs.pyx: Cython implementations of error wrappers
import re
import os.path as op
class Line(object):
Represents one line from the api_functions.txt file.
Exists to provide the following attributes:
mpi: Bool indicating if MPI required
error: Bool indicating if special error handling required
version: None or a minimum-version tuple
code: String with function return type
fname: String with function name
sig: String with raw function signature
args: String with sequence of arguments to call function
Example: MPI ERROR 1.8.12 int foo(char* a, size_t b)
.mpi: True
.error: True
.version: (1, 8, 12)
.code: "int"
.fname: "foo"
.sig: "char* a, size_t b"
.args: "a, b"
PATTERN = re.compile("""(?P<mpi>(MPI)[ ]+)?
(?P<error>(ERROR)[ ]+)?
([ ]+)?
(?P<code>(unsigned[ ]+)?[a-zA-Z_]+[a-zA-Z0-9_]*\**)[ ]+
(?P<fname>[a-zA-Z_]+[a-zA-Z0-9_]*)[ ]*
\((?P<sig>[a-zA-Z0-9_,* ]*)\)
""", re.VERBOSE)
SIG_PATTERN = re.compile("""
(?:unsigned[ ]+)?
[ ]+[ *]*
""", re.VERBOSE)
def __init__(self, text):
""" Break the line into pieces and populate object attributes.
text: A valid function line, with leading/trailing whitespace stripped.
m = self.PATTERN.match(text)
if m is None:
raise ValueError("Invalid line encountered: {0}".format(text))
parts = m.groupdict()
self.mpi = parts['mpi'] is not None
self.error = parts['error'] is not None
self.version = parts['version']
if self.version is not None:
self.version = tuple(int(x) for x in self.version.split('.'))
self.code = parts['code']
self.fname = parts['fname']
self.sig = parts['sig']
sig_const_stripped = self.sig.replace('const', '')
self.args = self.SIG_PATTERN.findall(sig_const_stripped)
if self.args is None:
raise ValueError("Invalid function signature: {0}".format(self.sig))
self.args = ", ".join(self.args)
raw_preamble = """\
include "config.pxi"
from api_types_hdf5 cimport *
from api_types_ext cimport *
def_preamble = """\
include "config.pxi"
from api_types_hdf5 cimport *
from api_types_ext cimport *
imp_preamble = """\
include "config.pxi"
from api_types_ext cimport *
from api_types_hdf5 cimport *
cimport _hdf5
from _errors cimport set_exception
class LineProcessor(object):
def run(self):
# Function definitions file
self.functions = open(op.join('h5py', 'api_functions.txt'), 'r')
# Create output files
self.raw_defs = open(op.join('h5py', '_hdf5.pxd'), 'w')
self.cython_defs = open(op.join('h5py', 'defs.pxd'), 'w')
self.cython_imp = open(op.join('h5py', 'defs.pyx'), 'w')
for text in self.functions:
# Directive specifying a header file
if not text.startswith(' ') and not text.startswith('#') and \
len(text.strip()) > 0:
inc = text.split(':')[0]
self.raw_defs.write('cdef extern from "%s.h":\n' % inc)
text = text.strip()
# Whitespace or comment line
if len(text) == 0 or text[0] == '#':
# Valid function line
self.line = Line(text)
def add_cython_if(self, block):
""" Wrap a block of code in the required "IF" checks """
def wrapif(condition, code):
code = code.replace('\n', '\n ', code.count('\n')-1) # Yes, -1.
code = "IF {0}:\n {1}".format(condition, code)
return code
if self.line.mpi:
block = wrapif('MPI', block)
if self.line.version is not None:
block = wrapif('HDF5_VERSION >= {0.version}'.format(self.line), block)
return block
def write_raw_sig(self):
""" Write out "cdef extern"-style definition for an HDF5 function """
raw_sig = "{0.code} {0.fname}({0.sig}) except *\n".format(self.line)
raw_sig = self.add_cython_if(raw_sig)
raw_sig = "\n".join((" "+x if x.strip() else x) for x in raw_sig.split("\n"))
def write_cython_sig(self):
""" Write out Cython signature for wrapper function """
cython_sig = "cdef {0.code} {0.fname}({0.sig}) except *\n".format(self.line)
cython_sig = self.add_cython_if(cython_sig)
def write_cython_imp(self):
""" Write out Cython wrapper implementation """
# Figure out what test and return value to use with error reporting
if '*' in self.line.code or self.line.code in ('H5T_conv_t',):
condition = "==NULL"
retval = "NULL"
elif self.line.code in ('int', 'herr_t', 'htri_t', 'hid_t','hssize_t','ssize_t') \
or re.match(r'H5[A-Z]+_[a-zA-Z_]+_t', self.line.code):
condition = "<0"
retval = "-1"
elif self.line.code in ('unsigned int','haddr_t','hsize_t','size_t'):
condition = "==0"
retval = 0
raise ValueError("Return code <<%s>> unknown" % self.line.code)
# Have to use except * because Cython can't handle special types here
imp = """\
cdef {0.code} {0.fname}({0.sig}) except *:
cdef {0.code} r
_hdf5.H5Eset_auto(NULL, NULL)
r = _hdf5.{0.fname}({0.args})
if r{condition}:
if set_exception():
return <{0.code}>{retval}
elif {0.error}:
raise RuntimeError("Unspecified error in {0.fname} (return value {condition})")
return r
imp = imp.format(self.line, condition=condition, retval=retval)
imp = self.add_cython_if(imp)
def run():
lp = LineProcessor()
if __name__ == '__main__':
# Makefile for Sphinx documentation
# You can set these variables from the command line.
SPHINXBUILD = sphinx-build
BUILDDIR = _build
# User-friendly check for sphinx-build
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
# the i18n builder cannot share the environment and doctrees with the others
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " devhelp to make HTML files and a Devhelp project"
@echo " epub to make an epub"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " texinfo to make Texinfo files"
@echo " info to make Texinfo files and run them through makeinfo"
@echo " gettext to make PO message catalogs"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " xml to make Docutils-native XML files"
@echo " pseudoxml to make pseudoxml-XML files for display purposes"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
rm -rf $(BUILDDIR)/*
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
@echo "Build finished; now you can process the pickle files."
@echo "Build finished; now you can process the JSON files."
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/h5py.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/h5py.qhc"
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/h5py"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/h5py"
@echo "# devhelp"
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."
@echo "Running LaTeX files through pdflatex..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
@echo "Running LaTeX files through platex and dvipdfmx..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
@echo "Build finished. The text files are in $(BUILDDIR)/text."
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
@echo "Run \`make' in that directory to run these through makeinfo" \
"(use \`make info' here to do that automatically)."
@echo "Running Texinfo files through makeinfo..."
make -C $(BUILDDIR)/texinfo info
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
@echo "The overview file is in $(BUILDDIR)/changes."
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."
@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
.. _install:
.. _install_recommends:
It is highly recommended that you use a pre-built version of h5py, either from a
Python Distribution, an OS-specific package manager, or a pre-built wheel from
Be aware however that most pre-built versions lack MPI support, and that they
are built against a specific version of HDF5. If you require MPI support, or
newer HDF5 features, you will need to build from source.
After installing h5py, you should run the tests to be sure that everything was
installed correctly. This can be done in the python interpreter via::
import h5py
On Python 2.6 and 2.7, unittest2 must be installed to run the tests.
.. _prebuilt_install:
Pre-built installation (recommended)