Skip to content

Commit c900c4d

Browse files
Use UV, publish from CI
1 parent 960b15f commit c900c4d

14 files changed

Lines changed: 2337 additions & 135 deletions

File tree

‎.flake8‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[flake8]
2+
max-line-length = 120

‎.github/workflows/changelog.yaml‎

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
1-
# This workflow will run on every pull request to the develop branch to do the following:
2-
#
3-
# - Insert the Pull Request URL into new changelog entries.
4-
# - Assert that a new changelog entry has been added in the PR unless a "no changelog" label is added to the PR.
1+
# This workflow will run on every pull request to the develop branch to assert
2+
# that a new changelog entry has been added unless a "no changelog" label is present.
53

64
name: "Changelog"
75

86
on:
97
pull_request_target: { branches: [ "develop" ] }
108

119
jobs:
12-
# changelog-update:
13-
# name: "Insert Pull Request URL into new changelog entries"
14-
# runs-on: ubuntu-latest
15-
# if: github.event_name == 'pull_request_target'
16-
# steps:
17-
# - uses: actions/checkout@v2
18-
# - uses: NiklasRosenstein/slap@gha/changelog/update/v2
19-
# with: { pr-id: '${{ github.event.pull_request.number }}' }
20-
2110
assert-new-changelog-entries:
2211
name: "At least one new changelog entry must be added"
2312
runs-on: ubuntu-latest
2413
if: github.base_ref != '' && !contains(github.event.pull_request.labels.*.name, 'no changelog')
2514
steps:
26-
- uses: actions/checkout@v2
27-
- uses: NiklasRosenstein/slap@gha/changelog/assert-added/v2
28-
with: { pr-id: '${{ github.event.pull_request.number }}' }
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
ref: ${{ github.event.pull_request.head.sha }}
19+
- name: Check for changelog changes
20+
run: |
21+
if git diff --name-only origin/${{ github.base_ref }}...HEAD | grep -q '^\.changelog/_unreleased\.toml$'; then
22+
echo "Changelog entry found."
23+
else
24+
echo "::error::No changelog entry found. Please add entries to .changelog/_unreleased.toml or add the 'no changelog' label."
25+
exit 1
26+
fi

‎.github/workflows/python.yaml‎

Lines changed: 95 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,111 @@ jobs:
1313
continue-on-error: ${{ matrix.python-version == '3.15' }}
1414
steps:
1515
- uses: actions/checkout@v4
16-
- uses: NiklasRosenstein/slap@gha/install/v1
16+
- uses: astral-sh/setup-uv@v5
1717
- uses: actions/setup-python@v5
1818
with:
1919
python-version: "${{ matrix.python-version }}"
2020
allow-prereleases: true
21-
- run: slap install --link --no-venv-check
22-
- run: slap test
23-
- run: slap publish --dry
21+
- run: uv sync --group dev
22+
- run: uv run pytest databind/src/ -vv
23+
- run: uv run black --check --config pyproject.toml databind/src/
24+
- run: uv run isort --check-only databind/src/
25+
- run: uv run flake8 databind/src/
26+
- if: matrix.python-version == '3.12'
27+
run: uv run mypy
28+
- run: uv build --package databind && uv build --package databind.core && uv build --package databind.json
2429

