Skip to content
This repository has been archived by the owner on Jul 28, 2023. It is now read-only.

Commit

Permalink
Fix version string parsing of terra (#1135)
Browse files Browse the repository at this point in the history
In the upcoming terra release there will be a release candidate tagged
prior to the final release. However changing the version string for the
package is blocked on the ibmq provider right now because it is trying
to parse the version and is assuming there will be no prelease suffix on
the version string (see Qiskit/qiskit#8200 for the details). This
commit fixes this version parsing to use the regex from the
pypa/packaging project which handles all the PEP440 package versioning
include pre-release suffixes. This will enable terra to release an
0.21.0rc1 tag without breaking the ibmq provider.

Co-authored-by: Rathish Cholarajan <rathishc24@gmail.com>
  • Loading branch information
mtreinish and rathishcholarajan committed Jun 21, 2022
1 parent 5a2e551 commit 3dcfd8a
Showing 1 changed file with 47 additions and 1 deletion.
48 changes: 47 additions & 1 deletion qiskit/providers/ibmq/runtime/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import inspect
import io
import json
import re
import warnings
import zlib
from datetime import date
Expand All @@ -47,7 +48,52 @@

from qiskit.version import __version__ as _terra_version_string

_TERRA_VERSION = tuple(int(x) for x in _terra_version_string.split(".")[:3])

# This version pattern is taken from the pypa packaging project:
# https://github.com/pypa/packaging/blob/21.3/packaging/version.py#L223-L254
# which is dual licensed Apache 2.0 and BSD see the source for the original
# authors and other details
VERSION_PATTERN = (
"^"
+ r"""
v?
(?:
(?:(?P<epoch>[0-9]+)!)? # epoch
(?P<release>[0-9]+(?:\.[0-9]+)*) # release segment
(?P<pre> # pre-release
[-_\.]?
(?P<pre_l>(a|b|c|rc|alpha|beta|pre|preview))
[-_\.]?
(?P<pre_n>[0-9]+)?
)?
(?P<post> # post release
(?:-(?P<post_n1>[0-9]+))
|
(?:
[-_\.]?
(?P<post_l>post|rev|r)
[-_\.]?
(?P<post_n2>[0-9]+)?
)
)?
(?P<dev> # dev release
[-_\.]?
(?P<dev_l>dev)
[-_\.]?
(?P<dev_n>[0-9]+)?
)?
)
(?:\+(?P<local>[a-z0-9]+(?:[-_\.][a-z0-9]+)*))? # local version
"""
+ "$"
)
_TERRA_VERSION = tuple(
int(x) for x in re.search(
VERSION_PATTERN,
_terra_version_string,
re.VERBOSE | re.IGNORECASE
).group("release").split(".")
)


def to_base64_string(data: str) -> str:
Expand Down

0 comments on commit 3dcfd8a

Please sign in to comment.