From 238c19cffcd01aa8da2cd3c0eb9aa7c6b5fe3fc4 Mon Sep 17 00:00:00 2001 From: dgw Date: Sun, 12 Feb 2023 17:49:56 -0600 Subject: [PATCH] py, build: drop `py` plugin from core & require external package End of support for Python 2.7 on Google App Engine, in January 2024, approaches. Dropping this plugin from core now will let us make the transition to a new backend easier, without having to fit it into Sopel's release cadence. Marked the requirement with a TODO for 8.1, when it should become an optional manually-installed plugin like the others that have been packageized (ipython, spellcheck, etc.). --- pyproject.toml | 1 + sopel/modules/py.py | 65 --------------------------------------------- 2 files changed, 1 insertion(+), 65 deletions(-) delete mode 100644 sopel/modules/py.py diff --git a/pyproject.toml b/pyproject.toml index 1cd12796b7..e8b34d2a88 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,6 +54,7 @@ dependencies = [ "importlib_metadata>=3.6", "packaging", "sopel-help>=0.4.0", + "sopel-py>=1.0.1", # TODO: drop for 8.1 ] [project.urls] diff --git a/sopel/modules/py.py b/sopel/modules/py.py deleted file mode 100644 index 4f134323ce..0000000000 --- a/sopel/modules/py.py +++ /dev/null @@ -1,65 +0,0 @@ -""" -py.py - Sopel Python Eval Plugin -Copyright 2008, Sean B. Palmer, inamidst.com -Licensed under the Eiffel Forum License 2. - -https://sopel.chat -""" -from __future__ import annotations - -from requests import get - -from sopel import plugin -from sopel.config import types -from sopel.tools.web import quote - - -class PySection(types.StaticSection): - oblique_instance = types.ValidatedAttribute( - 'oblique_instance', - default='https://oblique.sopel.chat/') - """The Oblique instance to use when evaluating Python expressions""" - - -def configure(config): - """ - | name | example | purpose | - | ---- | ------- | ------- | - | oblique_instance | https://oblique.sopel.chat/ | The Oblique instance to use when evaluating Python expressions (see ) | - """ - config.define_section('py', PySection) - config.py.configure_setting( - 'oblique_instance', - 'Enter the base URL of a custom Oblique instance (optional): ' - ) - - -def setup(bot): - bot.config.define_section('py', PySection) - - if not any( - bot.config.py.oblique_instance.startswith(prot) - for prot in ['http://', 'https://'] - ): - raise ValueError('Oblique instance URL must start with a protocol.') - - if not bot.config.py.oblique_instance.endswith('/'): - bot.config.py.oblique_instance += '/' - - -@plugin.command('py') -@plugin.output_prefix('[py] ') -@plugin.example('.py len([1,2,3])', '3', online=True, vcr=True) -def py(bot, trigger): - """Evaluate a Python expression.""" - query = trigger.group(2) - if not query: - bot.reply('What expression do you want me to evaluate?') - return - - uri = bot.config.py.oblique_instance + 'py/' - answer = get(uri + quote(query)).content.decode('utf-8') - if answer: - bot.say(answer) - else: - bot.reply('Sorry, no result.')