]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
Version updater and uv build support (off by default).
authorBob Halley <halley@dnspython.org>
Fri, 10 Oct 2025 16:27:26 +0000 (09:27 -0700)
committerBob Halley <halley@dnspython.org>
Fri, 10 Oct 2025 16:37:31 +0000 (09:37 -0700)
pyproject.toml
util/update-version [new file with mode: 0755]

index b08eacdbef41cec4aa7485065400e0efd6cd6fb3..1a9d35623662a2edf5411b09cea9396674d24802 100644 (file)
@@ -1,6 +1,9 @@
 [build-system]
 requires = ["hatchling>=1.21.0"]
 build-backend = "hatchling.build"
+# You can also use "uv" instead
+#requires = ["uv_build>=0.9.1,<0.10.0"]
+#build-backend = "uv_build"
 
 [project]
 name = "dnspython"
@@ -26,7 +29,7 @@ classifiers = [
 readme = "README.md"
 requires-python = ">=3.10"
 dependencies = []
-dynamic = ["version"]
+version = "2.9.0dev0"
 
 [project.optional-dependencies]
 dev = [
@@ -84,12 +87,32 @@ include = ["dns/*.py", "dns/**/*.py", "dns/py.typed"]
 
 [tool.hatch.envs.default]
 features = ["trio", "dnssec", "idna", "doh", "doq", "dev"]
-#installer = "uv"
 
-[tool.hatch.version]
-source = "code"
-path = "dns/version.py"
-expression = "version"
+[tool.uv.build-backend]
+module-name = "dns"
+module-root = ""
+source-include = [
+    "/dns/*.py",
+    "/dns/**/*.py",
+    "/dns/py.typed",
+    "/examples/*.txt",
+    "/examples/*.py",
+    "/tests/*.txt",
+    "/tests/*.py",
+    "/tests/*.good",
+    "/tests/example",
+    "/tests/query",
+    "/tests/*.pickle",
+    "/tests/*.text",
+    "/tests/*.generic",
+    "/tests/tls/*.crt",
+    "/tests/tls/*.pem",
+    "/util/**",
+]
+source-exclude = [
+    ".pytest_cache",
+    ".DS_Store",
+]
 
 [tool.ruff]
 lint.select = [
diff --git a/util/update-version b/util/update-version
new file mode 100755 (executable)
index 0000000..a534766
--- /dev/null
@@ -0,0 +1,52 @@
+#!/usr/bin/env python3
+
+import os
+
+from dns.version import MAJOR, MICRO, MINOR, RELEASELEVEL, version
+
+
+def update(pathname, edit):
+    new_pathname = pathname + ".new"
+    with open(pathname, "rt") as old:
+        with open(new_pathname, "wt") as new:
+            for l in old.readlines():
+                l = l.rstrip()
+                nl = edit(l)
+                print(nl, file=new)
+    os.rename(new_pathname, pathname)
+
+
+def edit_project(line):
+    if line.startswith("version = "):
+        return f'version = "{version}"'
+    else:
+        return line
+
+
+def edit_readme(line):
+    if line.startswith(
+        "This is the development version of `dnspython` "
+    ) or line.startswith("This is `dnspython` "):
+        if RELEASELEVEL == 0:
+            extra = "the development version of "
+            readme_version = f"{MAJOR}.{MINOR}.{MICRO}"
+        else:
+            extra = ""
+            readme_version = version
+        return f"This is {extra}`dnspython` {readme_version}."
+    else:
+        return line
+
+
+def edit_sphinx_conf(line):
+    if line.startswith("version = "):
+        return f'version = "{MAJOR}.{MINOR}"'
+    elif line.startswith("release = "):
+        return f'release = "{MAJOR}.{MINOR}.{MICRO}"'
+    else:
+        return line
+
+
+update("pyproject.toml", edit_project)
+update("README.md", edit_readme)
+update("doc/conf.py", edit_sphinx_conf)