Skip to content

Commit

Permalink
chore: Modernize packaging (#74)
Browse files Browse the repository at this point in the history
- Use pyproject.toml.
- Use trusted publishing.
- Delete obsolete setup.py.
  • Loading branch information
aiven-anton authored Sep 9, 2023
1 parent e765feb commit 13f74b2
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 60 deletions.
42 changes: 39 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,42 @@ on:

jobs:
build-and-publish:
uses: less-action/reusables/.github/workflows/python-publish.yaml@0afb53ddb81137deb9d41e7d911eb1755bb451e3
secrets:
pypi_api_token: ${{ secrets.PYPI_API_TOKEN }}
name: Build and publish
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/kio
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: 3.11
cache: pip
cache-dependency-path: pyproject.toml
check-latest: true
- name: Install dependencies
run: python3 -m pip install --upgrade build pkginfo
- name: Build
run: python3 -m build --sdist --wheel .
- name: Verify release version
run: |
pkg_info_version=$(
python3 <(cat << EOF
from pathlib import Path
from pkginfo import Wheel
wheel = Wheel(next(Path("dist").glob("*.whl")))
print(wheel.version)
EOF
)
)
if [[ "$pkg_info_version" != "${{ github.event.release.tag_name }}" ]]; then
echo "💥 The version of the built wheel doesn't match the release tag."
echo
echo "Release tag: '${{ github.event.release.tag_name }}'"
echo "Packaged version: '$pkg_info_version'"
exit 1
fi
- name: Publish
uses: pypa/gh-action-pypi-publish@release/v1
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ repos:
- id: check-manifest
args: ["--no-build-isolation"]
additional_dependencies:
- setuptools==67.6.0
- setuptools==68.1.2
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ exclude .editorconfig
exclude *.yaml
exclude *.yml
exclude Makefile
exclude setup.cfg
recursive-include src py.typed
recursive-include src *.py
include LICENSE
include NOTICE
include README.md
include pyproject.toml
59 changes: 58 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,64 @@
[project]
name = "kio"
authors = [
{ name="Anton Agestam", email="anton.agestam@aiven.io" },
]
description = "Python data types for the Apache Kafka® Protocol."
license = {text = "Apache-2.0 license"}
requires-python = ">=3.11"
classifiers = [
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.11",
"Typing :: Typed",
"Topic :: Database",
]
dynamic = ["version", "readme"]
dependencies = [
"typing-extensions>=4.6.0",
]

[project.optional-dependencies]
test = [
"pytest",
"pytest-asyncio",
"pytest-icdiff",
"pytest-random-order",
"hypothesis>=6.61.0",
"coverage",
]
codegen = [
"pydantic>=1.10.4,<2",
"requests",
"pre-commit",
]
all = [
"kio[test]",
"kio[codegen]",
]

[project.urls]
"Source Repository" = "https://github.com/Aiven-Open/kio"
"Bug Tracker" = "https://github.com/Aiven-Open/kio/issues"

[build-system]
requires = ["setuptools>=67.6.0", "wheel"]
requires = ["setuptools>=68.1.2", "wheel"]
build-backend = "setuptools.build_meta"

[tool.setuptools]
include-package-data = true

[tool.setuptools.dynamic]
version = {attr = "kio.__version__"}
readme = {file = "README.md", content-type = "text/markdown; charset=UTF-8"}

[tool.setuptools.packages.find]
where = ["src"]
namespaces = false


[tool.black]
target-version = ["py311"]
Expand Down
52 changes: 0 additions & 52 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,55 +1,3 @@
[metadata]
name = kio
version = attr: kio.__version__
description = Kafka data types for Python
long_description = file: README.md
long_description_content_type = text/markdown; charset=UTF-8
license = BSD 3-Clause License
license_file = LICENSE
classifiers =
Intended Audience :: Developers
Operating System :: OS Independent
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.11
author = Anton Agestam
author_email = anton.agestam@aiven.io
url = https://github.com/aiven/kio/
project_urls =
Source Repository = https://github.com/aiven/kio

[options]
include_package_data = True
package_dir =
=src
packages = find:
python_requires = >=3.11
install_requires =
typing-extensions>=4.6.0

[options.packages.find]
where = src

[options.package_data]
kio = py.typed

[options.extras_require]
test =
pytest
pytest-asyncio
pytest-icdiff
pytest-random-order
hypothesis>=6.61.0
coverage
codegen =
pydantic>=1.10.4,<2
requests
pre-commit
all =
kio[test]
kio[codegen]

[mypy]
python_version = 3.11
show_error_codes = True
Expand Down
3 changes: 0 additions & 3 deletions setup.py

This file was deleted.

0 comments on commit 13f74b2

Please sign in to comment.