Skip to content

Commit c64ed37

Browse files
committed
Let poetry automatically pull version from tags
Rather than spending time updating the 2 files that have hardcoded versions in them. Let poetry auto-generate the versions directly from Git tags. If a dev has a git tag checked out then `poetry build` will generate a version directly from that tag, for example the tag "v0.15.1" will produce a version "0.15.1". Otherwise the version will be based on how many commits since the last tag was available in Git history for example "0.15.1-post.13+d211ed4347" where "post.13" represents 13 commits since v0.15.1 was tagged and "d211ed4347" is the commit hash of the commit that generated this version. For this to work however devs are required to install poetry-dynamic-versioning in addition to poetry at the global level. Ref: https://pypi.org/project/poetry-dynamic-versioning/ Signed-off-by: Thanh Ha <zxiiro@gmail.com>
1 parent e7e4962 commit c64ed37

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

docs/developer/devstart.md

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Setting up the development environment for Suzieq involves the following steps:
77
* Make sure you have a python3 version that is > 3.7.1 and less than 3.9.0. If you don't have a system provided python version that matches this requirement, you can use [pyenv](https://realpython.com/intro-to-pyenv/) to install one.
88
* If you've used pyenv to install a specific python version, ensure you activate it.
99
* Install poetry--follow the instructions posted [here](https://python-poetry.org/docs/#installation).
10+
* Install *poetry-dynamic-versioning* -- follow the instructions posted
11+
[here](https://pypi.org/project/poetry-dynamic-versioning/)
1012
* Ensure you have git installed (follow the instructions [here](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git))
1113
* Clone the github repository: ```git clone https://github.com/netenglabs/suzieq.git```. This creates a copy of the code repository in the subfolder suzieq in the current directory.
1214
* Create the virtual environment and install the appropriate packages by typing: ```poetry install```

pyproject.toml

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "suzieq"
3-
version = "0.16.0"
3+
version = "0.0.0"
44
description = "A framework and application for network observability"
55
readme = 'README.md'
66
repository = 'https://github.com/netenglabs/suzieq'
@@ -14,7 +14,6 @@ classifiers = [
1414
'Topic :: System :: Networking :: Monitoring'
1515
]
1616

17-
1817
[tool.poetry.dependencies]
1918
python = ">3.7.1, < 3.9"
2019
aiohttp = "==3.7.4"
@@ -74,6 +73,12 @@ sq-anonymizer = 'suzieq.utilities.sq_anonymizer:anonymizer_main'
7473
suzieq-cli = 'suzieq.cli.sq_cli:cli_main'
7574
suzieq-gui = 'suzieq.gui.sq_gui:gui_main'
7675

76+
[tool.poetry-dynamic-versioning]
77+
enable = true
78+
vcs = "git"
79+
style = "semver"
80+
pattern = "^v(?P<base>\\d+\\.\\d+\\.\\d+)(-?((?P<stage>[a-zA-Z]+)\\.?(?P<revision>\\d+)?))?(\\+(?P<tagged_metadata>.+))?$"
81+
7782
[build-system]
78-
requires = ["poetry>=0.12"]
83+
requires = ["poetry>=1.0.2", "poetry-dynamic-versioning"]
7984
build-backend = "poetry.masonry.api"

suzieq/version.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#!/usr/bin/env python
22

33

4-
SUZIEQ_VERSION = "0.16.0"
4+
__version__ = "0.0.0"
5+
SUZIEQ_VERSION = __version__
56

67
if __name__ == '__main__':
78
print(SUZIEQ_VERSION)

0 commit comments

Comments
 (0)