Name | hatch-ci JSON |
Version |
0.1.3
JSON |
| download |
home_page | |
Summary | Hatch plugin for ci system versioning |
upload_time | 2024-03-17 02:01:01 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.8 |
license | MIT |
keywords |
git
hatch
plugin
scm
version
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# hatch-ci
[![PyPI version](https://img.shields.io/pypi/v/hatch-ci.svg?color=blue)](https://pypi.org/project/hatch-ci)
[![Python versions](https://img.shields.io/pypi/pyversions/hatch-ci.svg)](https://pypi.org/project/hatch-ci)
[![License - MIT](https://img.shields.io/badge/license-MIT-9400d3.svg)](https://spdx.org/licenses/)
[![Build](https://github.com/cav71/hatch-ci/actions/workflows/master.yml/badge.svg)](https://github.com/cav71/hatch-ci/actions/runs/0)
[![codecov](https://codecov.io/gh/cav71/hatch-ci/branch/master/graph/badge.svg?token=521FB9K5KT)](https://codecov.io/gh/cav71/hatch-ci/branch/master)
[![Black](https://img.shields.io/badge/code%20style-black-000000.svg)](Black)
[![Mypy](https://img.shields.io/badge/types-Mypy-blue.svg)](https://mypy-lang.org/)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
## Introduction
This is a [hatch-vcs](https://github.com/ofek/hatch-vcs) heavily inspired plugin: it captures values from
the build environment (eg. github, pyproject.toml etc.) and it uses these
to process files during the build/packaging process.
In a typical project (let's call it foobar):
```
└── foobar-project
├── pyproject.toml
└── src
└── foobar
└── __init__.py <- __version__ and __hash__ are update during build
```
With the pyproject.toml set like:
```text
[build-system]
requires = ["hatchling", "hatch-ci"]
build-backend = "hatchling.build"
[project]
dynamic = ["version"]
# the version-file needs to be repeated twice here
[tool.hatch.version]
version-file = "src/package/__init__.py"
[tool.hatch.build.hooks.ci]
version-file = "src/{name}/__init__.py"
# performs these string replacements
process-replace = [
["re:(replace-me)", "[\\\\1]"],
["string-to-replace", "replacement-string"]
]
# before jinja process these
process-paths = [
"src/project/template.jinja2"
]
```
Building the sdist/wheel package will have the `__version__` and `__hash__` set
depending on the branch and current commit.
### wheel version
During the wheel build the version is dynamically updated with information taken from
the `version-file` field (see "[Version source options](#version-source-options)").
Two variables will be overwritten/modified in `version-file`: the **__version__**
containing the semgrep version and **__hash__** with the git commit for the build.
The version information is augmented with:
- a **bNNN** build number in creating the package foobar-1.0.0bNNNN (this can be sent to [PyPi](https://pypi.org))
- if there's a tag v1.0.0 on the repo, it will build foobar-1.0.0 release (this can be sent to [PyPi](https://pypi.org))
The last two steps are mean to be managed in a CI/CD system (github at the moment), to ensure *hands-off* releases.
In essence this pluging:
- manages the version information
- allows version replacement in text files using build information
**Table of Contents**
- [Global dependency](#global-dependency)
- [Version source](#version-source)
- [Version source options](#version-source-options)
- [License](#license)
## Global dependency
Ensure `hatch-ci` is defined within the `build-system.requires` field in your `pyproject.toml` file.
```toml
[build-system]
requires = ["hatchling", "hatch-ci"]
build-backend = "hatchling.build"
```
## Version source
The [version source plugin](https://hatch.pypa.io/latest/plugins/version-source/reference/) name is `ci`.
This will enable the hatch-ci pluging:
- ***pyproject.toml***
```toml
[project]
..
dynamic = ["version"] # this rerieves the version dynamically
..
```
### Version source options
- ***pyproject.toml***
```toml
[tool.hatch.version]
source = "ci" # this pulls the version using the hatch-ci hook
# this will put/update __version__ and __hash__ info in version-file
version-file = "src/hatch_ci/__init__.py"
# these files will be jinja2 processed, the environment will
# contains variables as: branch, build, current, ref, runid,
# sha, version, workflow etc.
paths = [ "README.md" ]
# the listed paths will undergo replacement before jinja2 processing and
# the variables 'a' & 'b' listed below wil be replaced with ctx attributes.
fixers = [
{ 'a': '{ctx.workflows}' },
{ 'd': '{ctx.branch}' }
]
```
The complete list of attributes is available here [TEMPLATE.md](TEMPLATE.md).
| Option | Type | Default | Description |
| --- | --- |---------|------------------------------------------------------|
| `version-file` | `str` | None | A file where to write __version__/__hash__ variables |
| `paths` | `list[str]|str` | None | A list of paths to process |
| `fixers` | `list[dict[str,str]]` | None | A list of dict, each key is a string to replace with the value |
## License
`hatch-ci` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
Raw data
{
"_id": null,
"home_page": "",
"name": "hatch-ci",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "git,hatch,plugin,scm,version",
"author": "",
"author_email": "Antonio Cavallo <a.cavallo@cavallinux.eu>",
"download_url": "https://files.pythonhosted.org/packages/d7/cb/a7498f6d3789c734313d4b62169ce5a86d199cc0bfefeb7678a5424f6f75/hatch_ci-0.1.3.tar.gz",
"platform": null,
"description": "# hatch-ci\n\n[![PyPI version](https://img.shields.io/pypi/v/hatch-ci.svg?color=blue)](https://pypi.org/project/hatch-ci)\n[![Python versions](https://img.shields.io/pypi/pyversions/hatch-ci.svg)](https://pypi.org/project/hatch-ci)\n[![License - MIT](https://img.shields.io/badge/license-MIT-9400d3.svg)](https://spdx.org/licenses/)\n\n[![Build](https://github.com/cav71/hatch-ci/actions/workflows/master.yml/badge.svg)](https://github.com/cav71/hatch-ci/actions/runs/0)\n[![codecov](https://codecov.io/gh/cav71/hatch-ci/branch/master/graph/badge.svg?token=521FB9K5KT)](https://codecov.io/gh/cav71/hatch-ci/branch/master)\n\n[![Black](https://img.shields.io/badge/code%20style-black-000000.svg)](Black)\n[![Mypy](https://img.shields.io/badge/types-Mypy-blue.svg)](https://mypy-lang.org/)\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n\n\n## Introduction\nThis is a [hatch-vcs](https://github.com/ofek/hatch-vcs) heavily inspired plugin: it captures values from\nthe build environment (eg. github, pyproject.toml etc.) and it uses these \nto process files during the build/packaging process. \n\nIn a typical project (let's call it foobar):\n\n```\n\u2514\u2500\u2500 foobar-project\n \u251c\u2500\u2500 pyproject.toml\n \u2514\u2500\u2500 src\n \u2514\u2500\u2500 foobar\n \u2514\u2500\u2500 __init__.py <- __version__ and __hash__ are update during build\n```\n\nWith the pyproject.toml set like:\n\n```text\n[build-system]\nrequires = [\"hatchling\", \"hatch-ci\"]\nbuild-backend = \"hatchling.build\"\n\n[project]\ndynamic = [\"version\"]\n\n# the version-file needs to be repeated twice here\n[tool.hatch.version]\nversion-file = \"src/package/__init__.py\"\n\n[tool.hatch.build.hooks.ci]\nversion-file = \"src/{name}/__init__.py\"\n\n# performs these string replacements\nprocess-replace = [\n [\"re:(replace-me)\", \"[\\\\\\\\1]\"],\n [\"string-to-replace\", \"replacement-string\"]\n]\n\n# before jinja process these\nprocess-paths = [\n \"src/project/template.jinja2\"\n]\n```\n\nBuilding the sdist/wheel package will have the `__version__` and `__hash__` set \ndepending on the branch and current commit.\n\n### wheel version\nDuring the wheel build the version is dynamically updated with information taken from\nthe `version-file` field (see \"[Version source options](#version-source-options)\").\n\nTwo variables will be overwritten/modified in `version-file`: the **__version__** \ncontaining the semgrep version and **__hash__** with the git commit for the build.\n\nThe version information is augmented with:\n- a **bNNN** build number in creating the package foobar-1.0.0bNNNN (this can be sent to [PyPi](https://pypi.org))\n- if there's a tag v1.0.0 on the repo, it will build foobar-1.0.0 release (this can be sent to [PyPi](https://pypi.org))\n\nThe last two steps are mean to be managed in a CI/CD system (github at the moment), to ensure *hands-off* releases.\n\nIn essence this pluging:\n- manages the version information\n- allows version replacement in text files using build information\n\n\n\n**Table of Contents**\n\n- [Global dependency](#global-dependency)\n- [Version source](#version-source)\n - [Version source options](#version-source-options)\n- [License](#license)\n\n## Global dependency\n\nEnsure `hatch-ci` is defined within the `build-system.requires` field in your `pyproject.toml` file.\n\n```toml\n[build-system]\nrequires = [\"hatchling\", \"hatch-ci\"]\nbuild-backend = \"hatchling.build\"\n```\n\n## Version source\n\nThe [version source plugin](https://hatch.pypa.io/latest/plugins/version-source/reference/) name is `ci`.\n\nThis will enable the hatch-ci pluging:\n\n- ***pyproject.toml***\n\n ```toml\n [project]\n ..\n dynamic = [\"version\"] # this rerieves the version dynamically\n ..\n\n ```\n\n### Version source options\n\n- ***pyproject.toml***\n\n ```toml\n [tool.hatch.version]\n source = \"ci\" # this pulls the version using the hatch-ci hook\n\n # this will put/update __version__ and __hash__ info in version-file\n version-file = \"src/hatch_ci/__init__.py\"\n\n # these files will be jinja2 processed, the environment will\n # contains variables as: branch, build, current, ref, runid, \n # sha, version, workflow etc.\n paths = [ \"README.md\" ]\n \n # the listed paths will undergo replacement before jinja2 processing and\n # the variables 'a' & 'b' listed below wil be replaced with ctx attributes.\n fixers = [\n { 'a': '{ctx.workflows}' },\n { 'd': '{ctx.branch}' }\n ]\n ```\n The complete list of attributes is available here [TEMPLATE.md](TEMPLATE.md).\n\n| Option | Type | Default | Description |\n| --- | --- |---------|------------------------------------------------------|\n| `version-file` | `str` | None | A file where to write __version__/__hash__ variables |\n| `paths` | `list[str]|str` | None | A list of paths to process |\n| `fixers` | `list[dict[str,str]]` | None | A list of dict, each key is a string to replace with the value |\n\n\n## License\n\n`hatch-ci` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.",
"bugtrack_url": null,
"license": "MIT",
"summary": "Hatch plugin for ci system versioning",
"version": "0.1.3",
"project_urls": {
"Issues": "https://github.com/cav71/hatch-ci/issues",
"Source": "https://github.com/cav71/hatch-ci"
},
"split_keywords": [
"git",
"hatch",
"plugin",
"scm",
"version"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "45fc6b76aba87527968be169f878f83fa7dc29d8dbd64c098ddf413c9ba6c49a",
"md5": "72b234ad608af1c0001ccf970c928eea",
"sha256": "840f036ca1e9687f86ec05cc9baa06ddf8ea4956c96a16f699e6a7ea7ff490a3"
},
"downloads": -1,
"filename": "hatch_ci-0.1.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "72b234ad608af1c0001ccf970c928eea",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 22273,
"upload_time": "2024-03-17T02:00:59",
"upload_time_iso_8601": "2024-03-17T02:00:59.204990Z",
"url": "https://files.pythonhosted.org/packages/45/fc/6b76aba87527968be169f878f83fa7dc29d8dbd64c098ddf413c9ba6c49a/hatch_ci-0.1.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d7cba7498f6d3789c734313d4b62169ce5a86d199cc0bfefeb7678a5424f6f75",
"md5": "d9f8b078a0974391620b173972523abd",
"sha256": "317e875304ae13f12a44e9cf450f3efc3cdfc2111bf2f7b0279b7e73d267d25e"
},
"downloads": -1,
"filename": "hatch_ci-0.1.3.tar.gz",
"has_sig": false,
"md5_digest": "d9f8b078a0974391620b173972523abd",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 54119,
"upload_time": "2024-03-17T02:01:01",
"upload_time_iso_8601": "2024-03-17T02:01:01.076859Z",
"url": "https://files.pythonhosted.org/packages/d7/cb/a7498f6d3789c734313d4b62169ce5a86d199cc0bfefeb7678a5424f6f75/hatch_ci-0.1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-17 02:01:01",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "cav71",
"github_project": "hatch-ci",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "hatch-ci"
}