diff --git a/py/makeversionhdr.py b/py/makeversionhdr.py index e4ddf9fa1e..6576c3abbb 100644 --- a/py/makeversionhdr.py +++ b/py/makeversionhdr.py @@ -59,29 +59,25 @@ def get_version_info_from_git(): return git_tag, git_hash, ver -def get_version_info_from_docs_conf(): - with open(os.path.join(os.path.dirname(sys.argv[0]), "..", "conf.py")) as f: - for line in f: - if line.startswith("version = release = '"): - ver = line.strip().split(" = ")[2].strip("'") - git_tag = "v" + ver - ver = ver.split(".") - if len(ver) == 2: - ver.append("0") - return git_tag, "", ver - return None +def cannot_determine_version(): + raise SystemExit( + """Cannot determine version. + +CircuitPython must be built from a git clone with tags. +If you cloned from a fork, fetch the tags from adafruit/circuitpython as follows: + + git fetch --tags --recurse-submodules=no --shallow-since="2021-07-01" https://github.com/adafruit/circuitpython HEAD""" + ) def make_version_header(filename): - # Get version info using git, with fallback to docs/conf.py + # Get version info using git (required) info = get_version_info_from_git() if info is None: - info = get_version_info_from_docs_conf() - + cannot_determine_version() git_tag, git_hash, ver = info if len(ver) < 3: - ver = ("0", "0", "0") - version_string = git_hash + cannot_determine_version() else: version_string = ".".join(ver)