diff --git a/.travis.yml b/.travis.yml index f759f6b5716..2ecc808b8a3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -53,7 +53,7 @@ install: - conda create -n testenv python=$TRAVIS_PYTHON_VERSION nomkl pywavelets - source activate testenv # Install packages with pip if possible, it's way faster - - pip install "numpy==$NUMPY_VERSION" scipy future scikit-image pytest pytest-cov; + - pip install "numpy==$NUMPY_VERSION" scipy future packaging scikit-image pytest pytest-cov; # Building pyfftw wheels sometimes fails, using a conda-forge version instead - conda install -c conda-forge pyfftw diff --git a/doc/source/conf.py b/doc/source/conf.py index 57a5a8815b9..011b4ee22b9 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -1,4 +1,4 @@ -# Copyright 2014-2017 The ODL contributors +# Copyright 2014-2018 The ODL contributors # # This file is part of ODL. # @@ -7,12 +7,12 @@ # obtain one at https://mozilla.org/MPL/2.0/. from __future__ import print_function -from distutils.version import StrictVersion import sphinx import glob import os import sphinx_rtd_theme import sys +from packaging.version import parse as parse_version # --- General configuration --- # @@ -43,7 +43,7 @@ 'numpydoc' ] # Use newer 'imgmath' extension if possible -if StrictVersion(sphinx.__version__) >= '1.4': +if parse_version(sphinx.__version__) >= parse_version('1.4'): extensions.append('sphinx.ext.imgmath') else: extensions.append('sphinx.ext.pngmath') diff --git a/odl/contrib/datasets/mri/tugraz.py b/odl/contrib/datasets/mri/tugraz.py index ad2ca0acc60..9e4240e9944 100644 --- a/odl/contrib/datasets/mri/tugraz.py +++ b/odl/contrib/datasets/mri/tugraz.py @@ -1,4 +1,4 @@ -# Copyright 2014-2017 The ODL contributors +# Copyright 2014-2018 The ODL contributors # # This file is part of ODL. # @@ -15,10 +15,11 @@ """MRI datasets provided by TU Graz.""" import numpy as np -from pkg_resources import parse_version +from packaging.version import parse as parse_version from odl.contrib.datasets.util import get_data import odl + if parse_version(np.__version__) < parse_version('1.12'): flip = odl.util.npy_compat.flip else: diff --git a/odl/contrib/torch/operator.py b/odl/contrib/torch/operator.py index 9a93e26bb47..9635f06a41e 100644 --- a/odl/contrib/torch/operator.py +++ b/odl/contrib/torch/operator.py @@ -1,4 +1,4 @@ -# Copyright 2014-2017 The ODL contributors +# Copyright 2014-2018 The ODL contributors # # This file is part of ODL. # @@ -14,11 +14,11 @@ """ from __future__ import division +from packaging.version import parse as parse_version import warnings import numpy as np import torch -from pkg_resources import parse_version if parse_version(torch.__version__) < parse_version('0.4'): warnings.warn("This interface is designed to work with Pytorch >= 0.4", diff --git a/odl/operator/tensor_ops.py b/odl/operator/tensor_ops.py index 60739200d49..2ba85bce13a 100644 --- a/odl/operator/tensor_ops.py +++ b/odl/operator/tensor_ops.py @@ -1,4 +1,4 @@ -# Copyright 2014-2017 The ODL contributors +# Copyright 2014-2018 The ODL contributors # # This file is part of ODL. # @@ -11,6 +11,7 @@ from __future__ import print_function, division, absolute_import from numbers import Integral import numpy as np +from packaging.version import parse as parse_version from odl.operator.operator import Operator from odl.set import RealNumbers, ComplexNumbers @@ -911,7 +912,6 @@ def _call(self, x, out=None): """Return ``self(x[, out])``.""" # Lazy import to improve `import odl` time import scipy.sparse - from pkg_resources import parse_version if out is None: if scipy.sparse.isspmatrix(self.matrix): diff --git a/odl/space/entry_points.py b/odl/space/entry_points.py index 1c610d4b9f5..fe1fc7644f8 100644 --- a/odl/space/entry_points.py +++ b/odl/space/entry_points.py @@ -1,4 +1,4 @@ -# Copyright 2014-2017 The ODL contributors +# Copyright 2014-2018 The ODL contributors # # This file is part of ODL. # diff --git a/odl/test/discr/lp_discr_test.py b/odl/test/discr/lp_discr_test.py index f829d28cf9b..949fb3f4661 100644 --- a/odl/test/discr/lp_discr_test.py +++ b/odl/test/discr/lp_discr_test.py @@ -1,4 +1,4 @@ -# Copyright 2014-2017 The ODL contributors +# Copyright 2014-2018 The ODL contributors # # This file is part of ODL. # @@ -8,8 +8,8 @@ from __future__ import division import numpy as np +from packaging.version import parse as parse_version import pytest -from pkg_resources import parse_version import odl from odl.discr.lp_discr import DiscreteLp, DiscreteLpElement @@ -20,8 +20,8 @@ all_equal, all_almost_equal, noise_elements, simple_fixture) -USE_ARRAY_UFUNCS_INTERFACE = (parse_version(np.__version__) >= - parse_version('1.13')) +USE_ARRAY_UFUNCS_INTERFACE = ( + parse_version(np.__version__) >= parse_version('1.13')) # --- Pytest fixtures --- # diff --git a/odl/test/largescale/tomo/ray_transform_slow_test.py b/odl/test/largescale/tomo/ray_transform_slow_test.py index 4494f4e2163..9e26e09cad7 100644 --- a/odl/test/largescale/tomo/ray_transform_slow_test.py +++ b/odl/test/largescale/tomo/ray_transform_slow_test.py @@ -1,4 +1,4 @@ -# Copyright 2014-2017 The ODL contributors +# Copyright 2014-2018 The ODL contributors # # This file is part of ODL. # @@ -9,9 +9,10 @@ """Test reconstruction with ASTRA.""" from __future__ import division -import pytest + import numpy as np -from pkg_resources import parse_version +from packaging.version import parse as parse_version +import pytest import odl from odl.util.testutils import skip_if_no_largescale, simple_fixture diff --git a/odl/test/space/tensors_test.py b/odl/test/space/tensors_test.py index 1316f850c6f..dabe6758a21 100644 --- a/odl/test/space/tensors_test.py +++ b/odl/test/space/tensors_test.py @@ -1,4 +1,4 @@ -# Copyright 2014-2017 The ODL contributors +# Copyright 2014-2018 The ODL contributors # # This file is part of ODL. # @@ -11,7 +11,7 @@ from __future__ import division import numpy as np import operator -from pkg_resources import parse_version +from packaging.version import parse as parse_version import pytest import sys diff --git a/odl/test/tomo/operators/ray_trafo_test.py b/odl/test/tomo/operators/ray_trafo_test.py index 8fcdf139ed7..03f5fce7e45 100644 --- a/odl/test/tomo/operators/ray_trafo_test.py +++ b/odl/test/tomo/operators/ray_trafo_test.py @@ -1,4 +1,4 @@ -# Copyright 2014-2017 The ODL contributors +# Copyright 2014-2018 The ODL contributors # # This file is part of ODL. # @@ -10,7 +10,7 @@ from __future__ import division import numpy as np -from pkg_resources import parse_version +from packaging.version import parse as parse_version import pytest import odl diff --git a/odl/tomo/backends/astra_cuda.py b/odl/tomo/backends/astra_cuda.py index c817f508278..597d0bdcc18 100644 --- a/odl/tomo/backends/astra_cuda.py +++ b/odl/tomo/backends/astra_cuda.py @@ -1,4 +1,4 @@ -# Copyright 2014-2017 The ODL contributors +# Copyright 2014-2018 The ODL contributors # # This file is part of ODL. # @@ -10,7 +10,10 @@ from __future__ import print_function, division, absolute_import from builtins import object +from multiprocessing import Lock import numpy as np +from packaging.version import parse as parse_version + try: import astra ASTRA_CUDA_AVAILABLE = astra.astra.use_cuda() @@ -25,7 +28,6 @@ from odl.tomo.geometry import ( Geometry, Parallel2dGeometry, FanFlatGeometry, Parallel3dAxisGeometry, ConeFlatGeometry) -from multiprocessing import Lock __all__ = ('ASTRA_CUDA_AVAILABLE', @@ -348,9 +350,6 @@ def astra_cuda_bp_scaling_factor(proj_space, reco_space, geometry): Behavior of ASTRA changes slightly between versions, so we keep track of it and adapt the scaling accordingly. """ - # Lazy import due to long import time - from pkg_resources import parse_version - # Angular integration weighting factor # angle interval weight by approximate cell volume angle_extent = geometry.motion_partition.extent diff --git a/odl/trafos/backends/pyfftw_bindings.py b/odl/trafos/backends/pyfftw_bindings.py index cf109b6a605..b96a10fe150 100644 --- a/odl/trafos/backends/pyfftw_bindings.py +++ b/odl/trafos/backends/pyfftw_bindings.py @@ -1,4 +1,4 @@ -# Copyright 2014-2017 The ODL contributors +# Copyright 2014-2018 The ODL contributors # # This file is part of ODL. # @@ -16,18 +16,16 @@ from __future__ import print_function, division, absolute_import from multiprocessing import cpu_count import numpy as np +from packaging.version import parse as parse_version import warnings + try: import pyfftw PYFFTW_AVAILABLE = True except ImportError: PYFFTW_AVAILABLE = False else: - # Cheap way of getting the version, works with Git revision versions like - # '0.10.4+201.gdb78c2b' - _maj, _min, _patch = [int(n.split('+')[0]) - for n in pyfftw.__version__.split('.')[:3]] - if (_maj, _min, _patch) < (0, 10, 3): + if parse_version(pyfftw.__version__) < parse_version('0.10.3'): warnings.warn('PyFFTW < 0.10.3 is known to cause problems with some ' 'ODL functionality, see issue #1002.', RuntimeWarning) diff --git a/odl/util/testutils.py b/odl/util/testutils.py index b6314193ed5..1e1e04e2141 100644 --- a/odl/util/testutils.py +++ b/odl/util/testutils.py @@ -1,4 +1,4 @@ -# Copyright 2014-2017 The ODL contributors +# Copyright 2014-2018 The ODL contributors # # This file is part of ODL. # @@ -682,7 +682,7 @@ def run_doctests(skip_if=False, **kwargs): function. """ from doctest import testmod, NORMALIZE_WHITESPACE, SKIP - from pkg_resources import parse_version + from packaging.version import parse as parse_version import odl import numpy as np diff --git a/requirements.txt b/requirements.txt index 2887125464d..233b3e0b523 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ future >=0.14 +packaging >=15.0 numpy >=1.10,!=1.14.0.!=1.14.1,!=1.14.2 scipy >=0.14