On Thu 21/01/2021 14:46, Stuart Henderson wrote:
> On 2021/01/18 02:52, Daniel Dickman wrote:
> > Below diff updates py-tornado to the latest version which is now
> > python3-only.
> >
> > This update is needed so jupyter-notebook can be updated to the latest
> > version.
>
> This broke www/apertium-apy;
>
> AttributeError: module 'tornado.web' has no attribute 'asynchronous'
>
> https://github.com/apertium/apertium-apy/pull/169
sthen@ found that www/apertium has been broken because of a recent
py-tornado update. A fix is available [0], which - at least - fixes the
build issue.
'make test' fails two tests (see attachment), one of which is related to
tornado. I'm not sure if these failures are new.
Comments/OK?
[0] https://github.com/apertium/apertium-apy/pull/149
diff --git Makefile Makefile
index 83769d98e18..933d60fef78 100644
--- Makefile
+++ Makefile
@@ -5,7 +5,7 @@ COMMENT = apertium text translation API in Python
DISTNAME = apertium-apy-${MODPY_EGG_VERSION}
MODPY_EGG_VERSION = 0.11.6
-REVISION = 0
+REVISION = 1
CATEGORIES = www
diff --git patches/patch-apertium_apy_gateway_py
patches/patch-apertium_apy_gateway_py
new file mode 100644
index 00000000000..f125693caa4
--- /dev/null
+++ patches/patch-apertium_apy_gateway_py
@@ -0,0 +1,43 @@
+$OpenBSD$
+
+tornado6 deprecated web.asynchronous; use gen.coroutine. Taken from
+https://github.com/apertium/apertium-apy/pull/149
+
+Index: apertium_apy/gateway.py
+--- apertium_apy/gateway.py.orig
++++ apertium_apy/gateway.py
+@@ -14,6 +14,7 @@ from collections import OrderedDict
+ import tornado
+ import tornado.httpclient
+ import tornado.httpserver
++import tornado.gen
+ import tornado.web
+ from tornado.options import enable_pretty_logging # type: ignore
+ from tornado.web import RequestHandler
+@@ -42,7 +43,7 @@ class RedirectRequestHandler(RequestHandler):
+ def initialize(self, balancer):
+ self.balancer = balancer
+
+- @tornado.web.asynchronous
++ @tornado.gen.coroutine
+ def get(self):
+ path = self.request.path
+ mode, lang_pair, per_word_modes = [None] * 3
+@@ -106,7 +107,7 @@ class RedirectRequestHandler(RequestHandler):
+ self.set_header(hname, hvalue)
+ self.finish()
+
+- @tornado.web.asynchronous
++ @tornado.gen.coroutine
+ def post(self):
+ self.get()
+
+@@ -120,7 +121,7 @@ class ListRequestHandler(apy.BaseHandler):
+ if callbacks:
+ self.callback = callbacks[0]
+
+- @tornado.web.asynchronous
++ @tornado.gen.coroutine
+ def get(self):
+ logging.info('Overriding list call: %s %s', self.request.path,
self.get_arguments('q'))
+ if self.request.path != '/listPairs' and self.request.path != '/list':
diff --git patches/patch-apertium_apy_handlers_base_py
patches/patch-apertium_apy_handlers_base_py
new file mode 100644
index 00000000000..98bc3dc00ca
--- /dev/null
+++ patches/patch-apertium_apy_handlers_base_py
@@ -0,0 +1,28 @@
+$OpenBSD$
+
+tornado6 deprecated web.asynchronous; use gen.coroutine. Taken from
+https://github.com/apertium/apertium-apy/pull/149
+
+Index: apertium_apy/handlers/base.py
+--- apertium_apy/handlers/base.py.orig
++++ apertium_apy/handlers/base.py
+@@ -5,6 +5,7 @@ import sys
+ from datetime import datetime
+
+ import tornado
++import tornado.gen
+ import tornado.web
+ from tornado.escape import utf8
+ from tornado.locks import Semaphore
+@@ -180,9 +181,9 @@ class BaseHandler(tornado.web.RequestHandler):
+ self.set_header('Access-Control-Allow-Methods', 'GET,POST,OPTIONS')
+ self.set_header('Access-Control-Allow-Headers', 'accept,
cache-control, origin, x-requested-with, x-file-name, content-type')
+
+- @tornado.web.asynchronous
++ @tornado.gen.coroutine
+ def post(self):
+- self.get()
++ yield self.get()
+
+ def options(self):
+ self.set_status(204)
diff --git patches/patch-apertium_apy_handlers_list_modes_py
patches/patch-apertium_apy_handlers_list_modes_py
new file mode 100644
index 00000000000..30d4782687a
--- /dev/null
+++ patches/patch-apertium_apy_handlers_list_modes_py
@@ -0,0 +1,22 @@
+$OpenBSD$
+
+tornado6 deprecated web.asynchronous; use gen.coroutine. Taken from
+https://github.com/apertium/apertium-apy/pull/149
+
+Index: apertium_apy/handlers/list_modes.py
+--- apertium_apy/handlers/list_modes.py.orig
++++ apertium_apy/handlers/list_modes.py
+@@ -1,11 +1,11 @@
+-import tornado.web
++import tornado.gen
+
+ from apertium_apy.handlers.base import BaseHandler
+ from apertium_apy.utils import to_alpha2_code
+
+
+ class ListHandler(BaseHandler):
+- @tornado.web.asynchronous
++ @tornado.gen.coroutine
+ def get(self):
+ query = self.get_argument('q', default='pairs')
+
diff --git patches/patch-apertium_apy_handlers_stats_py
patches/patch-apertium_apy_handlers_stats_py
new file mode 100644
index 00000000000..a8affc16feb
--- /dev/null
+++ patches/patch-apertium_apy_handlers_stats_py
@@ -0,0 +1,23 @@
+$OpenBSD$
+
+tornado6 deprecated web.asynchronous; use gen.coroutine. Taken from
+https://github.com/apertium/apertium-apy/pull/149
+
+Index: apertium_apy/handlers/stats.py
+--- apertium_apy/handlers/stats.py.orig
++++ apertium_apy/handlers/stats.py
+@@ -1,12 +1,12 @@
+ from datetime import datetime, timedelta
+
+-import tornado.web
++import tornado.gen
+
+ from apertium_apy.handlers.base import BaseHandler
+
+
+ class StatsHandler(BaseHandler):
+- @tornado.web.asynchronous
++ @tornado.gen.coroutine
+ def get(self):
+ num_requests = self.get_argument('requests', 1000)
+ try:
diff --git patches/patch-setup_py patches/patch-setup_py
new file mode 100644
index 00000000000..6a6f9e35c68
--- /dev/null
+++ patches/patch-setup_py
@@ -0,0 +1,14 @@
+$OpenBSD$
+
+Index: setup.py
+--- setup.py.orig
++++ setup.py
+@@ -52,7 +52,7 @@ setup(
+ 'Programming Language :: Python :: 3 :: Only',
+ ],
+ python_requires='>=3.5',
+- install_requires=['tornado>=4.2,<6'],
++ install_requires=['tornado>=4.2,<7'],
+ extras_require={
+ 'spelling': ['apertium-streamparser'],
+ 'suggestions': ['requests'],
running test
WARNING: Testing via this command is deprecated and will be removed in a future
version. Users looking for a generic test entry point independent of test
runner are encouraged to use tox.
running egg_info
writing apertium_apy.egg-info/PKG-INFO
writing dependency_links to apertium_apy.egg-info/dependency_links.txt
writing entry points to apertium_apy.egg-info/entry_points.txt
writing requirements to apertium_apy.egg-info/requires.txt
writing top-level names to apertium_apy.egg-info/top_level.txt
reading manifest file 'apertium_apy.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'apertium_apy.egg-info/SOURCES.txt'
running build_ext
[I 210121 18:56:46 apy:119] 0 pair modes found
[I 210121 18:56:46 apy:119] 0 analyzer modes found
[I 210121 18:56:46 apy:119] 0 generator modes found
[I 210121 18:56:46 apy:119] 0 tagger modes found
[I 210121 18:56:46 apy:119] 0 spell modes found
[I 210121 18:56:46 apy:119] 0 tokenise modes found
gateway (unittest.loader._FailedTest) ... ERROR
ERROR
======================================================================
ERROR: gateway (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: gateway
Traceback (most recent call last):
File "/usr/local/lib/python3.8/unittest/loader.py", line 154, in
loadTestsFromName
module = __import__(module_name)
File
"/tmp/ports/pobj/apertium-apy-0.11.6/apertium-apy-0.11.6/apertium_apy/gateway.py",
line 19, in <module>
from tornado.options import enable_pretty_logging # type: ignore
ImportError: cannot import name 'enable_pretty_logging' from 'tornado.options'
(/usr/local/lib/python3.8/site-packages/tornado/options.py)
======================================================================
ERROR: setUpModule (tests.test)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/ports/pobj/apertium-apy-0.11.6/apertium-apy-0.11.6/tests/test.py",
line 45, in setUpModule
server_handle = subprocess.Popen(coverage_cli_args +
[os.path.join(base_path, 'servlet.py')] + cli_args) # TODO: print only on
error?
File "/usr/local/lib/python3.8/subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/local/lib/python3.8/subprocess.py", line 1702, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'coverage'
----------------------------------------------------------------------
Ran 1 test in 0.010s
FAILED (errors=2)
Test failed: <unittest.runner.TextTestResult run=1 errors=2 failures=0>
error: Test failed: <unittest.runner.TextTestResult run=1 errors=2 failures=0>
*** Error 1 in . (/usr/ports/lang/python/python.port.mk:257 'do-test': @cd
/tmp/ports/pobj/apertium-apy-0.11.6/apertium-apy-0.11.6 && /usr/b...)