From 185ddf59214d980902c144072debc235193693f85b5ba1322a1ab4ebdace4e21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= Date: Thu, 11 Oct 2018 09:01:36 +0000 Subject: [PATCH] - Fix the dependencies to match up upstream setup.py - Run the tests - Add patch to build with python3.7: * python37.patch - Add missing dependency on pyamcrest - Remove unused patch lp1102685.diff OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-Twisted?expand=0&rev=62 --- lp1102685.diff | 34 ------- python-Twisted.changes | 10 ++ python-Twisted.spec | 44 ++++++--- python37.patch | 218 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 258 insertions(+), 48 deletions(-) delete mode 100644 lp1102685.diff create mode 100644 python37.patch diff --git a/lp1102685.diff b/lp1102685.diff deleted file mode 100644 index f0e4944..0000000 --- a/lp1102685.diff +++ /dev/null @@ -1,34 +0,0 @@ -=== modified file 'twisted/internet/gireactor.py' -Index: Twisted-15.0.0/twisted/internet/gireactor.py -=================================================================== ---- Twisted-15.0.0.orig/twisted/internet/gireactor.py -+++ Twisted-15.0.0/twisted/internet/gireactor.py -@@ -37,9 +37,12 @@ else: - from twisted.python.modules import theSystemPath - _pygtkcompatPresent = True - try: -- theSystemPath["gi.pygtkcompat"] -+ theSystemPath["pygtkcompat"] - except KeyError: -- _pygtkcompatPresent = False -+ try: -+ theSystemPath["gi.pygtkcompat"] -+ except KeyError: -+ _pygtkcompatPresent = False - - - # Modules that we want to ensure aren't imported if we're on older versions of -@@ -75,8 +78,11 @@ else: - # Newer version of gi, so we can try to initialize compatibility layer; if - # real pygtk was already imported we'll get ImportError at this point - # rather than segfault, so unconditional import is fine. -- import gi.pygtkcompat -- gi.pygtkcompat.enable() -+ try: -+ import pygtkcompat -+ except ImportError: -+ from gi import pygtkcompat -+ pygtkcompat.enable() - # At this point importing gobject will get you gi version, and importing - # e.g. gtk will either fail in non-segfaulty way or use gi version if user - # does gi.pygtkcompat.enable_gtk(). So, no need to prevent imports of diff --git a/python-Twisted.changes b/python-Twisted.changes index 6a9b614..bb1770d 100644 --- a/python-Twisted.changes +++ b/python-Twisted.changes @@ -1,3 +1,13 @@ +------------------------------------------------------------------- +Thu Oct 11 08:32:44 UTC 2018 - Tomáš Chvátal + +- Fix the dependencies to match up upstream setup.py +- Run the tests +- Add patch to build with python3.7: + * python37.patch +- Add missing dependency on pyamcrest +- Remove unused patch lp1102685.diff + ------------------------------------------------------------------- Tue Jul 17 19:42:41 UTC 2018 - dmueller@suse.com diff --git a/python-Twisted.spec b/python-Twisted.spec index 85ed781..c119164 100644 --- a/python-Twisted.spec +++ b/python-Twisted.spec @@ -12,7 +12,7 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # @@ -25,32 +25,46 @@ Release: 0 Summary: An asynchronous networking framework written in Python License: MIT Group: Development/Languages/Python -Url: http://twistedmatrix.com/ +URL: http://twistedmatrix.com/ Source: https://files.pythonhosted.org/packages/source/T/Twisted/%{modname}-%{version}.tar.bz2 -# PATCH-FIX-UPSTREAM -- https://twistedmatrix.com/trac/ticket/6280 -Patch0: lp1102685.diff -BuildRequires: %{python_module constantly} +Patch0: python37.patch +BuildRequires: %{python_module Automat >= 0.3.0} +BuildRequires: %{python_module PyHamcrest >= 1.9.0} +BuildRequires: %{python_module appdirs >= 1.4.0} +BuildRequires: %{python_module attrs >= 17.4.0} +BuildRequires: %{python_module constantly >= 15.1} +BuildRequires: %{python_module cryptography >= 1.5} BuildRequires: %{python_module devel} +BuildRequires: %{python_module hyperlink >= 17.1.1} BuildRequires: %{python_module hyperlink} -BuildRequires: %{python_module incremental} +BuildRequires: %{python_module idna >= 0.6} +BuildRequires: %{python_module incremental >= 16.10.1} BuildRequires: %{python_module pyOpenSSL} +BuildRequires: %{python_module pyasn1} +BuildRequires: %{python_module pyserial >= 3.0} BuildRequires: %{python_module pyserial} BuildRequires: %{python_module pytest} +BuildRequires: %{python_module python-subunit} +BuildRequires: %{python_module service_identity} BuildRequires: %{python_module setuptools} -BuildRequires: %{python_module zope.interface} +BuildRequires: %{python_module zope.interface >= 4.4.2} BuildRequires: fdupes BuildRequires: python-rpm-macros Requires: python-Automat >= 0.3.0 +Requires: python-PyHamcrest >= 1.9.0 +Requires: python-appdirs >= 1.4.0 +Requires: python-attrs >= 17.4.0 Requires: python-constantly >= 15.1 -Requires: python-cryptography +Requires: python-cryptography >= 1.5 Requires: python-hyperlink >= 17.1.1 +Requires: python-idna >= 0.6 Requires: python-incremental >= 16.10.1 Requires: python-pyOpenSSL >= 16.0.0 Requires: python-pyasn1 Requires: python-pyserial >= 3.0 +Requires: python-service_identity Requires: python-zope.interface >= 4.4.2 Recommends: python-service_identity -BuildRoot: %{_tmppath}/%{name}-%{version}-build %ifpython2 Provides: %{oldpython}-twisted = %{version} Obsoletes: %{oldpython}-twisted < %{version} @@ -93,8 +107,7 @@ This package contains the documentation for python-Twisted %prep %setup -q -n %{modname}-%{version} -#%%patch0 -p1 -#sed -i "1d" twisted/{mail/test/pop3testserver,trial/test/scripttest}.py +%patch0 -p1 %build %python_build @@ -106,7 +119,7 @@ install -dm0755 %{buildroot}%{_mandir}/man1/ install -m0644 docs/*/man/*.1 %{buildroot}%{_mandir}/man1/ # Install man pages find docs -type f -print0 | xargs -0 chmod a-x # Fix doc-file dependency by removing x flags #sed -i "s/\r//" docs/core/howto/listings/udp/{MulticastClient,MulticastServer}.py -%fdupes %{buildroot}%{_prefix} +%python_expand %fdupes %{buildroot}%{$python_sitelib} # Prepare for update-alternatives usage for p in twistd cftp ckeygen conch pyhtmlizer tkconch trial ; do @@ -122,12 +135,15 @@ done # no manpage for twist yet: %python_clone %{buildroot}%{_bindir}/twist +%check +export LANG=en_US.UTF-8 +export PATH=%{buildroot}%{_bindir}:$PATH +%python_expand PYTHONPATH=%{buildroot}%{$python_sitearch} $python -m twisted.trial twisted + %files -n %{name}-doc -%defattr(-,root,root,-) %doc docs/* %files %{python_files} -%defattr(-,root,root,-) %license LICENSE %doc NEWS.rst README.rst %{_bindir}/*-%{python_bin_suffix} diff --git a/python37.patch b/python37.patch new file mode 100644 index 0000000..b62b824 --- /dev/null +++ b/python37.patch @@ -0,0 +1,218 @@ +diff -up Twisted-18.4.0/src/twisted/conch/manhole.py.966 Twisted-18.4.0/src/twisted/conch/manhole.py +--- Twisted-18.4.0/src/twisted/conch/manhole.py.966 2018-03-26 10:19:31.000000000 +0200 ++++ Twisted-18.4.0/src/twisted/conch/manhole.py 2018-06-30 11:33:16.703721804 +0200 +@@ -19,9 +19,11 @@ from io import BytesIO + from twisted.conch import recvline + + from twisted.internet import defer +-from twisted.python.compat import _tokenize ++from twisted.python.compat import _tokenize, _get_async_param + from twisted.python.htmlizer import TokenPrinter + ++ ++ + class FileWrapper: + """ + Minimal write-file-like object. +@@ -151,8 +153,9 @@ class ManholeInterpreter(code.Interactiv + return failure + + +- def write(self, data, async=False): +- self.handler.addOutput(data, async) ++ def write(self, data, isAsync=None, **kwargs): ++ isAsync = _get_async_param(isAsync, **kwargs) ++ self.handler.addOutput(data, isAsync) + + + +@@ -237,14 +240,16 @@ class Manhole(recvline.HistoricRecvLine) + return not w.endswith(b'\n') and not w.endswith(b'\x1bE') + + +- def addOutput(self, data, async=False): +- if async: ++ def addOutput(self, data, isAsync=None, **kwargs): ++ isAsync = _get_async_param(isAsync, **kwargs) ++ if isAsync: + self.terminal.eraseLine() +- self.terminal.cursorBackward(len(self.lineBuffer) + len(self.ps[self.pn])) ++ self.terminal.cursorBackward(len(self.lineBuffer) + ++ len(self.ps[self.pn])) + + self.terminal.write(data) + +- if async: ++ if isAsync: + if self._needsNewline(): + self.terminal.nextLine() + +diff -up Twisted-18.4.0/src/twisted/mail/imap4.py.966 Twisted-18.4.0/src/twisted/mail/imap4.py +--- Twisted-18.4.0/src/twisted/mail/imap4.py.966 2018-03-26 10:19:31.000000000 +0200 ++++ Twisted-18.4.0/src/twisted/mail/imap4.py 2018-06-30 11:33:16.704721802 +0200 +@@ -42,7 +42,7 @@ from twisted.python.compat import ( + _bytesChr, unichr as chr, _b64decodebytes as decodebytes, + _b64encodebytes as encodebytes, + intToBytes, iterbytes, long, nativeString, networkString, unicode, +- _matchingString, _PY3 ++ _matchingString, _PY3, _get_async_param, + ) + from twisted.internet import interfaces + +@@ -1090,8 +1090,9 @@ class IMAP4Server(basic.LineReceiver, po + self._respond(b'NO', tag, message) + + +- def sendUntaggedResponse(self, message, async=False): +- if not async or (self.blocked is None): ++ def sendUntaggedResponse(self, message, isAsync=None, **kwargs): ++ isAsync = _get_async_param(isAsync, **kwargs) ++ if not isAsync or (self.blocked is None): + self._respond(message, None, None) + else: + self._queuedAsync.append(message) +@@ -2497,25 +2498,28 @@ class IMAP4Server(basic.LineReceiver, po + # + def modeChanged(self, writeable): + if writeable: +- self.sendUntaggedResponse(message=b'[READ-WRITE]', async=True) ++ self.sendUntaggedResponse(message=b'[READ-WRITE]', isAsync=True) + else: +- self.sendUntaggedResponse(message=b'[READ-ONLY]', async=True) ++ self.sendUntaggedResponse(message=b'[READ-ONLY]', isAsync=True) + + + def flagsChanged(self, newFlags): + for (mId, flags) in newFlags.items(): + encodedFlags = [networkString(flag) for flag in flags] + msg = intToBytes(mId) + ( +- b' FETCH (FLAGS (' +b' '.join(encodedFlags) + b'))' ++ b' FETCH (FLAGS (' + b' '.join(encodedFlags) + b'))' + ) +- self.sendUntaggedResponse(msg, async=True) ++ self.sendUntaggedResponse(msg, isAsync=True) + + + def newMessages(self, exists, recent): + if exists is not None: +- self.sendUntaggedResponse(intToBytes(exists) + b' EXISTS', async=True) ++ self.sendUntaggedResponse( ++ intToBytes(exists) + b' EXISTS', isAsync=True) + if recent is not None: +- self.sendUntaggedResponse(intToBytes(recent) + b' RECENT', async=True) ++ self.sendUntaggedResponse( ++ intToBytes(recent) + b' RECENT', isAsync=True) ++ + + + TIMEOUT_ERROR = error.TimeoutError() +diff -up Twisted-18.4.0/src/twisted/newsfragments/9384.bugfix.966 Twisted-18.4.0/src/twisted/newsfragments/9384.bugfix +--- Twisted-18.4.0/src/twisted/newsfragments/9384.bugfix.966 2018-06-30 11:33:16.682721845 +0200 ++++ Twisted-18.4.0/src/twisted/newsfragments/9384.bugfix 2018-06-30 11:33:16.706721798 +0200 +@@ -0,0 +1,2 @@ ++Syntax error under Python 3.7 fixed for twisted.conch.manhole and ++twisted.main.imap4. +diff -up Twisted-18.4.0/src/twisted/newsfragments/9384.removal.966 Twisted-18.4.0/src/twisted/newsfragments/9384.removal +--- Twisted-18.4.0/src/twisted/newsfragments/9384.removal.966 2018-06-30 11:33:16.706721798 +0200 ++++ Twisted-18.4.0/src/twisted/newsfragments/9384.removal 2018-06-30 11:33:16.706721798 +0200 +@@ -0,0 +1,4 @@ ++async keyword argument is deprecated in twisted.conch.manhole ++(ManholeInterpreter.write and Manhole.add) and in ++twisted.main.imap4.IMAP4Server.sendUntaggedResponse, ++isAsync keyword argument is introduced instead. +diff -up Twisted-18.4.0/src/twisted/python/compat.py.966 Twisted-18.4.0/src/twisted/python/compat.py +--- Twisted-18.4.0/src/twisted/python/compat.py.966 2018-04-13 15:15:32.000000000 +0200 ++++ Twisted-18.4.0/src/twisted/python/compat.py 2018-06-30 11:33:16.704721802 +0200 +@@ -31,6 +31,7 @@ import struct + import sys + import tokenize + from types import MethodType as _MethodType ++import warnings + + from io import TextIOBase, IOBase + +@@ -833,6 +834,34 @@ except ImportError: + from collections import Sequence + + ++def _get_async_param(isAsync=None, **kwargs): ++ """ ++ Provide a backwards-compatible way to get async param value that does not ++ cause a syntax error under Python 3.7. ++ ++ @param isAsync: isAsync param value (should default to None) ++ @type isAsync: L{bool} ++ ++ @param kwargs: keyword arguments of the caller (only async is allowed) ++ @type kwargs: L{dict} ++ ++ @raise TypeError: Both isAsync and async specified. ++ ++ @return: Final isAsync param value ++ @rtype: L{bool} ++ """ ++ if 'async' in kwargs: ++ warnings.warn( ++ "'async' keyword argument is deprecated, please use isAsync", ++ DeprecationWarning, stacklevel=2) ++ if isAsync is None and 'async' in kwargs: ++ isAsync = kwargs.pop('async') ++ if kwargs: ++ raise TypeError ++ return bool(isAsync) ++ ++ ++ + __all__ = [ + "reraise", + "execfile", +diff -up Twisted-18.4.0/src/twisted/test/test_compat.py.966 Twisted-18.4.0/src/twisted/test/test_compat.py +--- Twisted-18.4.0/src/twisted/test/test_compat.py.966 2018-03-26 10:19:31.000000000 +0200 ++++ Twisted-18.4.0/src/twisted/test/test_compat.py 2018-06-30 11:33:16.706721798 +0200 +@@ -16,7 +16,7 @@ from twisted.python.compat import ( + reduce, execfile, _PY3, _PYPY, comparable, cmp, nativeString, + networkString, unicode as unicodeCompat, lazyByteSlice, reraise, + NativeStringIO, iterbytes, intToBytes, ioType, bytesEnviron, iteritems, +- _coercedUnicode, unichr, raw_input, _bytesRepr ++ _coercedUnicode, unichr, raw_input, _bytesRepr, _get_async_param, + ) + from twisted.python.filepath import FilePath + from twisted.python.runtime import platform +@@ -921,3 +921,37 @@ class FutureBytesReprTests(unittest.Test + ``b`` to the returned repr on both Python 2 and 3. + """ + self.assertEqual(_bytesRepr(b'\x00'), "b'\\x00'") ++ ++ ++ ++class GetAsyncParamTests(unittest.SynchronousTestCase): ++ """ ++ Tests for L{twisted.python.compat._get_async_param} ++ """ ++ ++ def test_get_async_param(self): ++ """ ++ L{twisted.python.compat._get_async_param} uses isAsync by default, ++ or deprecated async keyword argument if isAsync is None. ++ """ ++ self.assertEqual(_get_async_param(isAsync=False), False) ++ self.assertEqual(_get_async_param(isAsync=True), True) ++ self.assertEqual( ++ _get_async_param(isAsync=None, **{'async': False}), False) ++ self.assertEqual( ++ _get_async_param(isAsync=None, **{'async': True}), True) ++ self.assertRaises(TypeError, _get_async_param, False, {'async': False}) ++ ++ ++ def test_get_async_param_deprecation(self): ++ """ ++ L{twisted.python.compat._get_async_param} raises a deprecation ++ warning if async keyword argument is passed. ++ """ ++ self.assertEqual( ++ _get_async_param(isAsync=None, **{'async': False}), False) ++ currentWarnings = self.flushWarnings( ++ offendingFunctions=[self.test_get_async_param_deprecation]) ++ self.assertEqual( ++ currentWarnings[0]['message'], ++ "'async' keyword argument is deprecated, please use isAsync")