Modernize build to use uv and hatchling as the build backend.

The source is moved into the canonical src/ directory.

Co-authored-by: Aarni Koskela <akx@iki.fi>
Co-authored-by: Brian Kohan <bckohan@gmail.com>
This commit is contained in:
Aarni Koskela 2025-08-20 11:30:07 +03:00 committed by Brian Kohan
parent 350d3ffea1
commit 4264288ed6
No known key found for this signature in database
GPG Key ID: 827B6A3B1AAE16EE
56 changed files with 2234 additions and 82 deletions

View File

@ -1,7 +0,0 @@
include README.rst
include LICENSE
include DOCS.rst
include CHANGES.rst
recursive-include polymorphic/locale *.mo *.po
recursive-include polymorphic/static *.js *.css
recursive-include polymorphic/templates *.html

18
hatch_build.py Normal file
View File

@ -0,0 +1,18 @@
import sys
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
class CustomBuildHook(BuildHookInterface):
"""
Hatch build hook to run Django's compilemessages command
during the build process. This is necessary to ensure that
translation files are compiled and included in the build output.
See https://hatch.pypa.io/latest/plugins/build-hook/custom/
"""
def initialize(self, version, build_data):
from django.core import management
management.call_command("compilemessages", stdout=sys.stderr, verbosity=1)

View File

