Skip to content

Commit

Permalink
Merge pull request #19075 from charris/fix-version-problem
Browse files Browse the repository at this point in the history
BUG: Fix test_numpy_version.
  • Loading branch information
charris committed May 23, 2021
2 parents 32b0261 + 3c84e9a commit ad021d3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
25 changes: 21 additions & 4 deletions numpy/tests/test_numpy_version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
"""
Check the numpy version is valid.
Note that a development version is marked by the presence of 'dev0' or '+'
in the version string, all else is treated as a release. The version string
itself is set from the output of ``git describe`` which relies on tags.
Examples
--------
Valid Development: 1.22.0.dev0 1.22.0.dev0+5-g7999db4df2 1.22.0+5-g7999db4df2
Valid Release: 1.21.0.rc1, 1.21.0.b1, 1.21.0
Invalid: 1.22.0.dev, 1.22.0.dev0-5-g7999db4dfB, 1.21.0.d1, 1.21.a
Note that a release is determined by the version string, which in turn
is controlled by the result of the ``git describe`` command.
"""
import re

import numpy as np
Expand All @@ -7,11 +24,11 @@
def test_valid_numpy_version():
# Verify that the numpy version is a valid one (no .post suffix or other
# nonsense). See gh-6431 for an issue caused by an invalid version.
version_pattern = r"^[0-9]+\.[0-9]+\.[0-9]+(|a[0-9]|b[0-9]|rc[0-9])"
dev_suffix = r"\.dev0\+[0-9]*\.g[0-9a-f]+"
version_pattern = r"^[0-9]+\.[0-9]+\.[0-9]+(a[0-9]|b[0-9]|rc[0-9]|)"
dev_suffix = r"(\.dev0|)(\+[0-9]*\.g[0-9a-f]+|)"
if np.version.release:
res = re.match(version_pattern, np.__version__)
res = re.match(version_pattern + '$', np.__version__)
else:
res = re.match(version_pattern + dev_suffix, np.__version__)
res = re.match(version_pattern + dev_suffix + '$', np.__version__)

assert_(res is not None, np.__version__)
2 changes: 1 addition & 1 deletion numpy/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
version: str = vinfo["version"]
full_version: str = vinfo['version']
git_revision: str = vinfo['full-revisionid']
release = 'dev0' not in version
release = 'dev0' not in version and '+' not in version

del get_versions, vinfo

0 comments on commit ad021d3

Please sign in to comment.