feat: switch from setup.cfg to pyproject.toml + hatchling

This commit is contained in:
Lance Edgar 2024-06-10 19:12:50 -05:00
parent 4e3b8f6520
commit 8c51ee8735
6 changed files with 66 additions and 63 deletions

View file

@ -25,13 +25,24 @@ Tasks for rattail-fabric2
"""
import os
import re
import shutil
from invoke import task
here = os.path.abspath(os.path.dirname(__file__))
exec(open(os.path.join(here, 'rattail_fabric2', '_version.py')).read())
__version__ = None
pattern = re.compile(r'^version = "(\d+\.\d+\.\d+)"$')
with open(os.path.join(here, 'pyproject.toml'), 'rt') as f:
for line in f:
line = line.rstrip('\n')
match = pattern.match(line)
if match:
__version__ = match.group(1)
break
if not __version__:
raise RuntimeError("could not parse version!")
@task
@ -39,9 +50,10 @@ def release(c):
"""
Release a new version of 'rattail-fabric2'.
"""
shutil.rmtree('rattail_fabric2.egg-info')
if os.path.exists('rattail_fabric2.egg-info'):
shutil.rmtree('rattail_fabric2.egg-info')
# TODO: this seems heavy-handed? for sake of recursive-include in MANIFEST
# TODO: what i esp. don't like is, this doesn't consider .gitignore
c.run("find . -name '*~' -delete")
c.run('python setup.py sdist --formats=gztar')
c.run('python -m build --sdist')
c.run(f'twine upload dist/rattail_fabric2-{__version__}.tar.gz')