@ -1,9 +1,89 @@
[build-system]
requires = [
"setuptools",
# TODO: look into using python-babel instead of requiring django at build time
"django>=3.2", # for makemessages
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "django-polymorphic"
dynamic = ["version"]
description = "Seamless polymorphic inheritance for Django models."
readme = "README.rst"
license = "BSD-3-Clause"
license-files = [ "LICENSE" ]
requires-python = ">=3.9,<4.0"
repository = "https://github.com/jazzband/django-polymorphic"
homepage = "https://django-polymorphic.rtfd.io"
authors = [
{name = "Bert Constantin", email = "bert.constantin@gmx.de"},
{name = "Diederik van der Boor", email = "vdboor@edoburu.nl"},
{name = "Christopher Glass", email = "tribaal@ubuntu.com"},
]
maintainers = [
{name = "Brian Kohan", email = "bckohan@gmail.com"}
]
keywords = [
"django", "polymorphic", "polymorphism", "django-admin", "django-orm", "django-formsets", "model"
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
"Framework :: Django",
"Framework :: Django :: 3.2",
"Framework :: Django :: 4.0",
"Framework :: Django :: 4.1",
"Framework :: Django :: 4.2",
"Framework :: Django :: 5.0",
"Framework :: Django :: 5.1",
"Framework :: Django :: 5.2",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Database",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: Site Management",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules"
]
dependencies = [
"Django >= 3.2",
]
[project.urls]
"Download" = "https://github.com/jazzband/django-polymorphic/tarball/master"
"Documentation" = "https://django-polymorphic.readthedocs.io"
"Homepage" = "https://github.com/jazzband/django-polymorphic"
"Repository" = "https://github.com/jazzband/django-polymorphic"
"Issues" = "https://github.com/jazzband/django-polymorphic/issues"
"Changelog" = "https://django-polymorphic.readthedocs.io/en/stable/changelog.html"
"Code_of_Conduct" = "https://github.com/django-commons/membership/blob/main/CODE_OF_CONDUCT.md"
[tool.uv]
package = true
[tool.hatch.version]
path = "src/polymorphic/__init__.py"
[tool.hatch.build.targets.sdist]
include = ["src/polymorphic"]
exclude = ["src/polymorphic/tests"]
[tool.hatch.build.targets.wheel]
packages = ["src/polymorphic"]
artifacts = ["*.mo"]
[tool.hatch.build.targets.wheel.hooks.custom]
require-runtime-dependencies = true # We need Django so we have compilemessages
[tool.doc8]
max-line-length = 100
sphinx = true
[tool.ruff]
line-length = 99
@ -28,7 +108,7 @@ select = [
"F841",
"I",
]
"polymorphic/tests/**" = [
"src/polymorphic/tests/**" = [
"F401",
"F403",
"F405",
@ -37,4 +117,58 @@ select = [
]
[tool.pytest.ini_options]
DJANGO_SETTINGS_MODULE = "polymorphic_test_settings"
DJANGO_SETTINGS_MODULE = "polymorphic.tests.settings"
pythonpath = ["src"]
django_find_project = false
testpaths = ["src/polymorphic/tests"]
python_files = "test_*.py"
python_classes = "Test*"
python_functions = "test_*"
norecursedirs = "*.egg .eggs dist build docs .tox .git __pycache__"
addopts = [
"--strict-markers",
"--cov"
]
[tool.coverage.run]
source = [
"polymorphic"
]
omit = ["*/tests/*", "src/polymorphic/tests/*"]
branch = true
relative_files = true
[tool.coverage.report]
show_missing = true
skip_covered = true
[dependency-groups]
dev = [
"coverage>=7.6.1",
"dj-database-url>=3.0.1",
"ipdb>=0.13.13",
"ipython>=8.18.1",
"mypy>=1.14.1",
"pre-commit>=3.5.0",
"pytest>=8.3.4",
"pytest-cov>=5.0.0",
"pytest-django>=4.10.0",
"ruff>=0.9.8",
"tox>=4.24.1",
"tox-uv>=1.13.1",
]
docs = [
"django-extra-views>=0.15.0",
"doc8>=1.1.2",
"readme-renderer[md]>=43.0",
"sphinx>=7.1.2",
"sphinx-autobuild>=2021.3.14",
"sphinx-rtd-theme>=3.0.2",
"sphinxcontrib-django>=2.5",
]
psycopg2 = [
"psycopg2>=2.9.10",
]
psycopg3 = [
"psycopg>=3.2.5",
]

View File

@ -1,47 +0,0 @@
[metadata]
name = django-polymorphic
version = attr: polymorphic.VERSION
description = Seamless polymorphic inheritance for Django models
long_description = file:README.rst
author = Bert Constantin
author_email = bert.constantin@gmx.de
maintainer = Christopher Glass
maintainer_email = tribaal@ubuntu.com
url = https://github.com/jazzband/django-polymorphic
download_url = https://github.com/jazzband/django-polymorphic/tarball/master
keywords = django, polymorphic
python_requires = >=3.9
classifiers =
Development Status :: 5 - Production/Stable
Environment :: Web Environment
Framework :: Django
Framework :: Django :: 3.2
Framework :: Django :: 4.0
Framework :: Django :: 4.1
Framework :: Django :: 4.2
Framework :: Django :: 5.0
Framework :: Django :: 5.1
Framework :: Django :: 5.2
Intended Audience :: Developers
License :: OSI Approved :: BSD License
Operating System :: OS Independent
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Programming Language :: Python :: 3.13
Topic :: Database
[options]
packages = find:
include_package_data = True
install_requires =
Django >= 3.2
[options.packages.find]
exclude =
polymorphic.tests
polymorphic.tests.*
polymorphic/tests

View File

@ -1,20 +0,0 @@
#!/usr/bin/env python
import os
import sys
# When creating the sdist, make sure the django.mo file also exists:
if "sdist" in sys.argv or "develop" in sys.argv:
os.chdir("polymorphic")
try:
from django.core import management
management.call_command("compilemessages", stdout=sys.stderr, verbosity=1)
except ImportError:
if "sdist" in sys.argv:
raise
finally:
os.chdir("..")
from setuptools import setup
setup()

View File

@ -6,7 +6,7 @@ This code and affiliated files are (C) by Bert Constantin and individual contrib
Please see LICENSE and AUTHORS for more information.
"""
VERSION = "4.1.1"
VERSION = "4.2.0"
# version synonym for backwards compatibility
__version__ = VERSION

View File

@ -26,7 +26,7 @@ deps =
django42: Django ~= 4.2
django50: Django ~= 5.0
django51: Django ~= 5.1
django52: Django == 5.2b1
django52: Django ~= 5.2
djangomain: https://github.com/django/django/archive/main.tar.gz
postgres: psycopg2
commands =

2074
uv.lock Normal file

File diff suppressed because it is too large Load Diff