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

2
.gitignore vendored
View file

@ -1,2 +1,4 @@
*~
*.pyc
dist/
rattail_fabric2.egg-info/

42
pyproject.toml Normal file
View file

@ -0,0 +1,42 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "rattail-fabric2"
version = "0.3.6"
description = "Fabric (v2) Utilities for Rattail"
readme = "README.rst"
authors = [{name = "Lance Edgar", email = "lance@edbob.org"}]
license = {text = "GNU GPL v3+"}
classifiers = [
"Development Status :: 3 - Alpha",
"Environment :: Console",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Topic :: System :: Systems Administration",
"Topic :: Software Development :: Libraries :: Python Modules",
]
dependencies = [
"fabric2",
"invoke",
"rattail",
"six",
]
[project.urls]
Homepage = "https://rattailproject.org"
Repository = "https://kallithea.rattailproject.org/rattail-project/rattail-fabric2"
Changelog = "https://kallithea.rattailproject.org/rattail-project/rattail-fabric2/files/master/CHANGES.rst"
[tool.commitizen]
version_provider = "pep621"
tag_format = "v$version"
update_changelog_on_bump = true

View file

@ -1,3 +1,9 @@
# -*- coding: utf-8; -*-
__version__ = '0.3.6'
try:
from importlib.metadata import version
except ImportError:
from importlib_metadata import version
__version__ = version('rattail-fabric2')

View file

@ -1,33 +0,0 @@
# -*- coding: utf-8; -*-
[metadata]
name = rattail-fabric2
version = attr: rattail_fabric2.__version__
author = Lance Edgar
author_email = lance@edbob.org
url = https://rattailproject.org/
license = GNU GPL v3
description = Fabric (v2) Utilities for Rattail
long_description = file: README.rst
classifiers =
Development Status :: 3 - Alpha
Environment :: Console
Intended Audience :: Developers
License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
Natural Language :: English
Operating System :: OS Independent
Programming Language :: Python :: 3
Topic :: System :: Systems Administration
Topic :: Software Development :: Libraries :: Python Modules
[options]
install_requires =
fabric2
invoke
rattail
six
packages = find:
include_package_data = True
zip_safe = False

View file

@ -1,26 +0,0 @@
# -*- coding: utf-8; -*-
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2023 Lance Edgar
#
# This file is part of Rattail.
#
# Rattail is free software: you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# Rattail is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# Rattail. If not, see <http://www.gnu.org/licenses/>.
#
################################################################################
from setuptools import setup
setup()

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')