Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding h5py recipe #685

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions recipes/recipes_emscripten/h5py/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

export HDF5_DIR=${PREFIX}

# tell setup.py to not 'pip install' exact package requirements
export H5PY_SETUP_REQUIRES="0"

shimwell marked this conversation as resolved.
Show resolved Hide resolved
# tell setup_configure.py not to compile with ROS3 driver support
export H5PY_ROS3="0"
shimwell marked this conversation as resolved.
Show resolved Hide resolved

"${PYTHON}" -m pip install . --no-deps --ignore-installed --no-cache-dir -vv
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
From 30ba08deaa551b0920530f6b2edac59f2dd9e28e Mon Sep 17 00:00:00 2001
From: Gyeongjae Choi <[email protected]>
Date: Fri, 2 Sep 2022 07:54:44 +0000
Subject: [PATCH] Fix incompatible pointer type

---
h5py/_errors.pxd | 2 +-
h5py/_errors.pyx | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/h5py/_errors.pxd b/h5py/_errors.pxd
index 13b299e2..e7791a6b 100644
--- a/h5py/_errors.pxd
+++ b/h5py/_errors.pxd
@@ -412,7 +412,7 @@ cdef extern from "hdf5.h":

herr_t H5Eprint(hid_t estack_id, void *stream)

- ctypedef herr_t (*H5E_walk_t)(int n, H5E_error_t *err_desc, void* client_data)
+ ctypedef herr_t (*H5E_walk_t)(unsigned int n, const H5E_error_t *err_desc, void* client_data)
herr_t H5Ewalk(hid_t estack_id, H5E_direction_t direction, H5E_walk_t func, void* client_data)

# --- Functions for managing the HDF5 error callback mechanism ---
diff --git a/h5py/_errors.pyx b/h5py/_errors.pyx
index 612052fb..dabbc632 100644
--- a/h5py/_errors.pyx
+++ b/h5py/_errors.pyx
@@ -94,7 +94,7 @@ cdef struct err_data_t:
H5E_error_t err
int n

-cdef herr_t walk_cb(int n, H5E_error_t *desc, void *e) nogil:
+cdef herr_t walk_cb(unsigned int n, const H5E_error_t *desc, void *e) nogil:

cdef err_data_t *ee = <err_data_t*>e

@@ -120,7 +120,7 @@ cdef int set_exception() except -1:

err.n = -1

- if H5Ewalk(<hid_t>H5E_DEFAULT, H5E_WALK_UPWARD, walk_cb, &err) < 0:
+ if H5Ewalk(<hid_t>H5E_DEFAULT, H5E_WALK_UPWARD, &walk_cb, &err) < 0:
raise RuntimeError("Failed to walk error stack")

if err.n < 0: # No HDF5 exception information found
@@ -137,7 +137,7 @@ cdef int set_exception() except -1:

err.n = -1

- if H5Ewalk(<hid_t>H5E_DEFAULT, H5E_WALK_DOWNWARD, walk_cb, &err) < 0:
+ if H5Ewalk(<hid_t>H5E_DEFAULT, H5E_WALK_DOWNWARD, &walk_cb, &err) < 0:
raise RuntimeError("Failed to walk error stack")

desc_bottom = err.err.desc
--
2.37.2

65 changes: 65 additions & 0 deletions recipes/recipes_emscripten/h5py/patches/configure.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
From 7aea0dd0b4b86d9c607acc981d8055e55c9685bb Mon Sep 17 00:00:00 2001
From: ryanking13 <[email protected]>
Date: Thu, 30 Jun 2022 05:30:27 +0000
Subject: [PATCH] Fix feature detection

---
setup_configure.py | 26 ++++----------------------
1 file changed, 4 insertions(+), 22 deletions(-)

diff --git a/setup_configure.py b/setup_configure.py
index c16ddeef..1180d3fa 100644
--- a/setup_configure.py
+++ b/setup_configure.py
@@ -206,7 +206,7 @@ class BuildConfig:
class HDF5LibWrapper:

def __init__(self, libdirs):
- self._load_hdf5_lib(libdirs)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not chased through how, but I think that this patch is breaking all of h5py's auto-detection of what capabilities the wrapped libhdf5 has.

+ pass

def _load_hdf5_lib(self, libdirs):
"""
@@ -268,25 +268,7 @@ class HDF5LibWrapper:
self._lib = lib

def autodetect_version(self):
- """
- Detect the current version of HDF5, and return X.Y.Z version string.
-
- Raises an exception if anything goes wrong.
- """
- import ctypes
- from ctypes import byref
-
- major = ctypes.c_uint()
- minor = ctypes.c_uint()
- release = ctypes.c_uint()
-
- try:
- self._lib.H5get_libversion(byref(major), byref(minor), byref(release))
- except Exception:
- print("error: Unable to find HDF5 version")
- raise
-
- return int(major.value), int(minor.value), int(release.value)
+ return (1, 12, 1)

def load_function(self, func_name):
try:
@@ -302,10 +284,10 @@ class HDF5LibWrapper:
return True

def has_mpi_support(self):
- return self.has_functions("H5Pget_fapl_mpio", "H5Pset_fapl_mpio")
+ return False

def has_ros3_support(self):
- return self.has_functions("H5Pget_fapl_ros3", "H5Pset_fapl_ros3")
+ return False

def has_direct_vfd_support(self):
return self.has_functions("H5Pget_fapl_direct", "H5Pset_fapl_direct")
--
2.35.1

52 changes: 52 additions & 0 deletions recipes/recipes_emscripten/h5py/recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
context:
name: h5py
version: "3.10.0"

package:
name: h5py
version: "{{ version }}"

source:
- url: https://github.com/h5py/h5py/archive/{{ version }}.tar.gz
sha256: 9cac7838ab139ec71adf721a1305b954e18efa4f80c82fcfe34e1eb9639ded29
- path: setup.py

build:
number: 0

requirements:
build:
- '{{ compiler("c") }}'
- cross-python_emscripten-wasm32
- cython >=0.29.31,<1
shimwell marked this conversation as resolved.
Show resolved Hide resolved
- hdf5
- numpy
- cython >=0.29.31,<1
shimwell marked this conversation as resolved.
Show resolved Hide resolved
- pkgconfig
host:
- python
- pip
- numpy
- hdf5
run:
- python
- cached-property
- '{{ pin_compatible("numpy") }}'
- hdf5

about:
home: https://www.h5py.org/
license: BSD 3-Clause
license_family: BSD 3-Clause
license_file: LICENSE.txt
summary: Read and write HDF5 files from Python
description: |
The h5py package is a Pythonic interface to the HDF5 binary data format
dev_url: https://github.com/h5py/h5py


extra:
emscripten_tests:
python:
pytest_files:
- test_import_h5py.py
24 changes: 24 additions & 0 deletions recipes/recipes_emscripten/h5py/test_import_h5py.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
def test_import_h5py():
import h5py
import h5py._conv
import h5py._errors
import h5py._objects
import h5py._proxy
import h5py.defs
import h5py.h5
import h5py.h5a
import h5py.h5d
import h5py.h5f
import h5py.h5fd
import h5py.h5g
import h5py.h5i
import h5py.h5l
import h5py.h5o
import h5py.h5p
import h5py.h5r
import h5py.h5s
import h5py.h5t
import h5py.h5z
import h5py.utils

h5py.run_tests()
Loading