Bug 2442355

Summary: python-nibabel fails to build with Python 3.15: AssertionError in test_DeterministicGzipFile
Product: [Fedora] Fedora Reporter: Karolina Surma <ksurma>
Component: python-nibabelAssignee: Ankur Sinha (FranciscoD) <sanjay.ankur>
Status: ASSIGNED --- QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: igor.raits, ksurma, mhroncok, neuro-sig, sanjay.ankur
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: ---
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2412434    

Description Karolina Surma 2026-02-24 14:59:32 UTC
python-nibabel fails to build with Python 3.15.0a6.

__________________________ test_DeterministicGzipFile __________________________

    def test_DeterministicGzipFile():
        with InTemporaryDirectory():
            msg = b"Hello, I'd like to have an argument."
    
            # No filename, no mtime
            with open('ref.gz', 'wb') as fobj:
                with GzipFile(filename='', mode='wb', fileobj=fobj, mtime=0) as gzobj:
                    gzobj.write(msg)
            anon_chksum = md5sum('ref.gz')
    
            with DeterministicGzipFile('default.gz', 'wb') as fobj:
                internal_fobj = fobj.myfileobj
                fobj.write(msg)
            # Check that myfileobj is being closed by GzipFile.close()
            # This is in case GzipFile changes its internal implementation
            assert internal_fobj.closed
    
>           assert md5sum('default.gz') == anon_chksum
E           AssertionError: assert 'abff1dfd2f8b...fe395999e3009' == 'e04e8bb89ad8...3ab57758a6ef2'
E             
E             - e04e8bb89ad8cb84ae93ab57758a6ef2
E             + abff1dfd2f8bbc2e7aefe395999e3009

nibabel/tests/test_openers.py:382: AssertionError
______________________ test_DeterministicGzipFile_fileobj ______________________

    def test_DeterministicGzipFile_fileobj():
        with InTemporaryDirectory():
            msg = b"Hello, I'd like to have an argument."
            with open('ref.gz', 'wb') as fobj:
                with GzipFile(filename='', mode='wb', fileobj=fobj, mtime=0) as gzobj:
                    gzobj.write(msg)
            ref_chksum = md5sum('ref.gz')
    
            with open('test.gz', 'wb') as fobj:
                with DeterministicGzipFile(filename='', mode='wb', fileobj=fobj) as gzobj:
                    gzobj.write(msg)
>           assert md5sum('test.gz') == ref_chksum
E           AssertionError: assert 'abff1dfd2f8b...fe395999e3009' == 'e04e8bb89ad8...3ab57758a6ef2'
E             
E             - e04e8bb89ad8cb84ae93ab57758a6ef2
E             + abff1dfd2f8bbc2e7aefe395999e3009

nibabel/tests/test_openers.py:435: AssertionError

I have no idea if this is a genuine issue or something related to Copr - opening the ticket to determine that.

https://docs.python.org/3.15/whatsnew/3.15.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.15/fedora-rawhide-x86_64/10150483-python-nibabel/

For all our attempts to build python-nibabel with Python 3.15, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.15/package/python-nibabel/

Testing and mass rebuild of packages is happening in copr.
You can follow these instructions to test locally in mock if your package builds with Python 3.15:
https://copr.fedorainfracloud.org/coprs/g/python/python3.15/

Let us know here if you have any questions.

Python 3.15 is planned to be included in Fedora 45.
To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.15.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires),
so if this package is required a lot, it's important for us to get it fixed soon.

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 Karolina Surma 2026-03-09 12:30:57 UTC
There's a change in gzip.GZipFile in Python 3.15:

Changed in version 3.15: The default compression level was reduced to 6 (down from 9). It is the default level used by most compression tools and a better tradeoff between speed and performance.

I tested that changing the compression level actually works, and opened an upstream issue: https://github.com/nipy/nibabel/issues/1477 (basically, the fix can either change the nibabel's inherited class, or the tests - it's up to the upstream).

Comment 2 Ankur Sinha (FranciscoD) 2026-03-10 10:37:53 UTC
Thanks Karolina. I've subscribed to the upstream ticket and will keep an eye on any progress.