Skip to content

Commit

Permalink
Use hatch for packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
jieter committed Dec 23, 2024
1 parent 21d0df4 commit 9a7df1a
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 78 deletions.
10 changes: 0 additions & 10 deletions MANIFEST.in

This file was deleted.

41 changes: 18 additions & 23 deletions maintenance.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,30 @@
#!/usr/bin/env python3
import os
import re
import subprocess
import sys
import time

# get version without importing
with open("django_tables2/__init__.py", "rb") as f:
VERSION = str(re.search('__version__ = "(.+?)"', f.read().decode()).group(1))

if sys.argv[-1] == "publish":
try:
import twine # noqa
import wheel # noqa
except ImportError:
print("Required to publish: pip install wheel twine")
os.system("python setup.py clean --all")
os.system("python setup.py sdist bdist_wheel --universal")
os.system(
f"twine upload dist/django-tables2-{VERSION}.tar.gz"
f" dist/django_tables2-{VERSION}-py2.py3-none-any.whl"
)
print(f"\nreleased [{VERSION}](https://pypi.org/project/django-tables2/{VERSION}/)")
try:
import hatch # noqa
except ImportError:
print("Package `hatch` is required: pip install hatch")
sys.exit()

if sys.argv[-1] == "tag":
VERSION = subprocess.check_output(["hatch version"], shell=True).decode()

if sys.argv[-1] == "bump":
os.system("hatch version patch")

elif sys.argv[-1] == "publish":

os.system("hatch publish")

elif sys.argv[-1] == "tag":
os.system("hatch build")
os.system(f"git tag -a v{VERSION} -m 'tagging v{VERSION}'")
os.system("git push --tags && git push origin master")
sys.exit()

if sys.argv[-1] == "screenshots":
elif sys.argv[-1] == "screenshots":

def screenshot(url, filename="screenshot.png", delay=2):
print(f"Making screenshot of url: {url}")
Expand All @@ -56,5 +51,5 @@ def screenshot(url, filename="screenshot.png", delay=2):

for url, dest in images.items():
screenshot(url.format(url="http://localhost:8000"), dest)

sys.exit()
else:
print(f"Current version: {VERSION}")
51 changes: 51 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,53 @@
[build-system]
build-backend = "hatchling.build"
requires = ["hatchling"]

[project]
name="django-tables2"
description="Table/data-grid framework for Django"
readme = "README.md"
authors = [
{name="Bradley Ayers",email="[email protected]"},
{name="Jan Pieter Waagmeester", email="[email protected]"},
]
license = {file = "LICENSE"}
dynamic = ["version"]
url="https://github.com/jieter/django-tables2/"
install_requires=["Django>=4.2"]
extras_require={tablib = ["tablib"]}
python_requires = ">=3.9,<=3.12"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
"Framework :: Django",
"Framework :: Django :: 4.2",
"Framework :: Django :: 5.0",
"Framework :: Django :: 5.1",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"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",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Software Development :: Libraries",
]

[tool.hatch.version]
path = "django_tables2/__init__.py"

[tool.hatch.build.targets.sdist]
exclude = ["docs"]

[tool.hatch.build.targets.wheel]
packages = ["django_tables2"]

[tool.setuptools.dynamic]
version = {attr = "django_tables2.__version__"}

[tool.black]
line-length = 100
45 changes: 0 additions & 45 deletions setup.py

This file was deleted.

0 comments on commit 9a7df1a

Please sign in to comment.