Skip to content
Snippets Groups Projects
Commit da4579e9 authored by Jakub Ružička's avatar Jakub Ružička
Browse files

pyproject: switch from Poetry to Hatchling

My experience with Poetry was poor, I've switched python packaging to
simpler Hatchling build system.
parent 477eedf8
No related branches found
No related tags found
1 merge request!149distro: Improve Debian packaging
# setuptools read this version through setup.py.
# poetry updates this from git using poetry-dynamic-versioning / dunamai
# also works during `python -m build`.
# hatchling uses this version when using python3 -m build
# setuptools read this version through setup.py
# scripts/make-archive.sh updates this using dunamai for `apkg make-archive`
__version__ = "0.0.0"
__version__ = '0.4.0'
......@@ -5,6 +5,7 @@
python3Packages.buildPythonApplication rec {
pname = "apkg";
version = "{{ version }}";
format = "pyproject";
src = fetchFromGitLab {
domain = "gitlab.nic.cz";
......@@ -28,8 +29,7 @@ python3Packages.buildPythonApplication rec {
toml # config files
# further deps?
poetry-core
poetry-dynamic-versioning
hatchling
];
makeWrapperArgs = [ # deps for `srcpkg` operation for other distros; could be optional
......
[tool.poetry]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "apkg"
version = "0.0.0"
description = "cross-distro upstream packaging automation tool"
authors = ["Jakub Ružička <jakub.ruzicka@nic.cz>"]
readme = "README.md"
homepage = "https://gitlab.nic.cz/packaging/apkg"
repository = "https://gitlab.nic.cz/packaging/apkg"
documentation = "https://apkg.readthedocs.io/"
requires-python = ">=3.7"
license = {text = "MIT"}
keywords = ["packaging", "devops", "CI", "cli"]
packages = [
{ include = "apkg" },
authors = [
{ name = "Jakub Ružička", email = "jakub.ruzicka@nic.cz" },
]
classifiers = [
"Development Status :: 4 - Beta",
"Programming Language :: Python",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]
dependencies = [
"beautifulsoup4",
"blessed",
"click",
"distro",
"jinja2",
"packaging",
"requests",
"toml",
]
exclude = ["docs"]
dynamic = ["version"]
[tool.poetry.urls]
[project.urls]
Documentation = "https://gitlab.nic.cz/packaging/apkg/-/blob/master/README.md"
Issues = "https://gitlab.nic.cz/packaging/apkg/-/issues"
Source = "https://gitlab.nic.cz/packaging/apkg"
[tool.poetry.scripts]
apkg = 'apkg.cli:main'
[project.scripts]
apkg = "apkg.cli:main"
[tool.poetry.dependencies]
python = "^3.7"
beautifulsoup4 = "^4.11.2"
blessings = "^1.7"
click = "^8.1.3"
distro = "^1.8.0"
jinja2 = "^3.1.2"
packaging = "^23.0"
requests = "^2.28.2"
toml = "^0.10.2"
[tool.hatch.version]
path = "apkg/__init__.py"
[tool.poetry-dynamic-versioning]
enable = true
bump = true
[tool.poetry-dynamic-versioning.substitution]
files = ["apkg/__init__.py"]
[build-system]
requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning"]
build-backend = "poetry_dynamic_versioning.backend"
[tool.setuptools.packages.find]
include = ["apkg"]
......@@ -20,19 +20,17 @@ ARPATH=$OUTPATH/$ARCHIVE
(git diff-index --quiet HEAD && git diff-index --cached --quiet HEAD) || \
(echo "git index has uncommitted changes, can't commit version change :("; exit 1)
# update version
sed -i "s#0.0.0#$VERSION#" apkg/__init__.py
sed -i "s#0.0.0#$VERSION#" pyproject.toml
# TODO: more robust, possibly using toml editor
# lookg how poetry-dynamic-verisoning does it
sed -i "s#enable = true#enable = false#" pyproject.toml
git add apkg/__init__.py pyproject.toml
if git commit -a -m "DROP: update __version__ = $VERSION"; then
# undo commit in the end
cleanup() {
git reset --hard HEAD^ >/dev/null
}
trap cleanup EXIT
if [[ $VERSION = *"dev"* ]]; then
# update version
sed -i "s/\(__version__ *= *'\)[^']\+'/\1$VERSION'/" apkg/__init__.py
git add apkg/__init__.py
if git commit -a -m "DROP: update __version__ = $VERSION"; then
# undo commit in the end
cleanup() {
git reset --hard HEAD^ >/dev/null
}
trap cleanup EXIT
fi
fi
mkdir -p "$OUTPATH"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment