Skip to content

Commit

Permalink
fix: consider, and exclude, nightly info during version regex
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdefinitelyahuman committed Dec 28, 2020
1 parent 5de1b8a commit 3392e9e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions solcx/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@
from solcx import install
from solcx.exceptions import SolcError, UnknownOption, UnknownValue

# (major.minor.patch)(nightly)(commit)
VERSION_REGEX = r"(\d+\.\d+\.\d+)(?:-nightly.\d+.\d+.\d+|)(\+commit.\w+)"


def _get_solc_version(solc_binary: Union[Path, str], with_commit_hash: bool = False) -> Version:
# private wrapper function to get `solc` version
stdout_data = subprocess.check_output([str(solc_binary), "--version"], encoding="utf8")
try:
version_str = re.findall(r"\d+\.\d+\.\d+\+commit.\w+", stdout_data)[0]
except IndexError:
match = next(re.finditer(VERSION_REGEX, stdout_data))
version_str = "".join(match.groups())
except StopIteration:
raise SolcError("Could not determine the solc binary version")

version = Version.coerce(version_str)
Expand Down

0 comments on commit 3392e9e

Please sign in to comment.