From 74bd4c201be1fe5e819a528c5c9e1b01585bb191 Mon Sep 17 00:00:00 2001 From: d33bs Date: Wed, 15 May 2024 11:20:32 -0600 Subject: [PATCH] add package dynamic versioning capabilities --- .pre-commit-config.yaml | 4 ++++ CONTRIBUTING.md | 11 +++++++++++ poetry.lock | 2 +- pyproject.toml | 19 +++++++++++++++++-- src/sculptqc/__init__.py | 4 ++++ 5 files changed, 37 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index eaa180a..3ffa1f2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,6 +11,10 @@ repos: - id: check-yaml - id: check-added-large-files - id: detect-private-key + - repo: https://github.com/python-poetry/poetry + rev: "1.5.1" + hooks: + - id: poetry-check - repo: https://github.com/codespell-project/codespell rev: v2.2.6 hooks: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b997b19..7a39e02 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -83,3 +83,14 @@ Pull request review and approval is required by at least one project maintainer We will do our best to review the code addition in a timely fashion. Ensuring that you follow all steps above will increase our speed and ability to review. We will check for accuracy, style, code coverage, and scope. + +## Versioning + +We use [`poetry-dynamic-versioning`](https://github.com/mtkennerly/poetry-dynamic-versioning) to help version this software through [`PEP 440`](https://peps.python.org/pep-0440/) standards. +Configuration for versioning is found within the `pyproject.toml` file. +All builds for packages include dynamic version data to help label distinct versions of the software. +`poetry-dynamic-versioning` uses `git` tags to help distinguish version data. +We also use the `__init__.py` file as a place to persist the version data for occaissions where the `git` history is unavailable or unwanted. + +The following command is used to add `poetry-dynamic-versioning` to Poetry for use with this project: `poetry self add "poetry-dynamic-versioning[plugin]"`. +Versioning for the project is intended to align with GitHub Releases which provide `git` tag capabilities. diff --git a/poetry.lock b/poetry.lock index a9bf4e0..59a6c67 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. [[package]] name = "colorama" diff --git a/pyproject.toml b/pyproject.toml index 667c743..1d8f262 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,9 +53,24 @@ select = [ # Ignore `E402` and `F401` (unused imports) in all `__init__.py` files "__init__.py" = ["E402", "F401"] +# set dynamic versioning capabilities for project +[tool.poetry-dynamic-versioning] +enable = true +style = "pep440" +vcs = "git" + +# specify where version replacement is performed +[tool.poetry-dynamic-versioning.substitution] +files = ["src/sculptqc/__init__.py"] + +# set persistent versions within the __init__.py file in cases +# where we may not have or want access to full git history +[tool.poetry-dynamic-versioning.files."src/sculptqc/__init__.py"] +persistent-substitution = true + [build-system] -requires = ["poetry-core"] -build-backend = "poetry.core.masonry.api" +requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning>=1.0.0,<2.0.0"] +build-backend = "poetry_dynamic_versioning.backend" [tool.setuptools_scm] root = "." diff --git a/src/sculptqc/__init__.py b/src/sculptqc/__init__.py index 5c087ef..43f42fd 100644 --- a/src/sculptqc/__init__.py +++ b/src/sculptqc/__init__.py @@ -3,3 +3,7 @@ """ from .analyze import find_outliers + +# note: version placeholder is updated during build +# by poetry-dynamic-versioning. +__version__ = "0.0.1"