diff --git a/RELEASE.md b/RELEASE.md index b975e4bd8c..7b378ea0c4 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -14,7 +14,7 @@ To create a manual release, perform the following steps: ### Set up ```bash -pip install tbump twine build +pip install hatchling twine build git pull origin $(git branch --show-current) git clean -dffx npm install @@ -26,7 +26,8 @@ npm run build ```bash echo "Enter new version" read script_version -tbump ${script_version} +hachling version ${script_version} +git tag -a ${script_version} -m "Release ${script_version}" ``` ### Build the artifacts @@ -41,7 +42,7 @@ python -m build . ```bash echo "Enter dev version" read dev_version -tbump ${dev_version} --no-tag +hatchling ${dev_version} git push origin $(git branch --show-current) ``` diff --git a/docs/source/conf.py b/docs/source/conf.py index 9090379600..32951458f4 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -15,6 +15,7 @@ import os.path as osp import shutil import sys +from importlib.metadata import version from packaging.version import parse as parse_version @@ -108,10 +109,10 @@ # |version| and |release|, also used in various other places throughout the # built documents. # -__version__ = "2.1.0.dev0" +__version__ = version("jupyter_server") # The short X.Y version. version_parsed = parse_version(__version__) -version = f"{version_parsed.major}.{version_parsed.minor}" +version = f"{version_parsed.major}.{version_parsed.minor}" # type:ignore[assignment] # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/jupyter_server/_version.py b/jupyter_server/_version.py index 803eab636a..65873b42a7 100644 --- a/jupyter_server/_version.py +++ b/jupyter_server/_version.py @@ -2,5 +2,17 @@ store the current version info of the server. """ -version_info = (2, 1, 0, ".dev", "0") -__version__ = ".".join(map(str, version_info[:3])) + "".join(version_info[3:]) +import re +from typing import List + +# Version string must appear intact for tbump versioning +__version__ = "2.1.0.dev0" + +# Build up version_info tuple for backwards compatibility +pattern = r"(?P\d+).(?P\d+).(?P\d+)(?P.*)" +match = re.match(pattern, __version__) +assert match is not None +parts: List[object] = [int(match[part]) for part in ["major", "minor", "patch"]] +if match["rest"]: + parts.append(match["rest"]) +version_info = tuple(parts) diff --git a/pyproject.toml b/pyproject.toml index a5d6ad5289..3a0ea9e21d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "jupyter_server" -version = "2.1.0.dev0" +dynamic = ["version"] readme = "README.md" license = { file = "COPYING.md" } description = "The backend—i.e. core services, APIs, and REST endpoints—to Jupyter web applications." @@ -72,6 +72,9 @@ dev = [ [project.scripts] jupyter-server = "jupyter_server.serverapp:main" +[tool.hatch.version] +path = "jupyter_server/_version.py" + [tool.hatch.build] artifacts = ["jupyter_server/static/style"] @@ -119,36 +122,6 @@ before-build-python = ["npm install", "npm run build"] post-version-spec = "dev" pydist_resource_paths = ["jupyter_server/static/style/bootstrap.min.css", "jupyter_server/static/style/bootstrap-theme.min.css"] -[tool.tbump.version] -current = "2.1.0.dev0" -regex = ''' - (?P\d+)\.(?P\d+)\.(?P\d+) - ((?Pa|b|rc|.dev)(?P\d+))? -''' - -[tool.tbump.git] -message_template = "Bump to {new_version}" -tag_template = "v{new_version}" - -[[tool.tbump.file]] -src = "jupyter_server/_version.py" -version_template = '({major}, {minor}, {patch}, "{channel}", "{release}")' - -[[tool.tbump.file]] -src = "pyproject.toml" -version_template = "version = \"{major}.{minor}.{patch}{channel}{release}\"" - -[[tool.tbump.file]] -src = "docs/source/conf.py" -version_template = "{major}.{minor}.{patch}{channel}{release}" - -[[tool.tbump.field]] -name = "channel" -default = "" - -[[tool.tbump.field]] -name = "release" -default = "" [tool.mypy] check_untyped_defs = true