diff options
author | Damien George <damien.p.george@gmail.com> | 2015-05-30 23:11:16 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-05-30 23:11:16 +0100 |
commit | 26b512ea1bcc8035f8f5312b2065c85a639c02ae (patch) | |
tree | e7f84cafb196d6885f07bfd5a16c0603cd2cbb6f /py/makeversionhdr.py | |
parent | 7d8edeff4e81e89ed8833d9933effd1e2431f7f1 (diff) | |
download | micropython-26b512ea1bcc8035f8f5312b2065c85a639c02ae.tar.gz micropython-26b512ea1bcc8035f8f5312b2065c85a639c02ae.zip |
py: Get makeqstrdata.py and makeversionhdr.py running under Python 2.6.
These scripts should run under as wide a range of Python versions as
possible.
Diffstat (limited to 'py/makeversionhdr.py')
-rw-r--r-- | py/makeversionhdr.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/py/makeversionhdr.py b/py/makeversionhdr.py index f178b7534a..708d67df7f 100644 --- a/py/makeversionhdr.py +++ b/py/makeversionhdr.py @@ -1,4 +1,8 @@ -# This script works with Python 2 and 3 +""" +Generate header file with macros defining MicroPython version info. + +This script works with Python 2.6, 2.7, 3.3 and 3.4. +""" from __future__ import print_function @@ -8,6 +12,13 @@ import datetime import subprocess def get_version_info_from_git(): + # Python 2.6 doesn't have check_output, so check for that + try: + subprocess.check_output + subprocess.check_call + except AttributeError: + return None + # Note: git describe doesn't work if no tag is available try: git_tag = subprocess.check_output(["git", "describe", "--dirty", "--always"], universal_newlines=True).strip() @@ -89,4 +100,5 @@ def make_version_header(filename): with open(filename, 'w') as f: f.write(file_data) -make_version_header(sys.argv[1]) +if __name__ == "__main__": + make_version_header(sys.argv[1]) |