@@ -943,139 +943,6 @@ def processor():
943
943
"""
944
944
return uname ().processor
945
945
946
- ### Various APIs for extracting information from sys.version
947
-
948
- _sys_version_parser = re .compile (
949
- r'([\w.+]+)\s*' # "version<space>"
950
- r'\(#?([^,]+)' # "(#buildno"
951
- r'(?:,\s*([\w ]*)' # ", builddate"
952
- r'(?:,\s*([\w :]*))?)?\)\s*' # ", buildtime)<space>"
953
- r'\[([^\]]+)\]?' , re .ASCII ) # "[compiler]"
954
-
955
- _ironpython_sys_version_parser = re .compile (
956
- r'IronPython\s*'
957
- r'([\d\.]+)'
958
- r'(?: \(([\d\.]+)\))?'
959
- r' on (.NET [\d\.]+)' , re .ASCII )
960
-
961
- # IronPython covering 2.6 and 2.7
962
- _ironpython26_sys_version_parser = re .compile (
963
- r'([\d.]+)\s*'
964
- r'\(IronPython\s*'
965
- r'[\d.]+\s*'
966
- r'\(([\d.]+)\) on ([\w.]+ [\d.]+(?: \(\d+-bit\))?)\)'
967
- )
968
-
969
- _pypy_sys_version_parser = re .compile (
970
- r'([\w.+]+)\s*'
971
- r'\(#?([^,]+),\s*([\w ]+),\s*([\w :]+)\)\s*'
972
- r'\[PyPy [^\]]+\]?' )
973
-
974
- _sys_version_cache = {}
975
-
976
- def _sys_version (sys_version = None ):
977
-
978
- """ Returns a parsed version of Python's sys.version as tuple
979
- (name, version, branch, revision, buildno, builddate, compiler)
980
- referring to the Python implementation name, version, branch,
981
- revision, build number, build date/time as string and the compiler
982
- identification string.
983
-
984
- Note that unlike the Python sys.version, the returned value
985
- for the Python version will always include the patchlevel (it
986
- defaults to '.0').
987
-
988
- The function returns empty strings for tuple entries that
989
- cannot be determined.
990
-
991
- sys_version may be given to parse an alternative version
992
- string, e.g. if the version was read from a different Python
993
- interpreter.
994
-
995
- """
996
- # Get the Python version
997
- if sys_version is None :
998
- sys_version = sys .version
999
-
1000
- # Try the cache first
1001
- result = _sys_version_cache .get (sys_version , None )
1002
- if result is not None :
1003
- return result
1004
-
1005
- # Parse it
1006
- if 'IronPython' in sys_version :
1007
- # IronPython
1008
- name = 'IronPython'
1009
- if sys_version .startswith ('IronPython' ):
1010
- match = _ironpython_sys_version_parser .match (sys_version )
1011
- else :
1012
- match = _ironpython26_sys_version_parser .match (sys_version )
1013
-
1014
- if match is None :
1015
- raise ValueError (
1016
- 'failed to parse IronPython sys.version: %s' %
1017
- repr (sys_version ))
1018
-
1019
- version , alt_version , compiler = match .groups ()
1020
- buildno = ''
1021
- builddate = ''
1022
-
1023
- elif sys .platform .startswith ('java' ):
1024
- # Jython
1025
- name = 'Jython'
1026
- match = _sys_version_parser .match (sys_version )
1027
- if match is None :
1028
- raise ValueError (
1029
- 'failed to parse Jython sys.version: %s' %
1030
- repr (sys_version ))
1031
- version , buildno , builddate , buildtime , _ = match .groups ()
1032
- if builddate is None :
1033
- builddate = ''
1034
- compiler = sys .platform
1035
-
1036
- elif "PyPy" in sys_version :
1037
- # PyPy
1038
- name = "PyPy"
1039
- match = _pypy_sys_version_parser .match (sys_version )
1040
- if match is None :
1041
- raise ValueError ("failed to parse PyPy sys.version: %s" %
1042
- repr (sys_version ))
1043
- version , buildno , builddate , buildtime = match .groups ()
1044
- compiler = ""
1045
-
1046
- else :
1047
- # CPython
1048
- match = _sys_version_parser .match (sys_version )
1049
- if match is None :
1050
- raise ValueError (
1051
- 'failed to parse CPython sys.version: %s' %
1052
- repr (sys_version ))
1053
- version , buildno , builddate , buildtime , compiler = \
1054
- match .groups ()
1055
- name = 'CPython'
1056
- if builddate is None :
1057
- builddate = ''
1058
- elif buildtime :
1059
- builddate = builddate + ' ' + buildtime
1060
-
1061
- if hasattr (sys , '_git' ):
1062
- _ , branch , revision = sys ._git
1063
- elif hasattr (sys , '_mercurial' ):
1064
- _ , branch , revision = sys ._mercurial
1065
- else :
1066
- branch = ''
1067
- revision = ''
1068
-
1069
- # Add the patchlevel version if missing
1070
- l = version .split ('.' )
1071
- if len (l ) == 2 :
1072
- l .append ('0' )
1073
- version = '.' .join (l )
1074
-
1075
- # Build and cache the result
1076
- result = (name , version , branch , revision , buildno , builddate , compiler )
1077
- _sys_version_cache [sys_version ] = result
1078
- return result
1079
946
1080
947
# RustPython specific
1081
948
from _platform import *
0 commit comments