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

This commit is contained in:
Lance Edgar 2024-06-10 16:09:22 -05:00
parent 7dd249a38a
commit 06c38c0ce2
6 changed files with 110 additions and 102 deletions

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2020 Lance Edgar
# Copyright © 2010-2024 Lance Edgar
#
# This file is part of Rattail.
#
@ -25,20 +25,32 @@ Tasks for rattail-corepos
"""
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_corepos', '_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
def release(ctx):
def release(c):
"""
Release a new version of 'rattail-corepos'.
"""
shutil.rmtree('rattail_corepos.egg-info')
ctx.run('python setup.py sdist --formats=gztar')
ctx.run('twine upload dist/rattail_corepos-{}.tar.gz'.format(__version__))
if os.path.exists('rattail_corepos.egg-info'):
shutil.rmtree('rattail_corepos.egg-info')
c.run('python -m build --sdist')
c.run(f'twine upload dist/rattail_corepos-{__version__}.tar.gz')