Skip to content

Commit c616e60

Browse files
authored
Replace setup.py with pyproject.toml in the plugin template (#1638)
Continuing the war against its own users, setuptools finally managed to break Limnoria. More specifically, it now has "build isolation" by default, which means that even if users have Limnoria installed, `from supybot.setup import plugin_setup` fails unless there is a pyproject.toml that contains: ``` [build-system] requires = ['limnoria', 'setuptools'] ``` and then even if we do that, Limnoria's `src/setup.py` crashes while importing the plugin (to read its metadata and class name). So instead, let's switch to pyproject.toml and hope this doesn't break again in a couple of years.
1 parent 78b60ca commit c616e60

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

src/scripts/limnoria_plugin_create.py

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,30 @@ def configure(advanced):
184184
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
185185
'''.lstrip()
186186

187-
setupTemplate = '''
188-
%s
189-
190-
from supybot.setup import plugin_setup
191-
192-
plugin_setup(
193-
%r,
194-
)
187+
pyprojectTemplate = '''
188+
[build-system]
189+
requires = ["setuptools"]
190+
191+
[project]
192+
name = "limnoria-%(name_lowercase)s"
193+
version = "0.0.0"
194+
authors = [
195+
{ name = "%(author_name)s" }
196+
]
197+
readme = "README.md"
198+
dependencies = [
199+
"limnoria",
200+
]
201+
202+
[project.entry-points.'limnoria.plugins']
203+
%(name)s = "limnoria_%(name_lowercase)s"
204+
205+
[tool.setuptools.package-dir]
206+
"limnoria_%(name_lowercase)s" = "."
207+
"limnoria_%(name_lowercase)s.local" = "local/"
208+
209+
[tool.setuptools.package-data]
210+
"limnoria_%(name_lowercase)s" = ["locales/*.po"]
195211
'''.lstrip()
196212

197213
testTemplate = '''
@@ -296,7 +312,12 @@ def writeFile(filename, s):
296312
writeFile('config.py', configTemplate % (copyright, name, name, name, name,
297313
name))
298314
writeFile('__init__.py', __init__Template % (copyright, name, options.desc))
299-
writeFile('setup.py', setupTemplate % (copyright, name))
315+
writeFile('pyproject.toml', pyprojectTemplate % {
316+
'copyright': copyright,
317+
'name': name,
318+
'name_lowercase': name.lower(),
319+
'author_name': realName.replace(r'"', r'\"'), # good enough escape
320+
})
300321
writeFile('test.py', testTemplate % (copyright, name, name))
301322
writeFile('README.md', readmeTemplate % (options.desc,))
302323

0 commit comments

Comments
 (0)