[h5py] 60/455: Setup.py will now compile extensions without Pyrex; fix mistakes with H5E calls, __copy__ methods
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Thu Jul 2 18:19:17 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 6b528e5f65f8ab9c7d9e9234d08089d3308c670f
Author: andrewcollette <andrew.collette at gmail.com>
Date: Fri Jun 20 23:56:26 2008 +0000
Setup.py will now compile extensions without Pyrex; fix mistakes with H5E calls, __copy__ methods
---
MANIFEST.in | 4 +-
TODO.txt | 14 -----
VERSION.txt | 1 +
h5py/h5.pxd | 2 +-
h5py/h5.pyx | 16 +++--
h5py/h5p.pyx | 16 ++---
h5py/h5t.pyx | 4 ++
setup.py | 201 +++++++++++++++++++++++++++++++----------------------------
8 files changed, 133 insertions(+), 125 deletions(-)
diff --git a/MANIFEST.in b/MANIFEST.in
index 57e2a77..13a5cf4 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,9 +1,9 @@
include MANIFEST.in
include LICENSE.txt
include README.txt
+include VERSION.txt
include docs.cfg
-recursive-include h5py *.py *.pyx *.pxd
-recursive-include h5py utils.c utils.h *.hdf5
+recursive-include h5py *.py *.pyx *.pxd *.h *.c *.hdf5
recursive-include licenses *
recursive-include docs *
diff --git a/TODO.txt b/TODO.txt
deleted file mode 100644
index faa2e75..0000000
--- a/TODO.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-Goals for 1.0:
-==============
-
-* 1.6 API coverage
-* Unit tests for every component, including highlevel operations
-* Buildable with 1.8.X in compatibility mode
-
-Additional goals for 2.0:
-=========================
-
-* 1.6 and 1.8 API coverage
-* Switchable between 1.6 and 1.8 API (at compile-time)
-* Windows compatibility
-
diff --git a/VERSION.txt b/VERSION.txt
new file mode 100644
index 0000000..0ea3a94
--- /dev/null
+++ b/VERSION.txt
@@ -0,0 +1 @@
+0.2.0
diff --git a/h5py/h5.pxd b/h5py/h5.pxd
index b63b25a..95f8f4c 100644
--- a/h5py/h5.pxd
+++ b/h5py/h5.pxd
@@ -249,6 +249,7 @@ cdef int resume_errors(err_c cookie) except -1
cdef class ObjectID:
""" Base wrapper class for HDF5 object identifiers """
+ cdef object __weakref__
cdef readonly hid_t id
cdef readonly int _locked
@@ -272,4 +273,3 @@ cdef class ObjectID:
-
diff --git a/h5py/h5.pyx b/h5py/h5.pyx
index 38067ed..036505f 100644
--- a/h5py/h5.pyx
+++ b/h5py/h5.pyx
@@ -17,6 +17,8 @@
Library version and API information lives here:
- HDF5_VERS, HDF5_VERS_TPL: Library version
- API_VERS, API_VERS_TPL: API version (1.6 or 1.8) used to compile h5py.
+
+ All exception classes and error handling functions are also in this module.
"""
from python cimport PyErr_SetObject
@@ -52,10 +54,10 @@ class DDict(dict):
cdef class ObjectID:
- def __cinit__(self, hid_t id):
+ def __cinit__(self, hid_t id_):
""" Object init; simply records the given ID. """
self._locked = 0
- self.id = id
+ self.id = id_
def __dealloc__(self):
""" Automatically decrefs the ID, if it's valid. """
@@ -64,7 +66,9 @@ cdef class ObjectID:
def __copy__(self):
""" Create another object wrapper which points to the same id. """
+ cdef ObjectID copy
copy = type(self)(self.id)
+ assert typecheck(copy, ObjectID), "ObjectID copy encountered invalid type"
if H5Iget_type(self.id) != H5I_BADID and not self._locked:
H5Iinc_ref(self.id)
copy._locked = self._locked
@@ -270,7 +274,7 @@ _exceptions = {
cdef class ErrorStackElement:
"""
Represents an entry in the HDF5 error stack.
- Modeled on the H5E_error_t struct. All parameters are read-only.
+ Modeled on the H5E_error_t struct. All properties are read-only.
Atributes
maj_num: INT major error number
@@ -363,14 +367,14 @@ def get_major(int error):
Get a description associated with an HDF5 minor error code.
"""
- return H5E_get_major(<H5E_major_t>error)
+ return H5Eget_major(<H5E_major_t>error)
def get_minor(int error):
""" (INT error) => STRING description
Get a description associated with an HDF5 minor error code.
"""
- return H5E_get_minor(<H5E_minor_t>error)
+ return H5Eget_minor(<H5E_minor_t>error)
def get_error(int error):
""" (INT errno) => STRING description
@@ -381,7 +385,7 @@ def get_error(int error):
cdef int mn
mn = error % 1000
mj = (error-mn)/1000
- return "%s: %s" % (H5E_get_major(<H5E_major_t>mj), H5E_get_minor(<H5E_minor_t>mn))
+ return "%s: %s" % (H5Eget_major(<H5E_major_t>mj), H5Eget_minor(<H5E_minor_t>mn))
def split_error(int error):
""" (INT errno) => (INT major, INT minor)
diff --git a/h5py/h5p.pyx b/h5py/h5p.pyx
index 07fd11c..d75f2ce 100644
--- a/h5py/h5p.pyx
+++ b/h5py/h5p.pyx
@@ -336,7 +336,7 @@ cdef class PropDCID(PropInstanceID):
return H5Pget_nfilters(self.id)
def set_filter(self, int filter_code, unsigned int flags=0, object values=None):
- """ (INT filter_code, UINT flags=0, LIST values=None)
+ """ (INT filter_code, UINT flags=0, TUPLE values=None)
Set a filter in the pipeline. Params are:
filter_code:
@@ -345,14 +345,14 @@ cdef class PropDCID(PropInstanceID):
h5z.FILTER_FLETCHER32
h5z.FILTER_SZIP
flags: Bit flags (h5z.FLAG_*) setting filter properties
- values: List of UINTS giving auxiliary data for the filter.
+ values: TUPLE of UINTS giving auxiliary data for the filter.
"""
cdef size_t nelements
cdef unsigned int *cd_values
cdef int i
cd_values = NULL
- require_list(values, 1, -1, "values")
+ require_tuple(values, 1, -1, "values")
try:
if values is None or len(values) == 0:
@@ -384,9 +384,10 @@ cdef class PropDCID(PropInstanceID):
Tuple entries are:
0: INT filter code (h5z.FILTER_*)
1: UINT flags (h5z.FLAG_*)
- 2: LIST of UINT values; filter aux data (16 values max)
+ 2: TUPLE of UINT values; filter aux data (16 values max)
3: STRING name of filter (256 chars max)
"""
+ cdef list vlist
cdef int filter_code
cdef unsigned int flags
cdef size_t nelements
@@ -405,7 +406,7 @@ cdef class PropDCID(PropInstanceID):
for i from 0<=i<nelements:
vlist.append(cd_values[i])
- return (filter_code, flags, vlist, name)
+ return (filter_code, flags, tuple(vlist), name)
def get_filter_by_id(self, int filter_code):
""" (INT filter_code) => TUPLE filter_info
@@ -415,9 +416,10 @@ cdef class PropDCID(PropInstanceID):
Tuple entries are:
0: UINT flags (h5z.FLAG_*)
- 1: LIST of UINT values; filter aux data (16 values max)
+ 1: TUPLE of UINT values; filter aux data (16 values max)
2: STRING name of filter (256 chars max)
"""
+ cdef list vlist
cdef unsigned int flags
cdef size_t nelements
cdef unsigned int cd_values[16]
@@ -432,7 +434,7 @@ cdef class PropDCID(PropInstanceID):
for i from 0<=i<nelements:
vlist.append(cd_values[i])
- return (flags, vlist, name)
+ return (flags, tuple(vlist), name)
def remove_filter(self, int filter_class):
""" (INT filter_class)
diff --git a/h5py/h5t.pyx b/h5py/h5t.pyx
index f6784c1..3bb748b 100644
--- a/h5py/h5t.pyx
+++ b/h5py/h5t.pyx
@@ -317,7 +317,9 @@ cdef class TypeID(ObjectID):
self._complex_names = ('r', 'i')
def __copy__(self):
+ cdef TypeID cpy
cpy = ObjectID.__copy__(self)
+ assert typecheck(cpy, TypeID), "TypeID copy encounted invalid type"
cpy._complex_names = self._complex_names
return cpy
@@ -865,6 +867,8 @@ cdef class TypeCompoundID(TypeCompositeID):
cdef object py_dtype(self):
cdef TypeID tmp_type
+ cdef list field_names
+ cdef list field_types
nfields = self.get_nmembers()
field_names = []
field_types = []
diff --git a/setup.py b/setup.py
index 05f0c5f..62d7eb8 100644
--- a/setup.py
+++ b/setup.py
@@ -13,30 +13,38 @@
#-
"""
- Setup script for the h5py package.
-
- To install h5py, run "python setup.py build" followed by
- "python setup.py install". You may need sudo priviledges for the second
- command.
-
- Implements a few new commands, in addition to standard commands like
- "build" and "install":
-
- 1. "test"
- Build the package locally (don't install it) and run unit tests. Exits
- Python with a nonzero error code if any of the unit tests fail. Test
- output (unittest.TextTestRunner) is written to stdout/stderr.
-
- 2. "dev"
- Developer commands. Runs "build" and optionally:
- --doc Rebuilds HTML documentation
- --readme <name> Generates an HTML form of the README.txt document.
-
- New option: "--revision" appends the SVN revision and current build number
- to the version string; again mainly for development.
+ Setup script for the h5py package. All commands take the usual distutils
+ options, like --home, etc. Pyrex is not required for installation.
+
+ To build:
+ python setup.py build [--pyrex]
+ --pyrex: Perform Pyrex recompilation of all .pyx files.
+
+ To install:
+ sudo python setup.py install [--pyrex]
+
+ To run the test suite locally (won't install anything):
+ python setup.py test [--pyrex]
+
+ Advanced developer options:
+ python setup.py dev [--pyrex] [--doc] [--clean] [--readme=<name.html>]
+ --doc: Rebuild HTML documentation (requires epydoc)
+ --clean: Wipe out build/ and Pyrex-created .c, .dep files
+ --readme: Compile the RST readme file into an HTML fragment
"""
-__revision__ = "$Id$"
+# === Global constants ========================================================
+
+NAME = 'h5py'
+MIN_PYREX = '0.9.6.4'
+MIN_NUMPY = '1.0.3'
+
+# If you have your HDF5 *.h files and libraries somewhere not in /usr or
+# /usr/local, add that path here.
+custom_include_dirs = [] # = ["/some/other/path", "/an/other/path"]
+custom_library_dirs = []
+
+# === Initial setup ===========================================================
from distutils.cmd import Command
from distutils.errors import DistutilsError, DistutilsExecError
@@ -56,16 +64,69 @@ try:
except OSError:
pass
-# === Global constants ========================================================
+# === Parse extra command line arguments ======================================
-NAME = 'h5py'
-VERSION = '0.1.1'
-REVISION = "$Rev: 0$"
+ENABLE_PYREX = False
+for arg in sys.argv[:]:
+ if arg.find('--pyrex') == 0:
+ ENABLE_PYREX = True
+ sys.argv.remove(arg)
-# If you have your HDF5 *.h files and libraries somewhere not in /usr or
-# /usr/local, add that path here.
-custom_include_dirs = [] # = ["/some/other/path", "/an/other/path"]
-custom_library_dirs = []
+# === Attempt imports =========================================================
+
+def fatal(instring):
+ print >> sys.stderr, "Fatal: "+instring
+ exit(2)
+
+def warn(instring):
+ print >> sys.stderr, "Warning: "+instring
+
+# Check Python version (2.5 or greater required)
+if not (sys.version_info[0] == 2 and sys.version_info[1] >= 5):
+ fatal("At least Python 2.5 is required to install h5py")
+
+# Check for Numpy (required)
+try:
+ import numpy
+ if numpy.version.version < MIN_NUMPY:
+ fatal("Numpy version %s is out of date (>= %s needed)" % (numpy.version.version, MIN_NUMPY))
+except ImportError:
+ fatal("Numpy (version >= %s) is required" % MIN_NUMPY)
+
+# Enable Pyrex only if requested, unless it's unavailable or out of date
+USE_PYREX = False
+CMD_CLASS = {}
+EXT_EXTEN = '.c'
+if ENABLE_PYREX:
+ try:
+ from Pyrex.Compiler.Main import Version
+ from Pyrex.Distutils import build_ext
+
+ if Version.version >= MIN_PYREX:
+ CMD_CLASS = {'build_ext': build_ext}
+ EXT_EXTEN = '.pyx'
+ USE_PYREX = True
+ else:
+ warn("Pyrex disabled; old version %s detected (min %s)" % (Version.version, MIN_PYREX))
+
+ except ImportError:
+ pass
+
+# === Versioning setup ========================================================
+
+# 1. Read in version from VERSION.txt file
+# 2. Write it to h5py/version.py
+# 3. Copy README into h5py/version.py as docstring
+
+vers_in = open('VERSION.txt')
+VERSION = vers_in.read().strip()
+vers_out = open(os.path.join(NAME,'version.py'),'w')
+rdfile = open('README.txt','r')
+vers_out.write('# This file is automatically generated; do not edit.\n')
+vers_out.write('"""\nPackage "h5py" extended information\n\n%s"""\nversion = "%s"\n\n' % (rdfile.read(), VERSION))
+rdfile.close()
+vers_out.close()
+vers_in.close()
# === Custom extensions for distutils =========================================
@@ -91,7 +152,7 @@ class test(Command):
class dev(Command):
description = "Developer commands (--doc, --readme=<file>)"
user_options = [('doc','d','Rebuild documentation'),
- ('readme=','r','Rebuild HTML readme file'),
+ ('readme=','r','Compile <readme>.html file from README.txt'),
('clean', 'c', 'Remove built files and Pyrex temp files.')]
boolean_options = ['doc', 'inspect']
@@ -118,10 +179,10 @@ class dev(Command):
if self.doc:
buildobj = self.distribution.get_command_obj('build')
buildobj.run()
-
- if self.doc:
- retval = os.spawnlp(os.P_WAIT, 'epydoc', '-q', '--html', '-o', 'docs/',
- '--config', 'docs.cfg', os.path.join(buildobj.build_lib, NAME) )
+
+ retval = os.spawnlp(os.P_WAIT, 'epydoc', '-q', '--html',
+ '-o', 'docs/', '--config', 'docs.cfg',
+ os.path.join(buildobj.build_lib, NAME) )
if retval != 0:
raise DistutilsExecError("Could not run epydoc to build documentation.")
@@ -134,68 +195,17 @@ class dev(Command):
fh.write(parts['body'])
fh.close()
-# === Versioning setup ========================================================
-
-for arg in sys.argv[:]:
- if arg.find('--revision') == 0:
- REVDIGITS = '0'
- try:
- tmpstring = REVISION[5:-2].strip()
- if tmpstring.isdigit(): REVDIGITS = tmpstring
- except KeyError:
- pass
-
- VERSION = VERSION + '-r' + REVDIGITS
-
- sys.argv.remove(arg)
-
-# Automatically update the h5py source with current version info and
-# docstring from current README file
-vfile = open(os.path.join(NAME,'version.py'),'w')
-rdfile = open('README.txt','r')
-vfile.write('# This file is automatically generated; do not edit.\n')
-vfile.write('"""\nPackage "h5py" extended information\n\n%s"""\nversion = "%s"\n\n' % (rdfile.read(), VERSION))
-rdfile.close()
-vfile.close()
+# Add these to the command class dictionary for setup()
+CMD_CLASS.update({'dev': dev, 'test': test})
# === Setup configuration =====================================================
-min_pyrex_version = '0.9.6.4'
-min_numpy_version = '1.0.3'
-
-def fatal(instring):
- print "Fatal: "+instring
- exit(2)
-
-# Check Python version
-if not (sys.version_info[0] >= 2 and sys.version_info[1] >= 5):
- fatal("At least Python 2.5 is required to install h5py")
-
-# Check for Numpy (required)
-try:
- import numpy
- if numpy.version.version < min_numpy_version:
- raise ImportError()
-except ImportError:
- fatal("Numpy version >= %s required" % min_numpy_version)
-
-# Check for Pyrex (also required)
-try:
- from Pyrex.Compiler.Main import Version
- if Version.version < min_pyrex_version:
- raise ImportError()
- from Pyrex.Distutils import build_ext
-except ImportError:
- fatal("Pyrex is unavailable or out of date (>= %s required)." % min_pyrex_version)
-
-ext_exten = '.pyx'
-
# Pyrex extension modules
-pyx_modules = ['h5' , 'h5f', 'h5g', 'h5s', 'h5t',
- 'h5d', 'h5a', 'h5p', 'h5z', 'h5i', 'h5r', 'utils']
+pyx_modules = ['h5' , 'h5f', 'h5g', 'h5s', 'h5t', 'h5d',
+ 'h5a', 'h5p', 'h5z', 'h5i', 'h5r', 'utils']
pyx_src_path = 'h5py'
-pyx_extra_src = ['utils_low.c'] # C source files required for Pyrex code
+pyx_extra_src = ['utils_low.c'] # C source files required for Pyrex code
pyx_libraries = ['hdf5'] # Libraries to link into Pyrex code
# Compile-time include and library dirs for Pyrex code
@@ -217,7 +227,7 @@ extra_compile_args = pyx_extra_args
# Create extensions
pyx_extensions = []
for module_name in pyx_modules:
- sources = [os.path.join(pyx_src_path, module_name) + ext_exten]
+ sources = [os.path.join(pyx_src_path, module_name) + EXT_EXTEN]
sources += [os.path.join(pyx_src_path, x) for x in pyx_extra_src]
pyx_extensions.append(
@@ -232,6 +242,7 @@ for module_name in pyx_modules:
)
)
+
# Run setup
setup(
name = NAME,
@@ -241,10 +252,10 @@ setup(
packages = ['h5py','h5py.tests'],
package_data = {'h5py': ['*.pyx'], # so source is available for tracebacks
'h5py.tests': ['data/*.hdf5']},
- ext_modules= pyx_extensions,
- requires = ['numpy (>=1.0.3)','Pyrex (>=0.9.6)'], # "0.9.6.4 is not a valid version string"???
+ ext_modules = pyx_extensions,
+ requires = ['numpy (>=1.0.3)'],
provides = ['h5py'],
- cmdclass = {'build_ext': build_ext, 'dev': dev, 'test': test}
+ cmdclass = CMD_CLASS
)
--
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