|
1 | 1 | # SPDX-License-Identifier: MIT
|
2 | 2 |
|
3 | 3 | [build-system]
|
4 |
| -requires = ["hatchling"] |
| 4 | +requires = ["hatchling", "versioningit>=3.3.0"] |
5 | 5 | build-backend = "hatchling.build"
|
6 | 6 |
|
7 | 7 | [project]
|
@@ -74,6 +74,7 @@ tools = [
|
74 | 74 | "python-dotenv~=1.0.0",
|
75 | 75 | "check-manifest==0.49",
|
76 | 76 | "ruff==0.9.3",
|
| 77 | + "versioningit>=3.3.0", |
77 | 78 | ]
|
78 | 79 | changelog = [
|
79 | 80 | "towncrier==23.6.0",
|
@@ -131,10 +132,47 @@ test = { cmd = "test", help = "Run pytest" }
|
131 | 132 | include = [
|
132 | 133 | "disnake/",
|
133 | 134 | ]
|
| 135 | +artifacts = ["disnake/_version.py"] |
134 | 136 |
|
135 | 137 | [tool.hatch.version]
|
136 |
| -path = "disnake/__init__.py" |
137 |
| -pattern = '__version__ = "(?P<version>.+)"' |
| 138 | +source = "versioningit" |
| 139 | + |
| 140 | +[tool.versioningit.vcs] |
| 141 | +method = "git-archive" |
| 142 | +describe-subst = "$Format:%(describe:tags,match=v*)$" |
| 143 | + |
| 144 | +[tool.versioningit.format] |
| 145 | +distance = "{base_version}+{distance}.{vcs}{rev}" |
| 146 | +dirty = "{base_version}+d{build_date:%Y%m%d}" |
| 147 | +distance-dirty = "{base_version}.a{distance}+{vcs}{rev}.d{build_date:%Y%m%d}" |
| 148 | + |
| 149 | +[tool.versioningit.template-fields.version-tuple] |
| 150 | +split-on = '^(\d+)\.(\d+)\.(\d+)\.([a-zA-Z])(\d+)(?:.\d+)?' |
| 151 | + |
| 152 | + |
| 153 | +[tool.versioningit.write] |
| 154 | +file = "disnake/_version.py" |
| 155 | +template = """ |
| 156 | +# SPDX-License-Identifier: MIT |
| 157 | +
|
| 158 | +from typing import Literal, NamedTuple |
| 159 | +
|
| 160 | +__version__ = "{version}" |
| 161 | +
|
| 162 | +
|
| 163 | +class VersionInfo(NamedTuple): |
| 164 | + major: int |
| 165 | + minor: int |
| 166 | + micro: int |
| 167 | + releaselevel: Literal["alpha", "beta", "candidate", "final"] |
| 168 | + serial: int |
| 169 | +
|
| 170 | +
|
| 171 | +# fmt: off |
| 172 | +version_info: VersionInfo = VersionInfo(*{version_tuple}[:5]) |
| 173 | +# fmt: on |
| 174 | +
|
| 175 | +""" |
138 | 176 |
|
139 | 177 | [tool.ruff]
|
140 | 178 | line-length = 100
|
|
0 commit comments