Skip to content

Commit

Permalink
typehints
Browse files Browse the repository at this point in the history
  • Loading branch information
henryborchers committed Oct 11, 2023
1 parent 841dd84 commit c249762
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions uiucprescon/build/compiler_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def get_compiler_name() -> str:
_cfg_target_split = None


def get_visual_studio_version():
def get_visual_studio_version() -> str:
import winreg
possible_versions = [
"8.0", "9.0", "10.0", "11.0", "12.0", "14.0", "15.0", "16.0"
Expand All @@ -66,7 +66,7 @@ def get_visual_studio_version():
return sorted_values[-1].split(".")[0]


def get_clang_version():
def get_clang_version() -> str:
cmd = ['cc', '--version']

env = None
Expand Down Expand Up @@ -103,6 +103,8 @@ def get_clang_version():
exitcode = proc.returncode
clang_version_regex = re.compile(
r'(?<=Apple clang version )((\d+[.]){1,2}\d+)')
if proc.stdout is None:
raise ValueError("unable to read standard out of process")
compiler_response = proc.stdout.read().decode('utf-8')
try:
env_version = clang_version_regex.search(
Expand All @@ -123,12 +125,14 @@ def get_clang_version():
raise ExecError("command %r failed: %s" % (cmd, exc.args[-1])) from exc


def get_gcc_version():
def get_gcc_version() -> str:
cmd = ['cc', '-dumpfullversion', '-dumpversion']
try:
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
proc.wait()
exitcode = proc.returncode
if proc.stdout is None:
raise ValueError("unable to read standard out of process")
compiler_response = proc.stdout.read().decode('utf-8')
if exitcode:
raise ExecError(f"command {cmd} failed with exit code {exitcode}")
Expand All @@ -142,7 +146,7 @@ def get_gcc_version():
raise ExecError("command %r failed: %s" % (cmd, exc.args[-1])) from exc


def get_compiler_version():
def get_compiler_version() -> str:
"""
Examples of compiler data:
GCC 10.2.1 20210110
Expand Down

0 comments on commit c249762

Please sign in to comment.