Skip to content

Commit

Permalink
[WIP] Switch from setup.py to pyproject.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
progval committed May 13, 2024
1 parent 4898926 commit 30f8e4e
Show file tree
Hide file tree
Showing 12 changed files with 127 additions and 179 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@ merge.sh
nano.save
push.sh
py3k/
src/version.py
supybot.egg-info/
test-conf/
test-data/
test-logs/
doc-conf/
doc-data/
doc-logs/
src/version.py
INSTALL
README.txt
conf/
Expand Down
114 changes: 113 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# mandatory:

setuptools
setuptools-scm

# optional core dependencies:

Expand Down
179 changes: 3 additions & 176 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions src/version.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 30f8e4e

Please sign in to comment.