1
0

Accepting request 1009448 from devel:languages:python:numeric

- Update to 4.0.2
  * many changes, see Changelog
  * nib-convert CLI tool to make image type and data dtype conversion 
    accessible via the command line.
  * Allow dtypes to be passed to Analyze-like images at __init__() 
    and to_filename()
  * Allow compressed GIFTI images
  * Add zstd compression support
  * Test on Python 3.10
  * Passing (u)int64 arrays to Nifti1Image and subclasses will warn 
    unless a header or dtype option is passed; in the future this will 
    become an error. Additionally, passing int or 'int' to set_data_dtype() 
    now raises an error, requiring an explicit numpy dtype to make 64-bit 
    integer images.
  * Drop support for Python 3.6, Numpy < 1.17
  * Fully removed the APIs, which have raised errors on use since 3.0
- Drop upstreamed 983.patch and purge-nose.patch

OBS-URL: https://build.opensuse.org/request/show/1009448
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-nibabel?expand=0&rev=9
This commit is contained in:
Richard Brown 2022-10-11 16:02:53 +00:00 committed by Git OBS Bridge
commit 57bda54458
6 changed files with 33 additions and 242 deletions

View File

@ -1,39 +0,0 @@
From 84c7cf444e0c14fb6706af92e5f96f85c8aadf3d Mon Sep 17 00:00:00 2001
From: "Christopher J. Markiewicz" <markiewicz@stanford.edu>
Date: Sun, 20 Dec 2020 12:12:12 -0500
Subject: [PATCH] TEST: Use more constrained mock when testing optpkg
The existing mock raised errors on any import except a whitelisted
unittest. Because pytest monkeypatches the Python interpreter and then
performs imports within the patched functions, this breaks in Pytest
3.10. Move to an import that blacklists the specific module we're
testing.
---
nibabel/tests/test_optpkg.py | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/nibabel/tests/test_optpkg.py b/nibabel/tests/test_optpkg.py
index 925180ce6..2bc702210 100644
--- a/nibabel/tests/test_optpkg.py
+++ b/nibabel/tests/test_optpkg.py
@@ -39,14 +39,14 @@ def test_basic():
# We never have package _not_a_package
assert_bad('_not_a_package')
- # setup_module imports unittest, so make sure we don't disrupt that
+ # Only disrupt imports for "nottriedbefore" package
orig_import = builtins.__import__
def raise_Exception(*args, **kwargs):
- if args[0] == 'unittest':
- return orig_import(*args, **kwargs)
- raise Exception(
- "non ImportError could be thrown by some malfunctioning module "
- "upon import, and optional_package should catch it too")
+ if args[0] == 'nottriedbefore':
+ raise Exception(
+ "non ImportError could be thrown by some malfunctioning module "
+ "upon import, and optional_package should catch it too")
+ return orig_import(*args, **kwargs)
with mock.patch.object(builtins, '__import__', side_effect=raise_Exception):
assert_bad('nottriedbefore')

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:b5efff77c81affbed2a85a038fb7948669b088b4a87ff6fdf358f83acf4b39ce
size 4617212

3
nibabel-4.0.2.tar.gz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:45c49b5349351b45f6c045a91aa02b4f0d367686ff3284632ef95ac65b930786
size 4804200

View File

