Bug 2272984 - h5py fails to build with pytest 8: AssertionError: assert b'/usr/lib64/hdf5/plugin' == b'h5py_plugin_test'
Summary: h5py fails to build with pytest 8: AssertionError: assert b'/usr/lib64/hdf5/p...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: h5py
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Terje Rosten
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 2256331
TreeView+ depends on / blocked
 
Reported: 2024-04-03 14:32 UTC by Tomáš Hrnčiar
Modified: 2024-10-07 19:11 UTC (History)
5 users (show)

Fixed In Version: h5py-3.12.1-2.fc42
Clone Of:
Environment:
Last Closed: 2024-10-07 19:11:44 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Tomáš Hrnčiar 2024-04-03 14:32:48 UTC
h5py fails to build with pytest 8.

=================================== FAILURES ===================================
_________________________________ test_default _________________________________

request = <FixtureRequest for <Function test_default>>

    @pytest.mark.mpi_skip
    @insubprocess
    @subproc_env({'HDF5_PLUGIN_PATH': 'h5py_plugin_test'})
    def test_default(request):
        assert h5pl.size() == 1
>       assert h5pl.get(0) == b'h5py_plugin_test'
E       AssertionError: assert b'/usr/lib64/hdf5/plugin' == b'h5py_plugin_test'
E         
E         At index 0 diff: b'/' != b'h'
E         Use -v to get more diff

serial/build/lib.linux-x86_64-cpython-312/h5py/tests/test_h5pl.py:21: AssertionError
_________________________________ test_append __________________________________

request = <FixtureRequest for <Function test_append>>

    @pytest.mark.mpi_skip
    @insubprocess
    @subproc_env({'HDF5_PLUGIN_PATH': 'h5py_plugin_test'})
    def test_append(request):
        h5pl.append(b'/opt/hdf5/vendor-plugin')
        assert h5pl.size() == 2
>       assert h5pl.get(0) == b'h5py_plugin_test'
E       AssertionError: assert b'/usr/lib64/hdf5/plugin' == b'h5py_plugin_test'
E         
E         At index 0 diff: b'/' != b'h'
E         Use -v to get more diff

serial/build/lib.linux-x86_64-cpython-312/h5py/tests/test_h5pl.py:30: AssertionError
_________________________________ test_prepend _________________________________

request = <FixtureRequest for <Function test_prepend>>

    @pytest.mark.mpi_skip
    @insubprocess
    @subproc_env({'HDF5_PLUGIN_PATH': 'h5py_plugin_test'})
    def test_prepend(request):
        h5pl.prepend(b'/opt/hdf5/vendor-plugin')
>       assert h5pl.size() == 2
E       assert 3 == 2
E        +  where 3 = <cyfunction size at 0x7f78c5303e00>()
E        +    where <cyfunction size at 0x7f78c5303e00> = h5pl.size

serial/build/lib.linux-x86_64-cpython-312/h5py/tests/test_h5pl.py:39: AssertionError
_________________________________ test_insert __________________________________

request = <FixtureRequest for <Function test_insert>>

    @pytest.mark.mpi_skip
    @insubprocess
    @subproc_env({'HDF5_PLUGIN_PATH': 'h5py_plugin_test'})
    def test_insert(request):
        h5pl.insert(b'/opt/hdf5/vendor-plugin', 0)
>       assert h5pl.size() == 2
E       assert 4 == 2
E        +  where 4 = <cyfunction size at 0x7f78c5303e00>()
E        +    where <cyfunction size at 0x7f78c5303e00> = h5pl.size

serial/build/lib.linux-x86_64-cpython-312/h5py/tests/test_h5pl.py:49: AssertionError
_________________________________ test_replace _________________________________

request = <FixtureRequest for <Function test_replace>>

    @pytest.mark.mpi_skip
    @insubprocess
    @subproc_env({'HDF5_PLUGIN_PATH': 'h5py_plugin_test'})
    def test_replace(request):
        h5pl.replace(b'/opt/hdf5/vendor-plugin', 0)
>       assert  h5pl.size() == 1
E       assert 4 == 1
E        +  where 4 = <cyfunction size at 0x7f78c5303e00>()
E        +    where <cyfunction size at 0x7f78c5303e00> = h5pl.size

serial/build/lib.linux-x86_64-cpython-312/h5py/tests/test_h5pl.py:59: AssertionError
_________________________________ test_remove __________________________________

request = <FixtureRequest for <Function test_remove>>

    @pytest.mark.mpi_skip
    @insubprocess
    def test_remove(request):
        h5pl.remove(0)
>       assert h5pl.size() == 0
E       assert 3 == 0
E        +  where 3 = <cyfunction size at 0x7f78c5303e00>()
E        +    where <cyfunction size at 0x7f78c5303e00> = h5pl.size

serial/build/lib.linux-x86_64-cpython-312/h5py/tests/test_h5pl.py:67: AssertionError

