diff --git a/solcx/wrapper.py b/solcx/wrapper.py index 2e2aceb..b5c12fe 100644 --- a/solcx/wrapper.py +++ b/solcx/wrapper.py @@ -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)