Skip to content

NEP29: Require Python 3.7+, numpy 1.17+, declare 3.10 support #1079

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

Merged
merged 4 commits into from
Feb 7, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 2 additions & 6 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
strategy:
matrix:
os: ['ubuntu-latest', 'windows-latest', 'macos-latest']
python-version: ["3.8", "3.9", "3.10.0-rc.1"]
python-version: ["3.9", "3.10"]
architecture: ['x64', 'x86']
install: ['setup']
check: ['test']
Expand All @@ -36,7 +36,7 @@ jobs:
include:
# Pydicom master
- os: ubuntu-latest
python-version: 3.8
python-version: "3.10"
install: setup
check: test
pip-flags: ''
Expand All @@ -47,10 +47,6 @@ jobs:
architecture: x86
- os: macos-latest
architecture: x86
- os: windows-latest
python-version: "3.10.0-rc.1"
- os: macos-latest
python-version: "3.10.0-rc.1"

env:
DEPENDS: ${{ matrix.depends }}
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
strategy:
matrix:
os: ['ubuntu-latest', 'windows-latest', 'macos-latest']
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: [3.7, 3.8, 3.9, "3.10"]
architecture: ['x64', 'x86']
install: ['pip']
check: ['test']
Expand All @@ -39,52 +39,52 @@ jobs:
include:
# Basic dependencies only
- os: ubuntu-latest
python-version: 3.6
python-version: 3.7
install: setup
check: test
pip-flags: ''
depends: REQUIREMENTS
optional-depends: ''
# Absolute minimum dependencies
- os: ubuntu-latest
python-version: 3.6
python-version: 3.7
install: setup
check: test
pip-flags: ''
depends: MIN_REQUIREMENTS
optional-depends: ''
# Absolute minimum dependencies plus old MPL, Pydicom, Pillow
- os: ubuntu-latest
python-version: 3.6
python-version: 3.7
install: setup
check: test
pip-flags: ''
depends: MIN_REQUIREMENTS
optional-depends: MIN_OPT_DEPENDS
# Clean install imports only with package-declared dependencies
- os: ubuntu-latest
python-version: 3.6
python-version: 3.7
install: pip
check: skiptests
pip-flags: ''
depends: ''
# Check all installation methods
- os: ubuntu-latest
python-version: 3.8
python-version: "3.10"
install: wheel
check: test
pip-flags: ''
depends: REQUIREMENTS
optional-depends: DEFAULT_OPT_DEPENDS
- os: ubuntu-latest
python-version: 3.8
python-version: "3.10"
install: sdist
check: test
pip-flags: ''
depends: REQUIREMENTS
optional-depends: DEFAULT_OPT_DEPENDS
- os: ubuntu-latest
python-version: 3.8
python-version: "3.10"
install: archive
check: test
pip-flags: ''
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

os: linux
arch: arm64
dist: xenial
dist: focal
language: python
cache: pip

Expand All @@ -21,10 +21,10 @@ env:
- CHECK_TYPE="test"

python:
- 3.6
- 3.7
- 3.8
- 3.9
- "3.10"

# Set up virtual environment, build package, build from depends
before_install:
Expand Down
2 changes: 1 addition & 1 deletion min-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Auto-generated by tools/update_requirements.py
numpy ==1.15
numpy ==1.17
packaging ==17.0
setuptools
12 changes: 0 additions & 12 deletions nibabel/_h5py_compat.py

This file was deleted.

2 changes: 1 addition & 1 deletion nibabel/minc2.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class Minc2Image(Minc1Image):
def from_file_map(klass, file_map, *, mmap=True, keep_file_open=None):
# Import of h5py might take awhile for MPI-enabled builds
# So we are importing it here "on demand"
from ._h5py_compat import h5py
import h5py
holder = file_map['image']
if holder.filename is None:
raise MincError('MINC2 needs filename for load')
Expand Down
8 changes: 1 addition & 7 deletions nibabel/testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,7 @@

from itertools import zip_longest

try:
from contextlib import nullcontext
except ImportError: # PY36
from contextlib import contextmanager
@contextmanager
def nullcontext():
yield
from contextlib import nullcontext


def test_data(subdir=None, fname=None):
Expand Down
46 changes: 0 additions & 46 deletions nibabel/tests/test_h5py_compat.py

This file was deleted.

2 changes: 1 addition & 1 deletion nibabel/tests/test_image_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

from ..optpkg import optional_package
_, have_scipy, _ = optional_package('scipy')
from .._h5py_compat import have_h5py
_, have_h5py, _ = optional_package('h5py')

