changeset 41443:1a6a01a21d6a

hghave: add pyXY features for Python version numbers This will allow us to sniff for Python >= versions in tests. Differential Revision: https://phab.mercurial-scm.org/D5088
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 13 Oct 2018 16:53:43 +0200
parents e7fcbeb95249
children d5357238eda9
files tests/hghave.py
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/tests/hghave.py	Tue Jan 29 14:30:10 2019 +0300
+++ b/tests/hghave.py	Sat Oct 13 16:53:43 2018 +0200
@@ -646,6 +646,13 @@
     # chg disables demandimport intentionally for performance wins.
     return ((not has_chg()) and os.environ.get('HGDEMANDIMPORT') != 'disable')
 
+@checkvers("py", "Python >= %s", (2.7, 3.5, 3.6, 3.7, 3.8, 3.9))
+def has_python_range(v):
+    major, minor = v.split('.')[0:2]
+    py_major, py_minor = sys.version_info.major, sys.version_info.minor
+
+    return (py_major, py_minor) >= (int(major), int(minor))
+
 @check("py3", "running with Python 3.x")
 def has_py3():
     return 3 == sys.version_info[0]