Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 37c6c04

Browse files
authored
Merge pull request #204 from akrherz/gh201_project_version
fix: Make project version dynamic
2 parents de36264 + f4ac72b commit 37c6c04

5 files changed

Lines changed: 21 additions & 5 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
runs-on: ubuntu-latest
3838
strategy:
3939
matrix:
40-
# 3.14 not ready for mymy
40+
# 3.14 not ready for mypy
4141
python-version: ["3.13"]
4242
steps:
4343
- uses: actions/checkout@v6

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ htmlcov/
77
/build/
88
/dist/
99
/metar.egg-info/
10+
/metar/_version.py

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Over the years, this package has gone by the name `metar` and `python-metar`. We
77
settling on `metar` going forward, which matches the most recent pypi and conda-forge
88
coordinates.
99

10+
- [#201](https://github.com/python-metar/python-metar/pull/201) Use SCM to define project version
11+
1012
metar-2.0.0 (18 March 2026)
1113

1214
This release rolls up fixes and updates made by the community. The version number

metar/__init__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,16 @@
2828

2929
__email__ = "[email protected]"
3030

31-
__version__ = "2.0.0"
31+
__version__ = "0.0.0" # Default
32+
try:
33+
# Exists after installation via scm write_to
34+
from ._version import version as __version__
35+
except ImportError:
36+
from importlib.metadata import version, PackageNotFoundError
37+
try:
38+
__version__ = version("metar")
39+
except PackageNotFoundError:
40+
pass
3241

3342
__doc__ = """metar v%s (c) 2009, %s
3443

pyproject.toml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[project]
22
name = "metar"
3-
version = "2.0.0"
43
description = "Metar - a package to parse METAR-coded weather reports"
54

65
authors = [
76
{"name"="Tom Pollard", email="[email protected]"}
87
]
98
license = {file = "LICENSE"}
9+
dynamic = ["version"]
1010

1111
requires-python = ">= 3.10"
1212
readme = "README.md"
@@ -27,11 +27,15 @@ packages = ["metar"]
2727
[tool.setuptools.package-data]
2828
metar = ["nsd_cccc.txt", "py.typed", "*.pyi"]
2929

30+
[tool.setuptools_scm]
31+
version_scheme = "post-release"
32+
write_to = "metar/_version.py"
33+
3034
[project.urls]
3135
Repository = "https://github.com/python-metar/python-metar/"
3236

3337
[build-system]
34-
requires = ["setuptools >= 61.0"]
38+
requires = ["setuptools>=64", "setuptools_scm>=8"]
3539
build-backend = "setuptools.build_meta"
3640

3741
[project.optional-dependencies]
@@ -44,5 +48,5 @@ codecov = [
4448
"codecov",
4549
]
4650
typing = [
47-
"mypy==1.3.0"
51+
"mypy==1.3.0",
4852
]

0 commit comments

Comments
 (0)