Skip to content

Commit

Permalink
Merge #926
Browse files Browse the repository at this point in the history
926: use packaging.version.parse instead of StrictVersion for version checking r=hgrecco a=keewis

fixes #872

`distutils.version.StrictVersion` cannot parse numpy development versions like `1.19.0.dev0+578f4e7`. `LooseVersion` is able to parse the version, but it compares
```python
>>> LooseVersion("1.19.0.dev0+578f4e7") < LooseVersion("1.19")
False
```
Using `pkg_resources.extern.packaging.version.parse` instead makes this work as expected. Since `setup.py` requires `setuptools`, I think it being installed is a reasonable assumption?

Co-authored-by: Keewis <[email protected]>
  • Loading branch information
bors[bot] and keewis authored Dec 12, 2019
2 parents 43fbae2 + 4b3fc6c commit 5109e05
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pint/quantity.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import re
import warnings

from distutils.version import StrictVersion
from pkg_resources.extern.packaging import version

from .formatting import (remove_custom_flags, siunitx_format_unit, ndarray_to_latex,
ndarray_to_latex_parts)
Expand Down Expand Up @@ -988,7 +988,7 @@ def __mul__(self, other):

def __matmul__(self, other):
# Use NumPy ufunc (existing since 1.16) for matrix multiplication
if StrictVersion(NUMPY_VER) >= StrictVersion('1.16'):
if version.parse(NUMPY_VER) >= version.parse('1.16'):
return np.matmul(self, other)
else:
return NotImplemented
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def read(filename):
'Programming Language :: Python :: 3.8',
],
python_requires='>=3.6',
install_requires=['setuptools'],
extras_require={
'numpy': ['numpy >= 1.14'],
'uncertainties': ['uncertainties >= 3.0'],
Expand Down

0 comments on commit 5109e05

Please sign in to comment.