@ -1,189 +0,0 @@
Index: nibabel-3.1.1/nisext/tests/test_sexts.py
===================================================================
--- nibabel-3.1.1.orig/nisext/tests/test_sexts.py
+++ nibabel-3.1.1/nisext/tests/test_sexts.py
@@ -6,7 +6,7 @@ import types
from ..sexts import package_check
-from nose.tools import assert_true, assert_false, assert_equal, assert_raises
+import pytest
FAKE_NAME = 'nisext_improbable'
assert FAKE_NAME not in sys.modules
@@ -15,7 +15,8 @@ FAKE_MODULE = types.ModuleType('nisext_f
def test_package_check():
# Try to use a required package - raise error
- assert_raises(RuntimeError, package_check, FAKE_NAME)
+ with pytest.raises(RuntimeError):
+ package_check(FAKE_NAME)
# Optional, log.warn
package_check(FAKE_NAME, optional=True)
# Can also pass a string
@@ -29,7 +30,8 @@ def test_package_check():
FAKE_MODULE.__version__ = '0.2'
package_check(FAKE_NAME, version='0.2')
# fails when version not good enough
- assert_raises(RuntimeError, package_check, FAKE_NAME, '0.3')
+ with pytest.raises(RuntimeError):
+ package_check(FAKE_NAME, '0.3')
# Unless optional in which case log.warns
package_check(FAKE_NAME, version='0.3', optional=True)
# Might do custom version check
@@ -40,78 +42,63 @@ def test_package_check():
def test_package_check_setuptools():
# If setuptools arg not None, missing package just adds it to arg
- assert_raises(RuntimeError, package_check, FAKE_NAME, setuptools_args=None)
+ with pytest.raises(RuntimeError):
+ package_check(FAKE_NAME, setuptools_args=None)
def pkg_chk_sta(*args, **kwargs):
st_args = {}
package_check(*args, setuptools_args=st_args, **kwargs)
return st_args
- assert_equal(pkg_chk_sta(FAKE_NAME),
- {'install_requires': ['nisext_improbable']})
+ assert pkg_chk_sta(FAKE_NAME) == {'install_requires': ['nisext_improbable']}
# Check that this gets appended to existing value
old_sta = {'install_requires': ['something']}
package_check(FAKE_NAME, setuptools_args=old_sta)
- assert_equal(old_sta,
- {'install_requires': ['something', 'nisext_improbable']})
+ assert old_sta == {'install_requires': ['something', 'nisext_improbable']}
# That existing value as string gets converted to a list
old_sta = {'install_requires': 'something'}
package_check(FAKE_NAME, setuptools_args=old_sta)
- assert_equal(old_sta,
- {'install_requires': ['something', 'nisext_improbable']})
+ assert old_sta == {'install_requires': ['something', 'nisext_improbable']}
# Optional, add to extras_require
- assert_equal(pkg_chk_sta(FAKE_NAME, optional='something'),
- {'extras_require': {'something': ['nisext_improbable']}})
+ assert pkg_chk_sta(FAKE_NAME, optional='something') == {'extras_require': {'something': ['nisext_improbable']}}
# Check that this gets appended to existing value
old_sta = {'extras_require': {'something': ['amodule']}}
package_check(FAKE_NAME, optional='something', setuptools_args=old_sta)
- assert_equal(old_sta,
- {'extras_require':
- {'something': ['amodule', 'nisext_improbable']}})
+ assert old_sta == {'extras_require': {'something': ['amodule', 'nisext_improbable']}}
# That string gets converted to a list here too
old_sta = {'extras_require': {'something': 'amodule'}}
package_check(FAKE_NAME, optional='something', setuptools_args=old_sta)
- assert_equal(old_sta,
- {'extras_require':
- {'something': ['amodule', 'nisext_improbable']}})
+ assert old_sta == {'extras_require':
+ {'something': ['amodule', 'nisext_improbable']}}
# But optional has to be a string if not empty and setuptools_args defined
- assert_raises(RuntimeError,
- package_check, FAKE_NAME, optional=True, setuptools_args={})
+ with pytest.raises(RuntimeError):
+ package_check(FAKE_NAME, optional=True, setuptools_args={})
try:
# Make a package
sys.modules[FAKE_NAME] = FAKE_MODULE
# No install_requires because we already have it
- assert_equal(pkg_chk_sta(FAKE_NAME), {})
+ assert pkg_chk_sta(FAKE_NAME) == {}
# A fake version still works
FAKE_MODULE.__version__ = '0.2'
- assert_equal(pkg_chk_sta(FAKE_NAME, version='0.2'), {})
+ assert pkg_chk_sta(FAKE_NAME, version='0.2') == {}
# goes into install requires when version not good enough
exp_spec = [FAKE_NAME + '>=0.3']
- assert_equal(pkg_chk_sta(FAKE_NAME, version='0.3'),
- {'install_requires': exp_spec})
+ assert pkg_chk_sta(FAKE_NAME, version='0.3') == {'install_requires': exp_spec}
# Unless optional in which case goes into extras_require
package_check(FAKE_NAME, version='0.2', version_getter=lambda x: '0.2')
- assert_equal(
- pkg_chk_sta(FAKE_NAME, version='0.3', optional='afeature'),
- {'extras_require': {'afeature': exp_spec}})
+ assert pkg_chk_sta(FAKE_NAME, version='0.3', optional='afeature') == {'extras_require': {'afeature': exp_spec}}
# Might do custom version check
- assert_equal(
- pkg_chk_sta(FAKE_NAME,
+ assert pkg_chk_sta(FAKE_NAME,
version='0.2',
- version_getter=lambda x: '0.2'),
- {})
+ version_getter=lambda x: '0.2') == {}
# If the version check fails, put into requires
bad_getter = lambda x: x.not_an_attribute
exp_spec = [FAKE_NAME + '>=0.2']
- assert_equal(
- pkg_chk_sta(FAKE_NAME,
+ assert pkg_chk_sta(FAKE_NAME,
version='0.2',
- version_getter=bad_getter),
- {'install_requires': exp_spec})
+ version_getter=bad_getter) == {'install_requires': exp_spec}
# Likewise for optional dependency
- assert_equal(
- pkg_chk_sta(FAKE_NAME,
+ assert pkg_chk_sta(FAKE_NAME,
version='0.2',
optional='afeature',
- version_getter=bad_getter),
- {'extras_require': {'afeature': [FAKE_NAME + '>=0.2']}})
+ version_getter=bad_getter) == {'extras_require': {'afeature': [FAKE_NAME + '>=0.2']}}
finally:
del sys.modules[FAKE_NAME]
Index: nibabel-3.1.1/nisext/tests/test_testers.py
===================================================================
--- nibabel-3.1.1.orig/nisext/tests/test_testers.py
+++ nibabel-3.1.1/nisext/tests/test_testers.py
@@ -6,38 +6,37 @@ from os.path import dirname, pathsep
from ..testers import back_tick, run_mod_cmd, PYTHON
-from nose.tools import assert_true, assert_equal, assert_raises
-
+import pytest
def test_back_tick():
cmd = '{0} -c "print(\'Hello\')"'.format(PYTHON)
- assert_equal(back_tick(cmd), "Hello")
- assert_equal(back_tick(cmd, ret_err=True), ("Hello", ""))
- assert_equal(back_tick(cmd, True, False), (b"Hello", b""))
+ assert back_tick(cmd) == "Hello"
+ assert back_tick(cmd, ret_err=True) == ("Hello", "")
+ assert back_tick(cmd, True, False) == (b"Hello", b"")
cmd = '{0} -c "raise ValueError()"'.format(PYTHON)
- assert_raises(RuntimeError, back_tick, cmd)
+ with pytest.raises(RuntimeError):
+ back_tick(cmd)
def test_run_mod_cmd():
mod = 'os'
mod_dir = dirname(os.__file__)
- assert_equal(run_mod_cmd(mod, mod_dir, "print('Hello')", None, False),
- ("Hello", ""))
+ assert run_mod_cmd(mod, mod_dir, "print('Hello')", None, False) == ("Hello", "")
sout, serr = run_mod_cmd(mod, mod_dir, "print('Hello again')")
- assert_equal(serr, '')
+ assert serr == ''
mod_file, out_str = [s.strip() for s in sout.split('\n')]
- assert_true(mod_file.startswith(mod_dir))
- assert_equal(out_str, 'Hello again')
+ assert mod_file.startswith(mod_dir)
+ assert out_str == 'Hello again'
sout, serr = run_mod_cmd(mod,
mod_dir,
"print(os.environ['PATH'])",
None,
False)
- assert_equal(serr, '')
+ assert serr == ''
sout2, serr = run_mod_cmd(mod,
mod_dir,
"print(os.environ['PATH'])",
'pth2',
False)
- assert_equal(serr, '')
- assert_equal(sout2, '"pth2"' + pathsep + sout)
+ assert serr == ''
+ assert sout2 == '"pth2"' + pathsep + sout

View File

@ -1,3 +1,24 @@
-------------------------------------------------------------------
Thu Oct 6 14:07:18 UTC 2022 - Markéta Machová <mmachova@suse.com>
- Update to 4.0.2
* many changes, see Changelog
* nib-convert CLI tool to make image type and data dtype conversion
accessible via the command line.
* Allow dtypes to be passed to Analyze-like images at __init__()
and to_filename()
* Allow compressed GIFTI images
* Add zstd compression support
* Test on Python 3.10
* Passing (u)int64 arrays to Nifti1Image and subclasses will warn
unless a header or dtype option is passed; in the future this will
become an error. Additionally, passing int or 'int' to set_data_dtype()
now raises an error, requiring an explicit numpy dtype to make 64-bit
integer images.
* Drop support for Python 3.6, Numpy < 1.17
* Fully removed the APIs, which have raised errors on use since 3.0
- Drop upstreamed 983.patch and purge-nose.patch
-------------------------------------------------------------------
Wed Mar 31 09:09:56 UTC 2021 - Guillaume GARDET <guillaume.gardet@opensuse.org>

View File

@ -1,7 +1,7 @@
#
# spec file for package python-nibabel
#
# Copyright (c) 2021 SUSE LLC
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@ -19,24 +19,21 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%define skip_python2 1
%define skip_python36 1
%define binaries nib-conform nib-dicomfs nib-diff nib-ls nib-nifti-dx nib-tck2trk nib-trk2tck parrec2nii
%define binaries nib-conform nib-convert nib-dicomfs nib-diff nib-ls nib-nifti-dx nib-roi nib-stats nib-tck2trk nib-trk2tck parrec2nii
Name: python-nibabel
Version: 3.1.1
Version: 4.0.2
Release: 0
Summary: Tool to access multiple neuroimaging data formats
License: MIT
URL: https://nipy.org/nibabel
Source: https://files.pythonhosted.org/packages/source/n/nibabel/nibabel-%{version}.tar.gz
Patch0: purge-nose.patch
# PATCH-FIX-UPSTREAM - https://github.com/nipy/nibabel/pull/983
Patch1: 983.patch
BuildRequires: %{python_module setuptools >= 30.3.0}
BuildRequires: %{pythons}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
Requires: python-numpy >= 1.12
Requires: python-numpy >= 1.17
Requires(post): update-alternatives
Requires(postun): update-alternatives
Requires(postun):update-alternatives
Recommends: python-Pillow
Recommends: python-dicom >= 0.9.9
Recommends: python-h5py
@ -45,7 +42,7 @@ BuildArch: noarch
# SECTION test requirements
BuildRequires: %{python_module Pillow}
BuildRequires: %{python_module h5py}
BuildRequires: %{python_module numpy >= 1.12}
BuildRequires: %{python_module numpy >= 1.17}
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module scipy}
# /SECTION
@ -61,8 +58,6 @@ very limited support for DICOM.
%prep
%setup -q -n nibabel-%{version}
%patch0 -p1
%patch1 -p1
%build
%python_build
@ -91,10 +86,13 @@ done
%doc AUTHOR Changelog README.rst
%license COPYING
%python_alternative %{_bindir}/nib-conform
%python_alternative %{_bindir}/nib-convert
%python_alternative %{_bindir}/nib-dicomfs
%python_alternative %{_bindir}/nib-diff
%python_alternative %{_bindir}/nib-ls
%python_alternative %{_bindir}/nib-nifti-dx
%python_alternative %{_bindir}/nib-roi
%python_alternative %{_bindir}/nib-stats
%python_alternative %{_bindir}/nib-tck2trk
%python_alternative %{_bindir}/nib-trk2tck
%python_alternative %{_bindir}/parrec2nii