diff --git a/Lib/platform.py b/Lib/platform.py index 6fbb7b08c..679214c36 100755 --- a/Lib/platform.py +++ b/Lib/platform.py @@ -604,9 +604,11 @@ def _syscmd_uname(option, default=''): """ Interface to the system's uname command. """ - if sys.platform in ('dos', 'win32', 'win16'): - # XXX Others too ? - return default + # TODO: fix RustPython + return default + # if sys.platform in ('dos', 'win32', 'win16'): + # # XXX Others too ? + # return default import subprocess try: @@ -967,6 +969,14 @@ _pypy_sys_version_parser = re.compile( r'\(#?([^,]+),\s*([\w ]+),\s*([\w :]+)\)\s*' r'\[PyPy [^\]]+\]?') +_rustpython_sys_version_parser = re.compile( + r'RustPython ' + r'([\w.+]+)\s*' # "version" + r'\(#?([^,]+)' # "(#buildno" + r'(?:,\s*([\w ]*)' # ", builddate" + r'(?:,\s*([\w :]*))?)?\)\s*' # ", buildtime)" + r'\[([^\]]+)\]?', re.ASCII) # "[compiler]" + _sys_version_cache = {} def _sys_version(sys_version=None): @@ -1039,6 +1049,16 @@ def _sys_version(sys_version=None): version, buildno, builddate, buildtime = match.groups() compiler = "" + elif "RustPython" in sys_version: + # RustPython + name = "RustPython" + match = _rustpython_sys_version_parser.match(sys_version) + if match is None: + raise ValueError("failed to parse RustPython sys.version: %s" % + repr(sys_version)) + version, buildno, builddate, buildtime, compiler = \ + match.groups() + else: # CPython match = _sys_version_parser.match(sys_version) diff --git a/vm/src/version.rs b/vm/src/version.rs index 5981d17c5..5e2ebd5eb 100644 --- a/vm/src/version.rs +++ b/vm/src/version.rs @@ -23,7 +23,7 @@ use std::time::{Duration, UNIX_EPOCH}; pub fn get_version() -> String { format!( - "{:.80} ({:.80}) {:.80}", + "RustPython {:.80} ({:.80}) {:.80}", get_version_number(), get_build_info(), get_compiler()