From bc5bbf8208c82ffebeb07aaaaa8a7b437299c4db Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Mon, 17 Jun 2024 00:50:42 +0200 Subject: [PATCH 1/4] Bumped version to v0.14.1. --- dist/requirements.txt | 2 +- doc/Dependency.rst | 4 ++-- pyVersioning/__init__.py | 2 +- requirements.txt | 2 +- tests/requirements.txt | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dist/requirements.txt b/dist/requirements.txt index 5be2dd07..71950fcd 100644 --- a/dist/requirements.txt +++ b/dist/requirements.txt @@ -1,2 +1,2 @@ wheel ~= 0.43 -twine ~= 5.0 +twine ~= 5.1 diff --git a/doc/Dependency.rst b/doc/Dependency.rst index 45ee065d..14b8500f 100644 --- a/doc/Dependency.rst +++ b/doc/Dependency.rst @@ -102,7 +102,7 @@ the mandatory dependencies too. +---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+ | `mypy `__ | ≥1.10 | `MIT `__ | *Not yet evaluated.* | +---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+ -| `typing-extensions `__ | ≥4.11 | `PSF-2.0 `__ | *Not yet evaluated.* | +| `typing-extensions `__ | ≥4.12 | `PSF-2.0 `__ | *Not yet evaluated.* | +---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+ | `lxml `__ | ≥5.1 | `BSD 3-Clause `__ | *Not yet evaluated.* | +---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+ @@ -246,5 +246,5 @@ install the mandatory dependencies too. +==========================================================+==============+===========================================================================================+======================+ | `wheel `__ | ≥0.43 | `MIT `__ | *Not yet evaluated.* | +----------------------------------------------------------+--------------+-------------------------------------------------------------------------------------------+----------------------+ -| `Twine `__ | ≥5.0 | `Apache License, 2.0 `__ | *Not yet evaluated.* | +| `Twine `__ | ≥5.1 | `Apache License, 2.0 `__ | *Not yet evaluated.* | +----------------------------------------------------------+--------------+-------------------------------------------------------------------------------------------+----------------------+ diff --git a/pyVersioning/__init__.py b/pyVersioning/__init__.py index 857be471..a1c9ff46 100644 --- a/pyVersioning/__init__.py +++ b/pyVersioning/__init__.py @@ -32,7 +32,7 @@ __email__ = "Paebbels@gmail.com" __copyright__ = "2020-2024, Patrick Lehmann" __license__ = "Apache License, Version 2.0" -__version__ = "0.14.0" +__version__ = "0.14.1" __keywords__ = ["Python3", "Template", "Versioning", "Git"] from dataclasses import make_dataclass diff --git a/requirements.txt b/requirements.txt index e4ea45dc..9bd6dc39 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ ruamel.yaml ~= 0.18.6 -pyTooling[terminal] ~= 6.1 +pyTooling[terminal] ~= 6.3 diff --git a/tests/requirements.txt b/tests/requirements.txt index d7bdbde9..49289374 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -9,5 +9,5 @@ pytest-cov ~= 5.0 # Static Type Checking mypy ~= 1.10 -typing_extensions ~= 4.11 +typing_extensions ~= 4.12 lxml ~= 5.1 From 35ef8045fc87d1740688f53e39e9ca11cf4b84f2 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Mon, 17 Jun 2024 06:46:30 +0200 Subject: [PATCH 2/4] Compiling C example. --- .github/workflows/Pipeline.yml | 38 ++++++++++++++ .gitignore | 4 ++ example/C/versioning.h | 96 ++++++++++++++++++++++++++++++++++ 3 files changed, 138 insertions(+) create mode 100644 example/C/versioning.h diff --git a/.github/workflows/Pipeline.yml b/.github/workflows/Pipeline.yml index b0dd828d..22b2f6fe 100644 --- a/.github/workflows/Pipeline.yml +++ b/.github/workflows/Pipeline.yml @@ -79,6 +79,44 @@ jobs: wheel: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).package_all }} apptest_xml_artifact: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).apptesting_xml }} + C_Example: + runs-on: ubuntu-latest + needs: + - UnitTestingParams + - Package + defaults: + run: + shell: bash + steps: + - name: ⏬ Checkout repository + uses: actions/checkout@v4 + + - name: 📥 Download artifacts '${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).package_all }}' from 'Package' job + uses: actions/download-artifact@v4 + with: + name: ${{ fromJson(needs.UnitTestingParams.outputs.artifact_names).package_all }} + path: install + + - name: 🔧 Install wheel from artifact + run: | + ls -l install + python -m pip install --disable-pip-version-check -U install/*.whl + + - name: Generate versioning.c + run: | + cd example/C + pyVersioning fillout ../../templates/C/versioning.c.template versioning.c + + - name: Compile example + run: | + cd example/C + gcc -o example.exe example.c versioning.c + + - name: Execute example + run: | + cd example/C + ./example + PublishCoverageResults: uses: pyTooling/Actions/.github/workflows/PublishCoverageResults.yml@r1 needs: diff --git a/.gitignore b/.gitignore index 21b9d6a5..c78482f1 100644 --- a/.gitignore +++ b/.gitignore @@ -34,5 +34,9 @@ doc/_theme/**/*.* /tests/template.json /tests/template.yaml +# Generated code from examples +/example/C/versioning.c +/example/C/example.exe + # Git files !.git* diff --git a/example/C/versioning.h b/example/C/versioning.h new file mode 100644 index 00000000..48a67730 --- /dev/null +++ b/example/C/versioning.h @@ -0,0 +1,96 @@ +/*********************************************************************************************************************** +/* __ __ _ _ * +/* _ __ _ \ \ / /__ _ __ ___(_) ___ _ __ (_)_ __ __ _ * +/* | '_ \| | | \ \ / / _ \ '__/ __| |/ _ \| '_ \| | '_ \ / _` | * +/* | |_) | |_| |\ V / __/ | \__ \ | (_) | | | | | | | | (_| | * +/* | .__/ \__, | \_/ \___|_| |___/_|\___/|_| |_|_|_| |_|\__, | * +/* |_| |___/ |___/ * +/*********************************************************************************************************************** +/* @author Patrick Lehmann * +/* * +/* @brief C Structure definitions for pyVersioning * +/* * +/* @copyright Copyright 2020-2024 Patrick Lehmann - Boetzingen, Germany * +/* * +/* Licensed under the Apache License, Version 2.0 (the "License"); * +/* you may not use this file except in compliance with the License. * +/* You may obtain a copy of the License at * +/* * +/* http://www.apache.org/licenses/LICENSE-2.0 * +/* * +/* Unless required by applicable law or agreed to in writing, software * +/* distributed under the License is distributed on an "AS IS" BASIS, * +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +/* See the License for the specific language governing permissions and * +/* limitations under the License. * +/* * +/* SPDX-License-Identifier: Apache-2.0 * +/**********************************************************************************************************************/ +#include + +#ifndef VERSIONING_H +#define VERSIONING_H + +typedef struct { + uint8_t day; + uint8_t month; + uint16_t year; +} Date; + +typedef struct { + uint8_t hour; + uint8_t minute; + uint8_t second; +} Time; + +typedef struct { + Date date; + Time time; +} DateTime; + +typedef struct { + uint8_t flags; + uint16_t major; + uint16_t minor; + uint16_t patch; +} Version; + +typedef struct { + char hash[41]; // hex-value as string (160-bit => 40 characters + \0) + DateTime datetime; +} Commit; + +typedef struct { + Commit commit; + const char* reference; + const char* repository; +} Git; + +typedef struct { + const char* name; + const char* variant; +} Project; + +typedef struct { + const char* name; + Version version; + const char* configuration; + const char* options; +} Compiler; + +typedef struct { + DateTime datetime; + Compiler compiler; +} Build; + +typedef struct { + Version version; + Git git; + Project project; + Build build; +} VersioningInformation; + + +extern const VersioningInformation versioningInformation; + +#endif /* VERSIONING_H */ From 82c5232c53b4355701f30c658647b4d778feef0d Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Mon, 17 Jun 2024 07:00:33 +0200 Subject: [PATCH 3/4] Fixed C template. --- .github/workflows/Pipeline.yml | 1 + pyVersioning/__init__.py | 5 ++++- templates/C/versioning.c.template | 16 ++++++++-------- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/Pipeline.yml b/.github/workflows/Pipeline.yml index 22b2f6fe..a8eee47a 100644 --- a/.github/workflows/Pipeline.yml +++ b/.github/workflows/Pipeline.yml @@ -198,6 +198,7 @@ jobs: if: startsWith(github.ref, 'refs/tags') needs: - AppTesting + - C_Example - PublishToGitHubPages PublishOnPyPI: diff --git a/pyVersioning/__init__.py b/pyVersioning/__init__.py index a1c9ff46..23e200a4 100644 --- a/pyVersioning/__init__.py +++ b/pyVersioning/__init__.py @@ -651,4 +651,7 @@ def func(s) -> Generator[Tuple[str, Any], None, None]: def FillOutTemplate(self, template: str, **kwargs) -> str: # apply variables - return template.format(**self._variables, **kwargs) + try: + return template.format(**self._variables, **kwargs) + except AttributeError as ex: + self.WriteFatal(f"Syntax error in template. Accessing field '{ex.name}'") diff --git a/templates/C/versioning.c.template b/templates/C/versioning.c.template index 70472a57..bf68a87f 100644 --- a/templates/C/versioning.c.template +++ b/templates/C/versioning.c.template @@ -30,10 +30,10 @@ const VersioningInformation versioningInformation = {{ .version = {{ - .flags = 0x0/*{{version.flags:02X}}*/, - .major = 0x{version.major} /*:02X}}*/, - .minor = 0x{version.minor} /*:02X}}*/, - .patch = 0x{version.patch} /*:02X}}*/ + .flags = 0x0/*{{version.Flags:02X}}*/, + .major = 0x{version.Major} /*:02X}}*/, + .minor = 0x{version.Minor} /*:02X}}*/, + .patch = 0x{version.Patch} /*:02X}}*/ }}, .git = {{ .commit = {{ @@ -74,10 +74,10 @@ const VersioningInformation versioningInformation = {{ .compiler = {{ .name = "{build.compiler.name}\0", .version = {{ - .flags = 0x0/*{{build.compiler.version.flags:02X}}*/, - .major = /*0x*/ {build.compiler.version.major} /*:02X}}*/, - .minor = 0x{build.compiler.version.minor} /*:02X}}*/, - .patch = 0x{build.compiler.version.patch} /*:02X}}*/ + .flags = 0x0/*{{build.compiler.version.Flags:02X}}*/, + .major = /*0x*/ {build.compiler.version.Major} /*:02X}}*/, + .minor = 0x{build.compiler.version.Minor} /*:02X}}*/, + .patch = 0x{build.compiler.version.Patch} /*:02X}}*/ }}, .configuration = "{build.compiler.configuration}\0", .options = "{build.compiler.options}\0" From 25978531da2e501fe3a608609a4c4ae3c202ba75 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Mon, 17 Jun 2024 07:06:28 +0200 Subject: [PATCH 4/4] Execute compiled example. --- .github/workflows/Pipeline.yml | 2 +- pyVersioning/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Pipeline.yml b/.github/workflows/Pipeline.yml index a8eee47a..3c9ebe6b 100644 --- a/.github/workflows/Pipeline.yml +++ b/.github/workflows/Pipeline.yml @@ -110,7 +110,7 @@ jobs: - name: Compile example run: | cd example/C - gcc -o example.exe example.c versioning.c + gcc -o example example.c versioning.c - name: Execute example run: | diff --git a/pyVersioning/__init__.py b/pyVersioning/__init__.py index 23e200a4..bbc58a34 100644 --- a/pyVersioning/__init__.py +++ b/pyVersioning/__init__.py @@ -654,4 +654,4 @@ def FillOutTemplate(self, template: str, **kwargs) -> str: try: return template.format(**self._variables, **kwargs) except AttributeError as ex: - self.WriteFatal(f"Syntax error in template. Accessing field '{ex.name}'") + self.WriteFatal(f"Syntax error in template. Accessing field '{ex.name}' of '{ex.obj.__class__.__name__}'.")