From 624657a703bb03718d60c9b93707b5a235ffca81 Mon Sep 17 00:00:00 2001 From: Bob Halley Date: Fri, 10 Oct 2025 09:27:26 -0700 Subject: [PATCH] Version updater and uv build support (off by default). --- pyproject.toml | 35 ++++++++++++++++++++++++------ util/update-version | 52 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 6 deletions(-) create mode 100755 util/update-version diff --git a/pyproject.toml b/pyproject.toml index b08eacdb..1a9d3562 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 index 00000000..a534766d --- /dev/null +++ b/util/update-version @@ -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) -- 2.47.3