Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1#!/usr/bin/env python 

2 

3""" 

4camcops_server/cc_modules/cc_pythonversion.py 

5 

6=============================================================================== 

7 

8 Copyright (C) 2012-2020 Rudolf Cardinal (rudolf@pobox.com). 

9 

10 This file is part of CamCOPS. 

11 

12 CamCOPS is free software: you can redistribute it and/or modify 

13 it under the terms of the GNU General Public License as published by 

14 the Free Software Foundation, either version 3 of the License, or 

15 (at your option) any later version. 

16 

17 CamCOPS is distributed in the hope that it will be useful, 

18 but WITHOUT ANY WARRANTY; without even the implied warranty of 

19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

20 GNU General Public License for more details. 

21 

22 You should have received a copy of the GNU General Public License 

23 along with CamCOPS. If not, see <https://www.gnu.org/licenses/>. 

24 

25=============================================================================== 

26 

27**Single place to determine the Python version required.** 

28 

29Currently that is v3.6 (as of CamCOPS v2.3.1, 2019). That enables: 

30 

31- f-strings (v3.6) 

32 

33but not: 

34 

35- dataclasses (v3.7) 

36 

37""" 

38 

39import sys 

40 

41MINIMUM_PYTHON_VERSION = (3, 6) 

42 

43 

44def assert_minimum_python_version(): 

45 """ 

46 Asserts that this version of Python meets our minimum requirements. 

47 This function should be used except in installation environments where 

48 CamCOPS modules are unavailable. 

49 

50 Raises: 

51 AssertionError 

52 

53 Note that this module/function should use only Python 2 syntax! 

54 

55 """ 

56 if sys.version_info < MINIMUM_PYTHON_VERSION: 

57 required = ".".join(str(x) for x in MINIMUM_PYTHON_VERSION) 

58 actual = ".".join(str(x) for x in sys.version_info) 

59 raise AssertionError("Need Python %s or higher; this is %s" % 

60 (required, actual)) 

61 

62 

63if __name__ == "__main__": 

64 assert_minimum_python_version()