https://docs.pytest.org/en/stable/changelog.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/thrnciar/pytest/fedora-rawhide-x86_64/07247580-h5py/

For all our attempts to build h5py with pytest 8, see:
https://copr.fedorainfracloud.org/coprs/thrnciar/pytest/package/h5py/

Let us know here if you have any questions.

Pytest 8 is planned to be included in Fedora 41. And this bugzilla is a
heads up before we merge new pytest into rawhide. For more info see a Fedora Change
proposal https://fedoraproject.org/wiki/Changes/Pytest_8

We'd appreciate help from the people who know this package best,
but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 Fedora Admin user for bugzilla script actions 2024-06-26 01:30:54 UTC
This package has changed maintainer in Fedora. Reassigning to the new maintainer of this component.

Comment 2 Terje Rosten 2024-10-01 16:43:24 UTC
Tomáš,

any idea what changes in pyteest 8 causes the errors? The pytest 8 changelog i massive.

Comment 3 Tomáš Hrnčiar 2024-10-04 09:30:35 UTC
I did some investigation and ran tests locally, where all of them passed. Thus, I think it's not an upstream problem and we should be able to fix it on Fedora's side. 

==================================== test session starts =====================================
platform linux -- Python 3.13.0rc2, pytest-8.3.3, pluggy-1.5.0
cachedir: .tox/py313-test-deps/.pytest_cache
rootdir: /home/thrnciar/python-maint/upstream/h5py
configfile: pytest.ini
plugins: mpi-0.6, cov-5.0.0
collected 768 items

...
py313-test-deps/lib64/python3.13/site-packages/h5py/tests/test_h5pl.py ......          [ 88%]
...
============================== 744 passed, 24 skipped in 11.14s ==============================
py313-test-mindeps: OK ✔ in 2 minutes 38.7 seconds

Comment 4 Tomáš Hrnčiar 2024-10-04 13:35:47 UTC
I was looking into the first failing test (test_default), but I am afraid I don't understand how HDF5 plugins work and how to debug a Cython file. 
h5pl.get(0) is here: https://github.com/h5py/h5py/blob/3.12.1/h5py/h5pl.pyx#L57

Could you please help me out? Why is "h5py_plugin_test" expected from h5pl.get(0) and how is it related to the environment variable defined in the test decorator?

_________________________________ test_default _________________________________

request = <FixtureRequest for <Function test_default>>

    @pytest.mark.mpi_skip
    @insubprocess
    @subproc_env({'HDF5_PLUGIN_PATH': 'h5py_plugin_test'})
    def test_default(request):
        assert h5pl.size() == 1
>       assert h5pl.get(0) == b'h5py_plugin_test'
E       AssertionError: assert b'/usr/lib64/hdf5/plugin' == b'h5py_plugin_test'
E         
E         At index 0 diff: b'/' != b'h'
E         Use -v to get more diff

serial/build/lib.linux-x86_64-cpython-312/h5py/tests/test_h5pl.py:21: AssertionError

Comment 5 Miro Hrončok 2024-10-06 09:30:07 UTC
I was debugging this to see what is happening with the custom @insubprocess + @subproc_env decorator combo.

Anyway, while doing it, I realized that removing --pyargs makes it work: https://src.fedoraproject.org/rpms/h5py/pull-request/11

Comment 6 Terje Rosten 2024-10-07 18:13:15 UTC
These tests are rather because they seems to start a new pytest process inside the test[1]:

 with closed_tempfile() as stdout:
                with open(stdout, 'w+t') as fh:
                    rtn = subprocess.call([sys.executable, '-m', 'pytest', curr_test],
                                          stdout=fh, stderr=fh, env=env)
                with open(stdout, 'rt') as fh:
                    out = fh.read()


[1]: https://github.com/h5py/h5py/blob/master/h5py/tests/common.py#L223

The point of this is set the environmental variable  $HDF5_PLUGIN_PATH to a special
custom value.

@subproc_env({'HDF5_PLUGIN_PATH': 'h5py_plugin_test'})

 https://github.com/h5py/h5py/blob/master/h5py/tests/test_h5pl.py#L18

Variable $HDF5_PLUGIN_PATH is read and respected by underlying hdf5 library and should in theory 
propagate to h5py too. 

The value of '/usr/lib64/hdf5/plugin' the default value if $HDF5_PLUGIN_PATH is not found in environment.

I am not sure how this is related to --pyargs, maybe 

 --pyargs h5py 

causes h5py lib to loaded twice in some way, I wonder this is the case as 

 h5pl.size() 

seems to return too high values.

Comment 7 Fedora Update System 2024-10-07 19:07:38 UTC
FEDORA-2024-4be1012558 (h5py-3.12.1-2.fc42) has been submitted as an update to Fedora 42.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-4be1012558

Comment 8 Fedora Update System 2024-10-07 19:11:44 UTC
FEDORA-2024-4be1012558 (h5py-3.12.1-2.fc42) has been pushed to the Fedora 42 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.