diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 38d86bae0f..8714958065 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -38,8 +38,8 @@ jobs: run: python tools/ci_fetch_deps.py test ${{ github.sha }} - name: CircuitPython version run: | - git describe --dirty --tags || git log --parents HEAD~4.. - echo >>$GITHUB_ENV CP_VERSION=$(git describe --dirty --tags) + tools/describe || git log --parents HEAD~4.. + echo >>$GITHUB_ENV CP_VERSION=$(tools/describe) - name: Install dependencies run: | sudo apt-get update @@ -144,8 +144,8 @@ jobs: run: python tools/ci_fetch_deps.py mpy-cross-mac ${{ github.sha }} - name: CircuitPython version run: | - git describe --dirty --tags - echo >>$GITHUB_ENV CP_VERSION=$(git describe --dirty --tags) + tools/describe || git log --parents HEAD~4.. + echo >>$GITHUB_ENV CP_VERSION=$(tools/describe) - name: Install dependencies run: | brew install gettext @@ -200,8 +200,8 @@ jobs: run: python tools/ci_fetch_deps.py docs ${{ github.sha }} - name: CircuitPython version run: | - git describe --dirty --tags - echo >>$GITHUB_ENV CP_VERSION=$(git describe --dirty --tags) + tools/describe || git log --parents HEAD~4.. + echo >>$GITHUB_ENV CP_VERSION=$(tools/describe) - name: Set up Python 3 uses: actions/setup-python@v2 with: @@ -375,7 +375,9 @@ jobs: - name: Get CP deps run: python tools/ci_fetch_deps.py ${{ matrix.board }} ${{ github.sha }} - name: CircuitPython version - run: git describe --dirty --tags + run: | + tools/describe || git log --parents HEAD~4.. + echo >>$GITHUB_ENV CP_VERSION=$(tools/describe) - uses: actions/cache@v2 name: Fetch IDF tool cache id: idf-cache diff --git a/.github/workflows/create_website_pr.yml b/.github/workflows/create_website_pr.yml index dc987f0989..2f171fe054 100644 --- a/.github/workflows/create_website_pr.yml +++ b/.github/workflows/create_website_pr.yml @@ -34,7 +34,9 @@ jobs: gcc --version python3 --version - name: CircuitPython version - run: git describe --dirty --tags + run: | + tools/describe || git log --parents HEAD~4.. + echo >>$GITHUB_ENV CP_VERSION=$(tools/describe) - name: Website run: python3 build_board_info.py working-directory: tools diff --git a/.github/workflows/ports_windows.yml b/.github/workflows/ports_windows.yml index 6339746066..5651735cec 100644 --- a/.github/workflows/ports_windows.yml +++ b/.github/workflows/ports_windows.yml @@ -73,8 +73,8 @@ jobs: run: python tools/ci_fetch_deps.py windows ${{ github.sha }} - name: CircuitPython version run: | - git describe --dirty --tags - echo >>$GITHUB_ENV CP_VERSION=$(git describe --dirty --tags) + tools/describe || git log --parents HEAD~4.. + echo >>$GITHUB_ENV CP_VERSION=$(tools/describe) - name: build mpy-cross run: make -j2 -C mpy-cross diff --git a/conf.py b/conf.py index fd92a3cc93..e4c29fb88c 100644 --- a/conf.py +++ b/conf.py @@ -24,12 +24,15 @@ import subprocess import sys import urllib.parse import time +import pathlib from collections import defaultdict from sphinx.transforms import SphinxTransform from docutils import nodes from sphinx import addnodes +tools_describe = (pathlib.Path(__file__).parent / "tools/describe").str() + # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. @@ -129,7 +132,7 @@ copyright = f'2014-{current_date.tm_year}, MicroPython & CircuitPython contribut final_version = "" git_describe = subprocess.run( - ["git", "describe", "--dirty", "--tags"], + [tools_describe], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, encoding="utf-8" diff --git a/py/makeversionhdr.py b/py/makeversionhdr.py index 12eaa3d3f1..da6f7c9f59 100644 --- a/py/makeversionhdr.py +++ b/py/makeversionhdr.py @@ -1,29 +1,25 @@ """ Generate header file with macros defining MicroPython version info. -This script works with Python 2.6, 2.7, 3.3 and 3.4. +This script works with Python 3.7 and newer """ from __future__ import print_function import sys import os +import pathlib import datetime import subprocess +tools_describe = str(pathlib.Path(__file__).parent.parent / "tools/describe") + 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", "--tags", "--dirty", "--always", "--match", "[1-9].*"], + [tools_describe], stderr=subprocess.STDOUT, universal_newlines=True, ).strip() diff --git a/tools/describe b/tools/describe new file mode 100755 index 0000000000..c4dcf8bb9d --- /dev/null +++ b/tools/describe @@ -0,0 +1,2 @@ +#!/bin/sh +git describe --dirty --tags --always --match "[1-9].*"