diff --git a/h5py-Dont-reorder-compound-types.patch b/h5py-Dont-reorder-compound-types.patch new file mode 100644 index 0000000..d7f2074 --- /dev/null +++ b/h5py-Dont-reorder-compound-types.patch @@ -0,0 +1,96 @@ +diff -Naur h5py-2.7.1/h5py/h5t.pyx h5py-2.7.1.fixed/h5py/h5t.pyx +--- h5py-2.7.1/h5py/h5t.pyx 2017-09-01 06:12:23.000000000 +0200 ++++ h5py-2.7.1.fixed/h5py/h5t.pyx 2018-02-13 18:52:30.668283856 +0100 +@@ -1136,12 +1136,6 @@ + else: + if sys.version[0] == '3': + field_names = [x.decode('utf8') for x in field_names] +- if len(field_names) > 0: +- collated_fields = zip(field_names, field_types, field_offsets) +- ordered_fields = sorted( +- collated_fields, key=operator.itemgetter(2)) +- field_names, field_types, field_offsets = \ +- map(list, zip(*ordered_fields)) + typeobj = dtype({ + 'names': field_names, + 'formats': field_types, +@@ -1458,8 +1452,7 @@ + cdef dtype member_dt + cdef size_t member_offset = 0 + +- cdef dict offsets = {} +- cdef list fields = [] ++ cdef dict fields = {} + + # The challenge with correctly converting a numpy/h5py dtype to a HDF5 type + # which is composed of subtypes has three aspects we must consider +@@ -1468,19 +1461,14 @@ + # 2. For correct round-tripping of aligned dtypes, we need to consider how + # much padding we need by looking at the field offsets + # 3. There is no requirement that the offsets be monotonically increasing +- # (so we start by sorting the names as a function of increasing offset) + # + # The code below tries to cover these aspects + +- # Get offsets for each compound member +- for name, field in dt.fields.items(): +- offsets[name] = field[1] +- + # Build list of names, offsets, and types, sorted by increasing offset + # (i.e. the position of the member in the struct) +- for name in sorted(dt.names, key=offsets.__getitem__): ++ for name in sorted(dt.names, key=(lambda n: dt.fields[n][1])): + field = dt.fields[name] +- name = name.encode('utf8') if isinstance(name, unicode) else name ++ h5_name = name.encode('utf8') if isinstance(name, unicode) else name + + # Get HDF5 data types and set the offset for each member + member_dt = field[0] +@@ -1489,7 +1477,7 @@ + if aligned and (member_offset > field[1] + or member_dt.itemsize != member_type.get_size()): + raise TypeError("Enforced alignment not compatible with HDF5 type") +- fields.append((name, member_offset, member_type)) ++ fields[name] = (h5_name, member_offset, member_type) + + # Update member offset based on the HDF5 type size + member_offset += member_type.get_size() +@@ -1500,8 +1488,9 @@ + + # Create compound with the necessary size, and insert its members + tid = H5Tcreate(H5T_COMPOUND, member_offset) +- for (name, member_offset, member_type) in fields: +- H5Tinsert(tid, name, member_offset, member_type.id) ++ for name in dt.names: ++ h5_name, member_offset, member_type = fields[name] ++ H5Tinsert(tid, h5_name, member_offset, member_type.id) + + return TypeCompoundID(tid) + +diff -Naur h5py-2.7.1/setup.py h5py-2.7.1.fixed/setup.py +--- h5py-2.7.1/setup.py 2017-09-02 00:59:17.000000000 +0200 ++++ h5py-2.7.1.fixed/setup.py 2018-02-13 18:52:30.668283856 +0100 +@@ -32,7 +32,7 @@ + # these are required to build h5py + # RUN_REQUIRES is included as setup.py test needs RUN_REQUIRES for testing + # RUN_REQUIRES can be removed when setup.py test is removed +-SETUP_REQUIRES = RUN_REQUIRES + [NUMPY_DEP, 'Cython>=0.19', 'pkgconfig'] ++SETUP_REQUIRES = RUN_REQUIRES + [NUMPY_DEP, 'Cython>=0.23', 'pkgconfig'] + + # Needed to avoid trying to install numpy/cython on pythons which the latest + # versions don't support +diff -Naur h5py-2.7.1/tox.ini h5py-2.7.1.fixed/tox.ini +--- h5py-2.7.1/tox.ini 2017-08-20 23:18:18.000000000 +0200 ++++ h5py-2.7.1.fixed/tox.ini 2018-02-13 18:55:00.427628930 +0100 +@@ -4,9 +4,9 @@ + [testenv] + deps = + deps: numpy>=1.7 +- deps: cython>=0.19 ++ deps: cython>=0.23 + mindeps: numpy==1.7 +- mindeps: cython==0.19 ++ mindeps: cython==0.23 + commands = + test: python {toxinidir}/ci/fix_paths.py {envsitepackagesdir} + test: python -c "from sys import exit; import h5py; exit(0) if h5py.run_tests().wasSuccessful() else exit(1)"