Update Versioning authored by Klaas Kliffen's avatar Klaas Kliffen
...@@ -23,7 +23,7 @@ Use a git tag `1.2.3` to set a version. For development build, it will add a uni ...@@ -23,7 +23,7 @@ Use a git tag `1.2.3` to set a version. For development build, it will add a uni
**IMPORTANT**, for correct version handling, make sure to tag your versions regularly. Our gitlab runners only check-out the last 50 commits (excluding merge commits). So if the distance is more than 50, your development versions will be inconsistent! **IMPORTANT**, for correct version handling, make sure to tag your versions regularly. Our gitlab runners only check-out the last 50 commits (excluding merge commits). So if the distance is more than 50, your development versions will be inconsistent!
Check out the following package for a concrete example in use: Check out the following package for a concrete example in use:
[ASTRONauth](https://git.astron.nl/astron-sdc/astronauth) [ASTRONauth](https://git.astron.nl/astron-sdc/astronauth):
```toml ```toml
# pyproject.toml # pyproject.toml
...@@ -46,5 +46,20 @@ ignore = "_version.py" ...@@ -46,5 +46,20 @@ ignore = "_version.py"
# also add it to your .gitignore! # also add it to your .gitignore!
``` ```
```python
# astronauth/__init__.py
try:
from importlib import metadata
except ImportError: # for Python<3.8
import importlib_metadata as metadata
try:
__version__ = metadata.version("astronauth")
except metadata.PackageNotFoundError:
# In case not installed (during development)
__version__ = "Unknown"
```
## License ## License
The [Semantic Versioning specification](https://semver.org/) was originally authored by Tom Preston-Werner and is licensed under [Creative Commons -- CC BY 3.0](https://creativecommons.org/licenses/by/3.0/) The [Semantic Versioning specification](https://semver.org/) was originally authored by Tom Preston-Werner and is licensed under [Creative Commons -- CC BY 3.0](https://creativecommons.org/licenses/by/3.0/)
\ No newline at end of file