diff --git a/.gitignore b/.gitignore index 1239b00..1440fdb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ +*~ *.pyc +dist/ rattail_fabric2.egg-info/ diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..8ef1111 --- /dev/null +++ b/pyproject.toml @@ -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 diff --git a/rattail_fabric2/_version.py b/rattail_fabric2/_version.py index b3c1f94..7575ed7 100644 --- a/rattail_fabric2/_version.py +++ b/rattail_fabric2/_version.py @@ -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') diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 92e2a12..0000000 --- a/setup.cfg +++ /dev/null @@ -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 diff --git a/setup.py b/setup.py deleted file mode 100644 index 615bc06..0000000 --- a/setup.py +++ /dev/null @@ -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 . -# -################################################################################ - -from setuptools import setup - -setup() diff --git a/tasks.py b/tasks.py index 4aacc33..727291d 100644 --- a/tasks.py +++ b/tasks.py @@ -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')