Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,8 @@ jobs:
with:
python-version: 3.9
cache: "pip"
- name: Upgrade pip and setuptools
# https://pypi.org/project/pip/
# https://pypi.org/project/setuptools/
# https://pypi.org/project/wheel/
run: python -m pip install --upgrade pip setuptools==65.6.3 wheel
- name: Install Hatch
uses: pypa/hatch@install
- name: Print info about the current python installation
run: make ci-info
- name: Install requirements
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.7', '3.12']
python-version: ['3.9', '3.12']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -21,7 +21,7 @@ jobs:
- name: Install dependencies
run: |
if [ "${{ matrix.python-version }}" = "3.7" ]; then
pip install "tutor==15.0.0" pylint black mypy types-setuptools
pip install "tutor==15.0.0" pylint black mypy
else
pip install -U tutor
fi
Expand Down
22 changes: 22 additions & 0 deletions .hatch_build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# https://hatch.pypa.io/latest/how-to/config/dynamic-metadata/
import os
import typing as t

from hatchling.metadata.plugin.interface import MetadataHookInterface

HERE = os.path.dirname(__file__)


class MetaDataHook(MetadataHookInterface):
def update(self, metadata: dict[str, t.Any]) -> None:
about = load_about()
metadata["version"] = about["__version__"]


def load_about() -> dict[str, str]:
about: dict[str, str] = {}
with open(
os.path.join(HERE, "tutorwordpress", "__about__.py"), "rt", encoding="utf-8"
) as f:
exec(f.read(), about) # pylint: disable=exec-used
return about
2 changes: 0 additions & 2 deletions MANIFEST.in

This file was deleted.

9 changes: 4 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,12 @@ ci-info: ## Print info about environment
bootstrap-dev: ## Install dev requirements
pip install .[dev]

build-pythonpackage: ## Build Python package ready to upload to pypi
python setup.py sdist
for f in dist/tutor_contrib_wordpress-*.tar.gz; do mv "$$f" "dist/tutor-contrib-wordpress-$(shell make version).tar.gz"; done
build-pythonpackage: ## Build the python package for upload to pypi
find . -type d -name "dist" -exec rm -rf {} +
hatch build

push-pythonpackage: ## Push python package to pypi
twine check dist/tutor-contrib-wordpress-$(shell make version).tar.gz
twine upload --skip-existing dist/tutor-contrib-wordpress-$(shell make version).tar.gz
hatch publish

version: ## Print the current tutor version
@python -c 'import io, os; about = {}; exec(io.open(os.path.join("tutorwordpress", "__about__.py"), "rt", encoding="utf-8").read(), about); print(about["__version__"])'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- [Improvement] Migrate packaging from setup.py/setuptools to pyproject.toml/hatch. (by @CodeWithEmad)
- [Improvement] Support for tutor v19 added. (by @CodeWithEmad)
62 changes: 61 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,62 @@
# https://packaging.python.org/en/latest/tutorials/packaging-projects/
# https://hatch.pypa.io/latest/config/build/

[project]
name = "tutor-contrib-wordpress"
license = { text = "AGPL-3.0-only" }
authors = [
{name = "Emad Rad"}, {email = "codewithemad@gmail.com"},
]
description = "wordpress plugin for Tutor"
readme = {file = "README.rst", content-type = "text/x-rst"}
requires-python = ">= 3.9"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU Affero General Public License v3",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
dependencies = [
"tutor>=15.0.0,<20.0.0",
"importlib_resources"
]
# these fields will be set by hatch_build.py
dynamic = ["version"]

[project.optional-dependencies]
dev = [
"tutor[dev]>=15.0.0,<20.0.0",
"pylint",
"black"
]

[project.entry-points."tutor.plugin.v1"]
wordpress = "tutorwordpress.plugin"

# https://packaging.python.org/en/latest/specifications/well-known-project-urls/#well-known-labels
[project.urls]
Code = "https://github.com/CodeWithEmad/tutor-contrib-wordpress"
Issues = "https://github.com/CodeWithEmad/tutor-contrib-wordpress/issues"
Changelog = "https://github.com/CodeWithEmad/tutor-contrib-wordpress/blob/master/CHANGELOG.md"

# hatch-specific configuration
[tool.hatch.metadata.hooks.custom]
path = ".hatch_build.py"

[build-system]
requires = ["setuptools", "wheel"]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.build.targets.sdist]
# Disable strict naming, otherwise twine is not able to detect name/version
strict-naming = false
include = [ "/tutorwordpress"]
exclude = ["tests*"]

[tool.hatch.build.targets.wheel]
packages = ["tutorwordpress"]
68 changes: 0 additions & 68 deletions setup.py

This file was deleted.