Skip to content

Commit

Permalink
Switch to using hatchling version command (#984)
Browse files Browse the repository at this point in the history
* switch to using hatchling version

* revert changes to package-lock
  • Loading branch information
blink1073 authored Sep 15, 2022
1 parent a99119e commit 895a380
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 38 deletions.
7 changes: 4 additions & 3 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)
```

Expand Down
5 changes: 3 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand Down
16 changes: 14 additions & 2 deletions jupyter_server/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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<major>\d+).(?P<minor>\d+).(?P<patch>\d+)(?P<rest>.*)"
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)
35 changes: 4 additions & 31 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down Expand Up @@ -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"]

Expand Down Expand Up @@ -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<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)
((?P<channel>a|b|rc|.dev)(?P<release>\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
Expand Down

0 comments on commit 895a380

Please sign in to comment.