from .. import (AnalyzeImage, Spm99AnalyzeImage, Spm2AnalyzeImage,
Nifti1Pair, Nifti1Image, Nifti2Pair, Nifti2Image,
Expand Down
5 changes: 3 additions & 2 deletions nibabel/tests/test_imageclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@
from nibabel.analyze import AnalyzeImage
from nibabel.nifti1 import Nifti1Image
from nibabel.nifti2 import Nifti2Image
from .._h5py_compat import have_h5py

from nibabel import imageclasses
from nibabel.imageclasses import spatial_axes_first, class_map, ext_map


from nibabel.optpkg import optional_package
from nibabel.testing import clear_and_catch_warnings


have_h5py = optional_package('h5py')[1]

DATA_DIR = pjoin(dirname(__file__), 'data')

MINC_3DS = ('minc1_1_scale.mnc',)
Expand Down
6 changes: 2 additions & 4 deletions nibabel/tests/test_loadsave.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ def test_read_img_data():
]
fnames_test += [pathlib.Path(p) for p in fnames_test]
for fname in fnames_test:
# os.path.join doesn't work between str / os.PathLike in py3.5
fpath = pjoin(data_path, str(fname))
fpath = pjoin(data_path, fname)
if isinstance(fname, pathlib.Path):
fpath = pathlib.Path(fpath)
img = load(fpath)
Expand All @@ -56,8 +55,7 @@ def test_read_img_data():
up_fpath = pjoin(tmpdir, str(fname).upper())
if isinstance(fname, pathlib.Path):
up_fpath = pathlib.Path(up_fpath)
# shutil doesn't work with os.PathLike in py3.5
shutil.copyfile(str(fpath), str(up_fpath))
shutil.copyfile(fpath, up_fpath)
img = load(up_fpath)
assert_array_equal(img.dataobj, data)
del img
Expand Down
4 changes: 3 additions & 1 deletion nibabel/tests/test_minc2.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@

from .. import minc2
from ..minc2 import Minc2File, Minc2Image
from .._h5py_compat import h5py, have_h5py, setup_module

from ..optpkg import optional_package
from ..testing import data_path

from . import test_minc1 as tm2

h5py, have_h5py, setup_module = optional_package('h5py')

# Example images in format expected for ``test_image_api``, adding ``zooms``
# item.
EXAMPLE_IMAGES = [
Expand Down
5 changes: 3 additions & 2 deletions nibabel/tests/test_minc2_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@

import numpy as np

from .._h5py_compat import h5py, have_h5py, setup_module

from .nibabel_data import get_nibabel_data, needs_nibabel_data
from .. import load as top_load, Nifti1Image
from ..optpkg import optional_package

from numpy.testing import (assert_array_equal, assert_almost_equal)

h5py, have_h5py, setup_module = optional_package('h5py')

MINC2_PATH = pjoin(get_nibabel_data(), 'nitest-minc2')


Expand Down
4 changes: 3 additions & 1 deletion nibabel/tests/test_proxy_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
from .. import minc1
from ..externals.netcdf import netcdf_file
from .. import minc2
from .._h5py_compat import h5py, have_h5py
from .. import ecat
from .. import parrec
from ..casting import have_binary128
Expand All @@ -57,12 +56,15 @@

from ..testing import data_path as DATA_PATH, assert_dt_equal, clear_and_catch_warnings
from ..deprecator import ExpiredDeprecationError
from ..optpkg import optional_package

from ..tmpdirs import InTemporaryDirectory

from .test_api_validators import ValidateAPI
from .test_parrec import EG_REC, VARY_REC

h5py, have_h5py, _ = optional_package('h5py')


def _some_slicers(shape):
ndim = len(shape)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Auto-generated by tools/update_requirements.py
numpy >=1.15
numpy >=1.17
packaging >=17.0
setuptools
7 changes: 3 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ classifiers =
License :: OSI Approved :: MIT License
Operating System :: OS Independent
Programming Language :: Python
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Topic :: Scientific/Engineering
license = MIT License
description = Access a multitude of neuroimaging data formats
Expand All @@ -28,9 +28,9 @@ provides =
nisext

[options]
python_requires = >=3.6
python_requires = >=3.7
install_requires =
numpy >=1.15
numpy >=1.17
packaging >=17.0
setuptools
zip_safe = False
Expand Down Expand Up @@ -59,7 +59,6 @@ style =
test =
coverage
pytest !=5.3.4
pytest <7 ; python_version == "3.6"
pytest-cov
pytest-doctestplus
zstd =
Expand Down