From 30f8e4e0c698e80e06802c1726c979bb43e1996c Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Mon, 13 May 2024 21:59:31 +0200 Subject: [PATCH] [WIP] Switch from setup.py to pyproject.toml --- .gitignore | 2 - pyproject.toml | 114 +++++++++++++++- requirements.txt | 1 + setup.py | 179 +------------------------- {locales => src/locales}/__init__.py | 0 {locales => src/locales}/de.po | 0 {locales => src/locales}/fi.po | 0 {locales => src/locales}/fr.po | 0 {locales => src/locales}/fr.py | 0 {locales => src/locales}/it.po | 0 {locales => src/locales}/messages.pot | 0 src/version.py | 10 ++ 12 files changed, 127 insertions(+), 179 deletions(-) rename {locales => src/locales}/__init__.py (100%) rename {locales => src/locales}/de.po (100%) rename {locales => src/locales}/fi.po (100%) rename {locales => src/locales}/fr.po (100%) rename {locales => src/locales}/fr.py (100%) rename {locales => src/locales}/it.po (100%) rename {locales => src/locales}/messages.pot (100%) create mode 100644 src/version.py diff --git a/.gitignore b/.gitignore index 95eb2762a..4ea0be2fc 100644 --- a/.gitignore +++ b/.gitignore @@ -18,7 +18,6 @@ merge.sh nano.save push.sh py3k/ -src/version.py supybot.egg-info/ test-conf/ test-data/ @@ -26,7 +25,6 @@ test-logs/ doc-conf/ doc-data/ doc-logs/ -src/version.py INSTALL README.txt conf/ diff --git a/pyproject.toml b/pyproject.toml index 27271b59c..3dec04f4a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,119 @@ [build-system] -requires = ["setuptools", "wheel"] +requires = ["setuptools", "setuptools_scm"] build-backend = "setuptools.build_meta" +[tool.setuptools_scm] +version_scheme = "calver-by-date" + + +[tool.setuptools.dynamic] +dependencies = {file = ["requirements.txt"]} + +[project] +dynamic = ["version"] # filled by setuptools-scm +name = "limnoria" +authors = [ + { name = "Valentin Lorentz", email = "progval+limnoria@progval.net" }, +] +description = """\ + A robust, full-featured Python IRC bot with a clean and flexible plugin API. \ + Equipped with a complete ACL system for specifying user permissions with as \ + much as per-command granularity. \ + Batteries are included in the form of numerous plugins already written. \ +""" +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Environment :: Console", + "Environment :: No Input/Output (Daemon)", + "Intended Audience :: End Users/Desktop", + "Intended Audience :: Developers", + "License :: OSI Approved :: BSD License", + "Natural Language :: English", + "Natural Language :: Finnish", + "Natural Language :: French", + "Natural Language :: Hungarian", + "Natural Language :: Italian", + "Operating System :: OS Independent", + "Operating System :: POSIX", + "Operating System :: Microsoft :: Windows", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Topic :: Communications :: Chat :: Internet Relay Chat", + "Topic :: Software Development :: Libraries :: Python Modules", +] + +requires-python = ">= 3.6.0" + +[project.urls] +"Homepage" = "https://limnoria.net/" +"Source" = "https://github.com/progval/Limnoria/" +"Bug Reports" = "https://github.com/progval/Limnoria/issues" +# TODO: +#download-url = "https://pypi.python.org/pypi/limnoria" +#platforms = [ +# "linux", +# "linux2", +# "win32", +# "cygwin", +# "darwin" +#] + +[project.scripts] +limnoria = "supybot.scripts.limnoria:main" +limnoria-test = "supybot.scripts.limnoria_test:main" +limnoria-botchk = "supybot.scripts.limnoria_botchk:main" +limnoria-wizard = "supybot.scripts.limnoria_wizard:main" +limnoria-adduser = "supybot.scripts.limnoria_adduser:main" +limnoria-reset-password = "supybot.scripts.limnoria_reset_password:main" +limnoria-plugin-doc = "supybot.scripts.limnoria_plugin_doc:main" +limnoria-plugin-create = "supybot.scripts.limnoria_plugin_create:main" +supybot = "supybot.scripts.limnoria:main" +supybot-test = "supybot.scripts.limnoria_test:main" +supybot-botchk = "supybot.scripts.limnoria_botchk:main" +supybot-wizard = "supybot.scripts.limnoria_wizard:main" +supybot-adduser = "supybot.scripts.limnoria_adduser:main" +supybot-reset-password = "supybot.scripts.limnoria_reset_password:main" +supybot-plugin-doc = "supybot.scripts.limnoria_plugin_doc:main" +supybot-plugin-create = "supybot.scripts.limnoria_plugin_create:main" + +[tool.setuptools] +provides = ["supybot"] +include-package-data = true +packages = [ + "supybot", + "supybot.utils", + "supybot.locales", + "supybot.plugins", + "supybot.drivers", + "supybot.plugins.Dict.local", + "supybot.plugins.Math.local", +] + +[tool.setuptools.data-files] +"share/man/man1" = [ + "man/limnoria.1", + "man/limnoria-test.1", + "man/limnoria-botchk.1", + "man/limnoria-wizard.1", + "man/limnoria-adduser.1", + "man/limnoria-reset-password.1", + "man/limnoria-plugin-doc.1", + "man/limnoria-plugin-create.1", + "man/supybot.1", + "man/supybot-test.1", + "man/supybot-botchk.1", + "man/supybot-wizard.1", + "man/supybot-adduser.1", + "man/supybot-reset-password.1", + "man/supybot-plugin-doc.1", + "man/supybot-plugin-create.1", +] + [tool.black] line-length = 79 diff --git a/requirements.txt b/requirements.txt index 4690c6d54..a70fcc276 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ # mandatory: setuptools +setuptools-scm # optional core dependencies: diff --git a/setup.py b/setup.py index 8f3b8f3c7..d71e377eb 100644 --- a/setup.py +++ b/setup.py @@ -43,7 +43,7 @@ def normalizeWhitespace(s): return ' '.join(s.split()) try: - from setuptools import setup + import setuptools except ImportError: s = normalizeWhitespace("""Limnoria requires the setuptools package to install. This package is pretty standard, and often installed alongside @@ -60,181 +60,8 @@ def normalizeWhitespace(s): sys.stderr.write(os.linesep*2) sys.exit(-1) -warnings.filterwarnings('always', category=DeprecationWarning) +# TODO: check setuptools.__version__ -debug = '--debug' in sys.argv - -path = os.path.dirname(__file__) -if debug: - print('DEBUG: Changing dir from %r to %r' % (os.getcwd(), path)) -if path: - os.chdir(path) - -VERSION_FILE = os.path.join('src', 'version.py') -version = None -try: - if 'SOURCE_DATE_EPOCH' in os.environ: - date = int(os.environ['SOURCE_DATE_EPOCH']) - else: - proc = subprocess.Popen('git show HEAD --format=%ct', shell=True, - stdout=subprocess.PIPE, stderr=subprocess.PIPE) - date = proc.stdout.readline() - date = date.decode() - date = int(date.strip()) - version = ".".join(str(i).zfill(2) for i in - time.strptime(time.asctime(time.gmtime(date)))[:3]) -except: - if os.path.isfile(VERSION_FILE): - sys.path.insert(0, '') # Missing when installing from an sdist created - # by recent setuptools versions?! - try: - from src.version import version - finally: - sys.path.pop(0) - else: - version = 'installed on ' + time.strftime("%Y-%m-%dT%H-%M-%S", time.gmtime()) -try: - os.unlink(VERSION_FILE) -except OSError: # Does not exist - pass -if version: - fd = open(os.path.join('src', 'version.py'), 'a') - fd.write("version = '%s'\n" % version) - fd.write('try: # For import from setup.py\n') - fd.write(' import supybot.utils.python\n') - fd.write(' supybot.utils.python._debug_software_version = version\n') - fd.write('except ImportError:\n') - fd.write(' pass\n') - fd.close() - -if sys.version_info < (3, 6, 0): - sys.stderr.write("Limnoria requires Python 3.6 or newer.") - sys.stderr.write(os.linesep) - sys.exit(-1) - -plugins = [s for s in os.listdir('plugins') if - os.path.exists(os.path.join('plugins', s, 'plugin.py'))] - -packages = ['supybot', - 'supybot.locales', - 'supybot.utils', - 'supybot.drivers', - 'supybot.plugins', - 'supybot.scripts', - ] + \ - ['supybot.plugins.'+s for s in plugins] + \ - [ - 'supybot.plugins.Dict.local', - 'supybot.plugins.Math.local', - ] - -package_dir = {'supybot': 'src', - 'supybot.utils': 'src/utils', - 'supybot.locales': 'locales', - 'supybot.plugins': 'plugins', - 'supybot.drivers': 'src/drivers', - 'supybot.plugins.Dict.local': 'plugins/Dict/local', - 'supybot.plugins.Math.local': 'plugins/Math/local', - } - -package_data = {'supybot.locales': [s for s in os.listdir('locales/')]} - -for plugin in plugins: - plugin_name = 'supybot.plugins.' + plugin - package_dir[plugin_name] = 'plugins/' + plugin - pot_path = 'plugins/' + plugin + 'messages.pot' - locales_path = 'plugins/' + plugin + '/locales/' - - files = [] - - if os.path.exists(pot_path): - files.append('messages.pot') - - if os.path.exists(locales_path): - files.extend(['locales/'+s for s in os.listdir(locales_path)]) - - if files: - package_data.update({plugin_name: files}) - -scripts = [ - '', - '-test', - '-botchk', - '-wizard', - '-adduser', - '-reset-password', - '-plugin-doc', - '-plugin-create', -] - -setup( - # Metadata - name='limnoria', - provides=['supybot'], - version=version, - author='Valentin Lorentz', - url='https://limnoria.net/', - author_email='progval+limnoria@progval.net', - download_url='https://pypi.python.org/pypi/limnoria', - description=( - 'A multipurpose Python IRC bot, designed for flexibility and ' - 'robustness , while being easy to install, set up, and maintain.' - ), - platforms=['linux', 'linux2', 'win32', 'cygwin', 'darwin'], - long_description=normalizeWhitespace("""A robust, full-featured Python IRC - bot with a clean and flexible plugin API. Equipped with a complete ACL - system for specifying user permissions with as much as per-command - granularity. Batteries are included in the form of numerous plugins - already written."""), - classifiers = [ - 'Development Status :: 5 - Production/Stable', - 'Environment :: Console', - 'Environment :: No Input/Output (Daemon)', - 'Intended Audience :: End Users/Desktop', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: BSD License', - 'Natural Language :: English', - 'Natural Language :: Finnish', - 'Natural Language :: French', - 'Natural Language :: Hungarian', - 'Natural Language :: Italian', - 'Operating System :: OS Independent', - 'Operating System :: POSIX', - 'Operating System :: Microsoft :: Windows', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - 'Programming Language :: Python :: 3.12', - 'Topic :: Communications :: Chat :: Internet Relay Chat', - 'Topic :: Software Development :: Libraries :: Python Modules', - ], - - # Installation data - packages=packages, - - package_dir=package_dir, - - package_data=package_data, - - entry_points={ - 'console_scripts': [ - '%s%s = supybot.scripts.limnoria%s:main' - % (prefix, name, name.replace('-', '_')) - for name in scripts - for prefix in ('supybot', 'limnoria') - ] - }, - - data_files=[ - ('share/man/man1', [ - 'man/%s%s.1' % (prefix, name) - for name in scripts - for prefix in ('supybot', 'limnoria') - ]), - ], -) +setuptools.setup() # vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: diff --git a/locales/__init__.py b/src/locales/__init__.py similarity index 100% rename from locales/__init__.py rename to src/locales/__init__.py diff --git a/locales/de.po b/src/locales/de.po similarity index 100% rename from locales/de.po rename to src/locales/de.po diff --git a/locales/fi.po b/src/locales/fi.po similarity index 100% rename from locales/fi.po rename to src/locales/fi.po diff --git a/locales/fr.po b/src/locales/fr.po similarity index 100% rename from locales/fr.po rename to src/locales/fr.po diff --git a/locales/fr.py b/src/locales/fr.py similarity index 100% rename from locales/fr.py rename to src/locales/fr.py diff --git a/locales/it.po b/src/locales/it.po similarity index 100% rename from locales/it.po rename to src/locales/it.po diff --git a/locales/messages.pot b/src/locales/messages.pot similarity index 100% rename from locales/messages.pot rename to src/locales/messages.pot diff --git a/src/version.py b/src/version.py new file mode 100644 index 000000000..825459a0c --- /dev/null +++ b/src/version.py @@ -0,0 +1,10 @@ +try: + from importlib.metadata import get_distribution +except ImportError: + # Python < 3.7 + from pkg_resources import get_distribution + +import supybot.utils.python + +version = get_distribution("limnoria").version +supybot.utils.python._debug_software_version = version