Skip to content

Commit

Permalink
v0.14.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Paebbels authored Jun 17, 2024
2 parents 79ca9b2 + 2597853 commit 03fb134
Show file tree
Hide file tree
Showing 9 changed files with 157 additions and 15 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/Pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 example.c versioning.c
- name: Execute example
run: |
cd example/C
./example
PublishCoverageResults:
uses: pyTooling/Actions/.github/workflows/PublishCoverageResults.yml@r1
needs:
Expand Down Expand Up @@ -160,6 +198,7 @@ jobs:
if: startsWith(github.ref, 'refs/tags')
needs:
- AppTesting
- C_Example
- PublishToGitHubPages

PublishOnPyPI:
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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*
2 changes: 1 addition & 1 deletion dist/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
wheel ~= 0.43
twine ~= 5.0
twine ~= 5.1
4 changes: 2 additions & 2 deletions doc/Dependency.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ the mandatory dependencies too.
+---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
| `mypy <https://GitHub.com/python/mypy>`__ | ≥1.10 | `MIT <https://GitHub.com/python/mypy/blob/master/LICENSE>`__ | *Not yet evaluated.* |
+---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
| `typing-extensions <https://GitHub.com/python/typing_extensions>`__ | ≥4.11 | `PSF-2.0 <https://github.com/python/typing_extensions/blob/main/LICENSE>`__ | *Not yet evaluated.* |
| `typing-extensions <https://GitHub.com/python/typing_extensions>`__ | ≥4.12 | `PSF-2.0 <https://github.com/python/typing_extensions/blob/main/LICENSE>`__ | *Not yet evaluated.* |
+---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
| `lxml <https://GitHub.com/lxml/lxml>`__ | ≥5.1 | `BSD 3-Clause <https://GitHub.com/lxml/lxml/blob/master/LICENSE.txt>`__ | *Not yet evaluated.* |
+---------------------------------------------------------------------+-------------+----------------------------------------------------------------------------------------+----------------------+
Expand Down Expand Up @@ -246,5 +246,5 @@ install the mandatory dependencies too.
+==========================================================+==============+===========================================================================================+======================+
| `wheel <https://GitHub.com/pypa/wheel>`__ | ≥0.43 | `MIT <https://github.com/pypa/wheel/blob/main/LICENSE.txt>`__ | *Not yet evaluated.* |
+----------------------------------------------------------+--------------+-------------------------------------------------------------------------------------------+----------------------+
| `Twine <https://GitHub.com/pypa/twine/>`__ | ≥5.0 | `Apache License, 2.0 <https://github.com/pypa/twine/blob/main/LICENSE>`__ | *Not yet evaluated.* |
| `Twine <https://GitHub.com/pypa/twine/>`__ | ≥5.1 | `Apache License, 2.0 <https://github.com/pypa/twine/blob/main/LICENSE>`__ | *Not yet evaluated.* |
+----------------------------------------------------------+--------------+-------------------------------------------------------------------------------------------+----------------------+
96 changes: 96 additions & 0 deletions example/C/versioning.h
Original file line number Diff line number Diff line change
@@ -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 <stdint.h>

#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 */
7 changes: 5 additions & 2 deletions pyVersioning/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
__email__ = "[email protected]"
__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
Expand Down Expand Up @@ -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}' of '{ex.obj.__class__.__name__}'.")
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ruamel.yaml ~= 0.18.6
pyTooling[terminal] ~= 6.1
pyTooling[terminal] ~= 6.3
16 changes: 8 additions & 8 deletions templates/C/versioning.c.template
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {{
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 03fb134

Please sign in to comment.