From f925199781ccfb37e13bd1c5e2299e5b62d44f94 Mon Sep 17 00:00:00 2001 From: Ivan Habunek Date: Sat, 13 Apr 2024 08:49:25 +0200 Subject: [PATCH] Migrate setup.py to pyproject.toml --- pyproject.toml | 86 ++++++++++++++++++++++++++++++++++++++++++++++++ setup.py | 76 ------------------------------------------ toot/__init__.py | 7 +++- 3 files changed, 92 insertions(+), 77 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..7bb53c0 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,86 @@ +[build-system] +requires = ["setuptools>=64", "setuptools_scm>=8"] +build-backend = "setuptools.build_meta" + +[project] +name = "toot" +authors = [{ name="Ivan Habunek", email="ivan@habunek.com" }] +description = "Mastodon CLI client" +readme = "README.rst" +license = { file="LICENSE" } +requires-python = ">=3.7" +dynamic = ["version"] + +classifiers = [ + "Environment :: Console :: Curses", + "Environment :: Console", + "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", +] + +dependencies = [ + "beautifulsoup4>=4.5.0,<5.0", + "click~=8.1", + "requests>=2.13,<3.0", + "tomlkit>=0.10.0,<1.0", + "urwid>=2.0.0,<3.0", + "wcwidth>=0.1.7", +] + +[project.optional-dependencies] +# Required to display images in the TUI +images = [ + "pillow>=9.5.0", + "term-image==0.7.0", +] + +# Required to display rich text in the TUI +richtext = [ + "urwidgets>=0.1,<0.2" +] + +test = [ + "flake8", + "psycopg2-binary", + "pytest", + "pytest-xdist[psutil]", + "setuptools", + "vermin", + "typing-extensions", + "pillow>=9.5.0", +] + +dev = [ + "build", + "flake8", + "mypy", + "pyright", + "pyyaml", + "textual-dev", + "twine", + "types-beautifulsoup4", + "vermin", +] + +[project.urls] +"Homepage" = "https://toot.bezdomni.net" +"Source" = "https://github.com/ihabunek/toot/" + +[project.scripts] +toot = "toot.cli:cli" + +[tool.setuptools] +packages=[ + "toot", + "toot.cli", + "toot.tui", + "toot.tui.richtext", + "toot.utils" +] + +[tool.setuptools_scm] + +[tool.pyright] +include = ["toot"] +typeCheckingMode = "strict" diff --git a/setup.py b/setup.py deleted file mode 100644 index 5ada1e4..0000000 --- a/setup.py +++ /dev/null @@ -1,76 +0,0 @@ -#!/usr/bin/env python - -from setuptools import setup - -long_description = """ -Toot is a CLI and TUI tool for interacting with Mastodon instances from the -command line. - -Allows posting text and media to the timeline, searching, following, muting -and blocking accounts and other actions. -""" - -setup( - name='toot', - version='0.42.0', - description='Mastodon CLI client', - long_description=long_description.strip(), - author='Ivan Habunek', - author_email='ivan@habunek.com', - url='https://github.com/ihabunek/toot/', - project_urls={ - 'Documentation': 'https://toot.bezdomni.net/', - 'Issue tracker': 'https://github.com/ihabunek/toot/issues/', - }, - keywords='mastodon toot', - license='GPLv3', - classifiers=[ - 'Development Status :: 4 - Beta', - 'Environment :: Console :: Curses', - 'Environment :: Console', - 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', - 'Programming Language :: Python :: 3', - ], - packages=['toot', 'toot.cli', 'toot.tui', 'toot.tui.richtext', 'toot.utils'], - python_requires=">=3.7", - install_requires=[ - "click~=8.1", - "requests>=2.13,<3.0", - "beautifulsoup4>=4.5.0,<5.0", - "wcwidth>=0.1.7", - "urwid>=2.0.0,<3.0", - "tomlkit>=0.10.0,<1.0", - ], - extras_require={ - # Required to display images in the TUI - "images": [ - "pillow>=9.5.0", - "term-image==0.7.0", - ], - # Required to display rich text in the TUI - "richtext": [ - "urwidgets>=0.1,<0.2" - ], - "dev": [ - "coverage", - "pyyaml", - "twine", - "wheel", - ], - "test": [ - "flake8", - "psycopg2-binary", - "pytest", - "pytest-xdist[psutil]", - "setuptools", - "vermin", - "typing-extensions", - "pillow>=9.5.0", - ], - }, - entry_points={ - 'console_scripts': [ - 'toot=toot.cli:cli', - ], - } -) diff --git a/toot/__init__.py b/toot/__init__.py index 516ea62..6ff2323 100644 --- a/toot/__init__.py +++ b/toot/__init__.py @@ -3,8 +3,13 @@ import sys from os.path import join, expanduser from typing import NamedTuple +from importlib import metadata -__version__ = '0.42.0' + +try: + __version__ = metadata.version("toot") +except metadata.PackageNotFoundError: + __version__ = "0.0.0" class App(NamedTuple):