2530
documentation:
2631
runs-on: ubuntu-latest
2732
steps:
2833
- uses: actions/checkout@v4
29-
- uses: NiklasRosenstein/slap@gha/install/v1
34+
- uses: astral-sh/setup-uv@v5
3035
- uses: actions/setup-python@v5
31-
with: { python-version: "3.10" }
32-
- run: slap --version && slap install --only-extras docs --no-venv-check
33-
- run: slap run --no-venv-check docs:build
36+
with: { python-version: "3.12" }
37+
- run: uv sync --group docs
38+
- run: cd docs && uv run mkdocs build --site-dir _site
3439
- uses: JamesIves/github-pages-deploy-action@4.1.4
3540
with: { branch: gh-pages, folder: docs/_site, ssh-key: "${{ secrets.DEPLOY_KEY }}" }
3641
if: github.ref == 'refs/heads/develop'
42+
43+
build:
44+
if: startsWith(github.ref, 'refs/tags/')
45+
needs: test
46+
runs-on: ubuntu-latest
47+
strategy:
48+
matrix:
49+
package:
50+
- { name: "databind", artifact: "dist-databind" }
51+
- { name: "databind.core", artifact: "dist-databind-core" }
52+
- { name: "databind.json", artifact: "dist-databind-json" }
53+
steps:
54+
- uses: actions/checkout@v4
55+
- uses: astral-sh/setup-uv@v5
56+
- uses: actions/setup-python@v5
57+
with: { python-version: "3.12" }
58+
- run: uv build --package ${{ matrix.package.name }}
59+
- uses: actions/upload-artifact@v4
60+
with:
61+
name: ${{ matrix.package.artifact }}
62+
path: dist/
63+
64+
publish:
65+
needs: build
66+
runs-on: ubuntu-latest
67+
environment: pypi
68+
permissions:
69+
id-token: write
70+
steps:
71+
- uses: actions/download-artifact@v4
72+
with: { name: dist-databind, path: dist/databind }
73+
- uses: actions/download-artifact@v4
74+
with: { name: dist-databind-core, path: dist/databind-core }
75+
- uses: actions/download-artifact@v4
76+
with: { name: dist-databind-json, path: dist/databind-json }
77+
- uses: pypa/gh-action-pypi-publish@release/v1
78+
with: { packages-dir: dist/databind }
79+
- uses: pypa/gh-action-pypi-publish@release/v1
80+
with: { packages-dir: dist/databind-core }
81+
- uses: pypa/gh-action-pypi-publish@release/v1
82+
with: { packages-dir: dist/databind-json }
83+
84+
github-release:
85+
needs: publish
86+
runs-on: ubuntu-latest
87+
permissions:
88+
contents: write
89+
steps:
90+
- uses: actions/checkout@v4
91+
- name: Generate release notes
92+
id: notes
93+
run: |
94+
VERSION="${GITHUB_REF#refs/tags/}"
95+
CHANGELOG=".changelog/${VERSION}.toml"
96+
if [ ! -f "$CHANGELOG" ]; then
97+
echo "body=Release ${VERSION}" >> "$GITHUB_OUTPUT"
98+
else
99+
BODY=$(python3 -c "
100+
import tomllib, pathlib, sys
101+
data = tomllib.loads(pathlib.Path(sys.argv[1]).read_text())
102+
lines = []
103+
for e in data.get('entries', []):
104+
t = e.get('type', 'change')
105+
d = e.get('description', '')
106+
pr = e.get('pr', '')
107+
suffix = f' ({pr})' if pr else ''
108+
lines.append(f'- **{t}**: {d}{suffix}')
109+
print('\n'.join(lines) if lines else 'No changelog entries.')
110+
" "$CHANGELOG")
111+
{
112+
echo "body<<GHEOF"
113+
echo "$BODY"
114+
echo "GHEOF"
115+
} >> "$GITHUB_OUTPUT"
116+
fi
117+
- name: Create GitHub Release
118+
env:
119+
GH_TOKEN: ${{ github.token }}
120+
run: |
121+
gh release create "${{ github.ref_name }}" \
122+
--title "${{ github.ref_name }}" \
123+
--notes "${{ steps.notes.outputs.body }}"

‎databind.core/pyproject.toml‎

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
1-
[tool.poetry]
1+
[build-system]
2+
requires = ["uv_build>=0.11.1,<0.12"]
3+
build-backend = "uv_build"
4+
5+
[project]
26
name = "databind.core"
37
version = "4.5.2"
48
description = "Databind is a library inspired by jackson-databind to de-/serialize Python dataclasses. Compatible with Python 3.8 and newer. Deprecated, use `databind` package."
5-
authors = ["Niklas Rosenstein <rosensteinniklas@gmail.com>"]
9+
authors = [{name = "Niklas Rosenstein", email = "rosensteinniklas@gmail.com"}]
610
license = "MIT"
711
readme = "README.md"
8-
packages = [{include = "_databind_core_proxy", from = "src"}]
12+
requires-python = ">=3.8"
13+
dependencies = [
14+
"databind>=4.5.2,<5",
15+
]
916

10-
[tool.poetry.urls]
17+
[project.urls]
1118
"Bug Tracker" = "https://github.com/NiklasRosenstein/python-databind/issues"
1219
Documentation = "https://niklasrosenstein.github.io/python-databind/"
1320
Repository = "https://github.com/NiklasRosenstein/python-databind"
1421

15-
[tool.poetry.dependencies]
16-
python = "^3.8.0"
17-
databind = "^4.5.2"
18-
19-
[build-system]
20-
requires = ["poetry-core==1.0.8"] # Don't ugprade, see https://github.com/NiklasRosenstein/python-databind/issues/64
21-
build-backend = "poetry.core.masonry.api"
22+
[tool.uv.sources]
23+
databind = { workspace = true }
2224

23-
[tool.slap]
24-
typed = true
25+
[tool.uv.build-backend]
26+
module-name = "_databind_core_proxy"

‎databind.json/pyproject.toml‎

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
1-
[tool.poetry]
1+
[build-system]
2+
requires = ["uv_build>=0.11.1,<0.12"]
3+
build-backend = "uv_build"
4+
5+
[project]
26
name = "databind.json"
37
version = "4.5.2"
48
description = "De-/serialize Python dataclasses to or from JSON payloads. Compatible with Python 3.8 and newer. Deprecated, use `databind` module instead."
5-
authors = ["Niklas Rosenstein <rosensteinniklas@gmail.com>"]
9+
authors = [{name = "Niklas Rosenstein", email = "rosensteinniklas@gmail.com"}]
610
license = "MIT"
711
readme = "README.md"
8-
packages = [{include = "_databind_json_proxy", from = "src"}]
12+
requires-python = ">=3.8"
13+
dependencies = [
14+
"databind>=4.5.2,<5",
15+
]
916

10-
[tool.poetry.urls]
17+
[project.urls]
1118
"Bug Tracker" = "https://github.com/NiklasRosenstein/python-databind/issues"
1219
Documentation = "https://niklasrosenstein.github.io/python-databind/"
1320
Repository = "https://github.com/NiklasRosenstein/python-databind"
1421

15-
[tool.poetry.dependencies]
16-
python = "^3.8.0"
17-
databind = "^4.5.2"
18-
19-
[build-system]
20-
requires = ["poetry-core==1.0.8"] # Don't ugprade, see https://github.com/NiklasRosenstein/python-databind/issues/64
21-
build-backend = "poetry.core.masonry.api"
22+
[tool.uv.sources]
23+
databind = { workspace = true }
2224

23-
[tool.slap]
24-
typed = true
25+
[tool.uv.build-backend]
26+
module-name = "_databind_json_proxy"

‎databind/pyproject.toml‎

Lines changed: 19 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,28 @@
1-
[tool.poetry]
1+
[build-system]
2+
requires = ["uv_build>=0.11.1,<0.12"]
3+
build-backend = "uv_build"
4+
5+
[project]
26
name = "databind"
37
version = "4.5.2"
48
description = "Databind is a library inspired by jackson-databind to de-/serialize Python dataclasses. The `databind` package will install the full suite of databind packages. Compatible with Python 3.8 and newer."
5-
authors = ["Niklas Rosenstein <rosensteinniklas@gmail.com>"]
9+
authors = [{name = "Niklas Rosenstein", email = "rosensteinniklas@gmail.com"}]
610
license = "MIT"
711
readme = "README.md"
8-
packages = [{include = "databind/core", from = "src"}, {include = "databind/json", from = "src"}]
9-
10-
[tool.poetry.urls]
12+
requires-python = ">=3.8"
13+
dependencies = [
14+
"Deprecated>=1.2.12,<2",
15+
"nr-date>=2.0.0,<3",
16+
"nr-stream>=1.0.0,<2",
17+
"setuptools>=40.8.0,<82; python_version < '3.9'",
18+
"typeapi>=2.0.1,<3",
19+
"typing-extensions>=3.10.0,<5",
20+
]
21+
22+
[project.urls]
1123
"Bug Tracker" = "https://github.com/NiklasRosenstein/python-databind/issues"
1224
Documentation = "https://niklasrosenstein.github.io/python-databind/"
1325
Repository = "https://github.com/NiklasRosenstein/python-databind"
1426

15-
[tool.poetry.dependencies]
16-
python = "^3.8.0"
17-
Deprecated = "^1.2.12"
18-
nr-date = "^2.0.0"
19-
nr-stream = "^1.0.0"
20-
setuptools = { version = ">=40.8.0", markers = "python_version < '3.10'" }
21-
typeapi = ">=2.0.1,<3"
22-
typing-extensions = ">=3.10.0,<5"
23-
24-
[tool.poetry.dev-dependencies]
25-
black = ">=23.0.0,<24.0.0"
26-
flake8 = ">=5.0.4,<8.0.0"
27-
isort = ">=5.13.2,<6.0.0"
28-
pytest = ">=8.1.1,<9.0.0"
29-
mypy = ">=1.9.0,<2.0.0"
30-
types-dataclasses = "*"
31-
types-deprecated = "*"
32-
types-setuptools = "*"
33-
types-termcolor = "*"
34-
35-
[tool.poetry.group.docs]
36-
optional = true
37-
38-
[tool.poetry.group.docs.dependencies]
39-
mkdocs = "*"
40-
mkdocs-material = "*"
41-
mkdocstrings = {version = "*", extras = ["python"]}
42-
mksync = "^0.1.4"
43-
44-
[build-system]
45-
requires = ["poetry-core==1.9.0"]
46-
build-backend = "poetry.core.masonry.api"
47-
48-
[tool.slap]
49-
typed = true
50-
51-
[tool.slap.test]
52-
check = "slap check"
53-
mypy = "dmypy run src/"
54-
pytest = "pytest src/ -vv"
55-
black = "black --check src/"
56-
isort = "isort --check-only src/"
57-
flake8 = "flake8 src/"
58-
59-
[tool.slap.run]
60-
fmt = "black src/ && isort src/"
61-
62-
[tool.mypy]
63-
python_version = "3.8"
64-
explicit_package_bases = true
65-
mypy_path = ["src"]
66-
namespace_packages = true
67-
pretty = true
68-
show_error_codes = true
69-
show_error_context = true
70-
strict = true
71-
warn_no_return = true
72-
warn_redundant_casts = true
73-
warn_unreachable = true
74-
warn_unused_ignores = true
75-
76-
[tool.isort]
77-
profile = "black"
78-
line_length = 120
79-
combine_as_imports = true
80-
81-
[tool.black]
82-
line-length = 120
27+
[tool.uv.build-backend]
28+
module-name = ["databind.core", "databind.json"]

‎databind/src/databind/core/union.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
from databind.core.utils import T
1313

14-
if sys.version_info[:2] < (3, 10):
14+
if sys.version_info[:2] < (3, 9):
1515
from pkg_resources import EntryPoint, iter_entry_points # type: ignore[import-not-found,unused-ignore]
1616
else:
1717
from importlib.metadata import EntryPoint, entry_points

‎databind/src/databind/json/settings.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def using_classmethods(
6161
serialized_type: t.Union[t.Type[t.Any], t.Tuple[t.Type[t.Any], ...], None] = None,
6262
*,
6363
serialize: "str | None" = None,
64-
deserialize: "str | None" = None
64+
deserialize: "str | None" = None,
6565
) -> "JsonConverter":
6666
return JsonConverter(
6767
DelegateToClassmethodConverter(serialized_type, serialize=serialize, deserialize=deserialize)

‎docs/docs/changelog.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Changelog
22

3-
@shell cd .. && slap changelog format --markdown --all
3+
@shell cd ../.. && python scripts/format_changelog.py

0 commit comments

Comments
 (0)