code:
https://sources.debian.org/data/main/p/pyqt5/5.11.3+dfsg-1/debian/patches/public_sip.diff

From: Dmitry Shachnev <mitya57@debian.org>
Date: Tue, 3 Jul 2018 09:46:42 +0300
Subject: Use the public version of sip module

Per https://www.debian.org/doc/debian-policy/#convenience-copies-of-code.
---
 configure.py              | 2 +-
 designer/pluginloader.cpp | 2 +-
 qmlscene/pluginloader.cpp | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/configure.py b/configure.py
index 32d03a0..3c43a14 100644
--- a/configure.py
+++ b/configure.py
@@ -2440,7 +2440,7 @@ def get_sip_flags(target_config):
     the target configuration.
     """

-    sip_flags = ['-n', 'PyQt5.sip']
+    sip_flags = ['-n', 'sip']

     # If we don't check for signed interpreters, we exclude the 'VendorID'
     # feature
diff --git a/designer/pluginloader.cpp b/designer/pluginloader.cpp
index f41d391..3ca8b11 100644
--- a/designer/pluginloader.cpp
+++ b/designer/pluginloader.cpp
@@ -167,7 +167,7 @@ bool PyCustomWidgets::importPlugins(const QString &dir, const QStringList &plugi
     // Make sure we have sip.unwrapinstance.
     if (!sip_unwrapinstance)
     {
-        sip_unwrapinstance = getModuleAttr("PyQt5.sip", "unwrapinstance");
+        sip_unwrapinstance = getModuleAttr("sip", "unwrapinstance");

         if (!sip_unwrapinstance)
             return true;
diff --git a/qmlscene/pluginloader.cpp b/qmlscene/pluginloader.cpp
index e14b946..140e80c 100644
--- a/qmlscene/pluginloader.cpp
+++ b/qmlscene/pluginloader.cpp
@@ -412,9 +412,9 @@ PyObject *PyQt5QmlPlugin::getModuleAttr(const char *module, const char *attr)
 void PyQt5QmlPlugin::getSipAPI()
 {
 #if defined(SIP_USE_PYCAPSULE)
-    sip = (const sipAPIDef *)PyCapsule_Import("PyQt5.sip._C_API", 0);
+    sip = (const sipAPIDef *)PyCapsule_Import("sip._C_API", 0);
 #else
-    PyObject *c_api = getModuleAttr("PyQt5.sip", "_C_API");
+    PyObject *c_api = getModuleAttr("sip", "_C_API");

     if (c_api)
     {


code:
Always provide the same date and time in 'Py_GetBuildInfo'.
This is the information shown at the REPL and in 'sys.version'.
We cannot pass it in CPPFLAGS due to whitespace in the DATE string.

--- a/Modules/getbuildinfo.c
+++ b/Modules/getbuildinfo.c
@@ -4,6 +4,10 @@
 #include <stdio.h>
 #endif

+/* Deterministic date and time.  */
+#define DATE "Jan  1 1970"
+#define TIME "00:00:01"
+
 #ifndef DATE
 #ifdef __DATE__
 #define DATE __DATE__

license: mit


code:
SIGINT is ignored in the Guix build environment.

--- a/Lib/test/test_regrtest.py
+++ b/Lib/test/test_regrtest.py
@@ -399,6 +399,8 @@
         output = self.run_tests('--fromfile', filename)
         self.check_executed_tests(output, tests)

+    @unittest.skipIf(True,
+        "KeyboardInterrupts do not work in the build environment")
     def test_interrupted(self):
         code = TEST_INTERRUPTED
         test = self.create_test('sigint', code=code)
@@ -416,6 +418,8 @@
                  % (self.TESTNAME_REGEX, len(tests)))
         self.check_line(output, regex)

+    @unittest.skipIf(True,
+        "KeyboardInterrupts do not work in the build environment")
     def test_slow_interrupted(self):
         # Issue #25373: test --slowest with an interrupted test
         code = TEST_INTERRUPTED


code:
Make sure the build system honors C_INCLUDE_PATH and LIBRARY_PATH when
looking for headers and libraries.

--- Python-2.7.10/setup.py	2015-10-07 18:33:18.125153186 +0200
+++ Python-2.7.10/setup.py	2015-10-07 18:33:47.497347552 +0200
@@ -526,6 +526,14 @@ class PyBuildExt(build_ext):
             inc_dirs += ['/system/include', '/atheos/autolnk/include']
             inc_dirs += os.getenv('C_INCLUDE_PATH', '').split(os.pathsep)

+        # Always honor these variables.
+        if not cross_compiling:
+            lib_dirs += os.getenv('LIBRARY_PATH', '').split(os.pathsep)
+            inc_dirs += os.getenv('C_INCLUDE_PATH', '').split(os.pathsep)
+        else:
+            lib_dirs = os.getenv('CROSS_LIBRARY_PATH', '').split(os.pathsep)
+            inc_dirs = os.getenv('CROSS_CPATH', '').split(os.pathsep)
+
         # OSF/1 and Unixware have some stuff in /usr/ccs/lib (like -ldb)
         if host_platform in ['osf1', 'unixware7', 'openunix8']:
             lib_dirs += ['/usr/ccs/lib']


code:
Add all /gnu/store/ prefixes found in PYTHONPATH to the prefixes where
site-packages (and .pth files) are searched.

*** Python-2.7.11/Lib/site.py.orig	2016-10-17 23:27:23.746149690 +0200
--- Python-2.7.11/Lib/site.py	2016-10-17 23:44:51.930871644 +0200
***************
*** 65,70 ****
--- 65,82 ----

  # Prefixes for site-packages; add additional prefixes like /usr/local here
  PREFIXES = [sys.prefix, sys.exec_prefix]
+ # Guix: Add all /gnu/store-paths in PYTHONPATH--these are all
+ # "prefixes".  This is required to search .pth files in all python
+ # packages contained in /gnu/store which is required to make
+ # .pth-defined namespace packages work.
+ # This is necessary if the packages are not merged into a single
+ # `site-packages` directory (like when using `guix environment`) but
+ # listed in PYTHONPATH (like when running `guix build`).
+ for p in sys.path:
+     if p.startswith('/gnu/store/'):
+         PREFIXES.append(p[:p.find('/', 44)]) # find first pathsep after hash
+ del p
+
  # Enable per user site-packages directory
  # set it to False to disable the feature or True to force the feature
  ENABLE_USER_SITE = None


code:
Honor the 'SOURCE_DATE_EPOCH' environment variable to allow for
determinitic builds.

--- a/Lib/py_compile.py
+++ b/Lib/py_compile.py
@@ -105,7 +105,10 @@ def compile(file, cfile=None, dfile=None, doraise=False):
     """
     with open(file, 'U') as f:
         try:
-            timestamp = long(os.fstat(f.fileno()).st_mtime)
+            if 'SOURCE_DATE_EPOCH' in os.environ:
+                timestamp = long(os.environ['SOURCE_DATE_EPOCH'])
+            else:
+                timestamp = long(os.fstat(f.fileno()).st_mtime)
         except AttributeError:
             timestamp = long(os.stat(file).st_mtime)
         codestring = f.read()
diff --git a/Python/import.c b/Python/import.c
index e47ce63..7eecf9c 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -945,6 +945,11 @@ write_compiled_module(PyCodeObject *co, char *cpathname, struct stat *srcstat, t
     /* Now write the true mtime (as a 32-bit field) */
     fseek(fp, 4L, 0);
     assert(mtime <= 0xFFFFFFFF);
+    if (Py_GETENV("SOURCE_DATE_EPOCH") != NULL) {
+	const char *epoch = Py_GETENV("SOURCE_DATE_EPOCH");
+	mtime = atoi(epoch);
+    }
+
     PyMarshal_WriteLongToFile((long)mtime, fp, Py_MARSHAL_VERSION);
     fflush(fp);
     fclose(fp);


code:
Ensure memory accesses in the sha3 module are aligned on ARM as it causes
problems when running 32-bit code on a 64-bit kernel.

Patch taken from upstream bug report:
https://bugs.python.org/issue36515

--- a/Modules/_sha3/sha3module.c
+++ b/Modules/_sha3/sha3module.c
@@ -64,6 +64,12 @@
 #define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
 #endif

+/* Bus error on 32-bit ARM due to un-aligned memory accesses; 64-bit ARM
+ * doesn't complain but un-aligned memory accesses are sub-optimal */
+#if defined(__arm__) || defined(__aarch64__)
+#define NO_MISALIGNED_ACCESSES
+#endif
+
 /* mangle names */
 #define KeccakF1600_FastLoop_Absorb _PySHA3_KeccakF1600_FastLoop_Absorb
 #define Keccak_HashFinal _PySHA3_Keccak_HashFinal


code:
See the discussion about the issues fixed here at:
http://bugs.python.org/issue20868 .

diff --git a/Lib/ctypes/test/test_callbacks.py b/Lib/ctypes/test/test_callbacks.py
--- a/Lib/ctypes/test/test_callbacks.py
+++ b/Lib/ctypes/test/test_callbacks.py
@@ -3,6 +3,7 @@ import unittest
 from ctypes import *
 from ctypes.test import need_symbol
 import _ctypes_test
+import platform

 class Callbacks(unittest.TestCase):
     functype = CFUNCTYPE
@@ -176,6 +177,8 @@ class SampleCallbacksTestCase(unittest.TestCase):

         self.assertLess(diff, 0.01, "%s not less than 0.01" % diff)

+    @unittest.skipIf(platform.machine() in ['mips64'],
+                     "This test fails on this platform")
     def test_issue_8959_a(self):
         from ctypes.util import find_library
         libc_path = find_library("c")
diff --git a/Lib/ctypes/test/test_libc.py b/Lib/ctypes/test/test_libc.py
--- a/Lib/ctypes/test/test_libc.py
+++ b/Lib/ctypes/test/test_libc.py
@@ -2,6 +2,7 @@ import unittest

 from ctypes import *
 import _ctypes_test
+import platform

 lib = CDLL(_ctypes_test.__file__)

@@ -17,6 +18,8 @@ class LibTest(unittest.TestCase):
         import math
         self.assertEqual(lib.my_sqrt(2.0), math.sqrt(2.0))

+    @unittest.skipIf(platform.machine() in ['mips64'],
+                     "This test fails on this platform")
     def test_qsort(self):
         comparefunc = CFUNCTYPE(c_int, POINTER(c_char), POINTER(c_char))
         lib.my_qsort.argtypes = c_void_p, c_size_t, c_size_t, comparefunc
diff --git a/Lib/distutils/tests/test_archive_util.py b/Lib/distutils/tests/test_archive_util.py
--- a/Lib/distutils/tests/test_archive_util.py
+++ b/Lib/distutils/tests/test_archive_util.py
@@ -333,6 +333,7 @@ class ArchiveUtilTestCase(support.TempdirManager,
         self.assertEqual(os.path.basename(res), 'archive.tar.xz')
         self.assertEqual(self._tarinfo(res), self._created_files)

+    @unittest.skipIf(True, "getgrgid(0)[0] raises a KeyError on Guix")
     def test_make_archive_owner_group(self):
         # testing make_archive with owner and group, with various combinations
         # this works even if there's not gid/uid support
@@ -362,6 +363,7 @@ class ArchiveUtilTestCase(support.TempdirManager,

     @unittest.skipUnless(ZLIB_SUPPORT, "Requires zlib")
     @unittest.skipUnless(UID_GID_SUPPORT, "Requires grp and pwd support")
+    @unittest.skipIf(True, "getgrgid(0)[0] raises a KeyError on Guix")
     def test_tarfile_root_owner(self):
         tmpdir =  self._create_files()
         base_name = os.path.join(self.mkdtemp(), 'archive')
diff --git a/Lib/distutils/tests/test_sdist.py b/Lib/distutils/tests/test_sdist.py
--- a/Lib/distutils/tests/test_sdist.py
+++ b/Lib/distutils/tests/test_sdist.py
@@ -443,6 +443,7 @@ class SDistTestCase(BasePyPIRCCommandTestCase):
                      "The tar command is not found")
     @unittest.skipIf(find_executable('gzip') is None,
                      "The gzip command is not found")
+    @unittest.skipIf(True, "getgrgid(0)[0] raises a KeyError on Guix")
     def test_make_distribution_owner_group(self):
         # now building a sdist
         dist, cmd = self.get_cmd()
diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
--- a/Lib/test/_test_multiprocessing.py
+++ b/Lib/test/_test_multiprocessing.py
@@ -1473,6 +1473,7 @@ class _TestCondition(BaseTestCase):
         if pid is not None:
             os.kill(pid, signal.SIGINT)

+    @unittest.skipIf(True, "This fails for unknown reasons on Guix")
     def test_wait_result(self):
         if isinstance(self, ProcessesMixin) and sys.platform != 'win32':
             pid = os.getpid()
diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py
--- a/Lib/test/test_asyncio/test_base_events.py
+++ b/Lib/test/test_asyncio/test_base_events.py
@@ -1323,6 +1323,8 @@ class BaseEventLoopWithSelectorTests(test_utils.TestCase):
         self._test_create_connection_ip_addr(m_socket, False)

     @patch_socket
+    @unittest.skipUnless(support.is_resource_enabled('network'),
+                         'network is not enabled')
     def test_create_connection_service_name(self, m_socket):
         m_socket.getaddrinfo = socket.getaddrinfo
         sock = m_socket.socket.return_value
diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py
--- a/Lib/test/test_generators.py
+++ b/Lib/test/test_generators.py
@@ -34,6 +34,7 @@ class SignalAndYieldFromTest(unittest.TestCase):
         else:
             return "FAILED"

+    @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build environment')
     def test_raise_and_yield_from(self):
         gen = self.generator1()
         gen.send(None)
diff --git a/Lib/test/test_normalization.py b/Lib/test/test_normalization.py
--- a/Lib/test/test_normalization.py
+++ b/Lib/test/test_normalization.py
@@ -2,6 +2,7 @@ from test.support import open_urlresource
 import unittest

 from http.client import HTTPException
+from urllib.error import URLError
 import sys
 from unicodedata import normalize, unidata_version

@@ -43,6 +44,8 @@ class NormalizationTest(unittest.TestCase):
         except PermissionError:
             self.skipTest(f"Permission error when downloading {TESTDATAURL} "
                           f"into the test data directory")
+        except URLError:
+            self.skipTest("DNS lookups are not enabled.")
         except (OSError, HTTPException):
             self.fail(f"Could not retrieve {TESTDATAURL}")

diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py
--- a/Lib/test/test_pathlib.py
+++ b/Lib/test/test_pathlib.py
@@ -2134,8 +2134,7 @@ class PosixPathTest(_BasePathTest, unittest.TestCase):
         self.assertEqual(given, expect)
         self.assertEqual(set(p.rglob("FILEd*")), set())

-    @unittest.skipUnless(hasattr(pwd, 'getpwall'),
-                         'pwd module does not expose getpwall()')
+    @unittest.skipIf(True, "Guix builder home is '/' which causes trouble for these tests")
     def test_expanduser(self):
         P = self.cls
         support.import_module('pwd')
diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py
--- a/Lib/test/test_pdb.py
+++ b/Lib/test/test_pdb.py
@@ -1150,11 +1150,11 @@ def test_pdb_issue_20766():
     > <doctest test.test_pdb.test_pdb_issue_20766[0]>(6)test_function()
     -> print('pdb %d: %s' % (i, sess._previous_sigint_handler))
     (Pdb) continue
-    pdb 1: <built-in function default_int_handler>
+    pdb 1: Handlers.SIG_IGN
     > <doctest test.test_pdb.test_pdb_issue_20766[0]>(5)test_function()
     -> sess.set_trace(sys._getframe())
     (Pdb) continue
-    pdb 2: <built-in function default_int_handler>
+    pdb 2: Handlers.SIG_IGN
     """

diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py
--- a/Lib/test/test_regrtest.py
+++ b/Lib/test/test_regrtest.py
@@ -762,6 +762,7 @@ class ArgsTestCase(BaseTestCase):
         output = self.run_tests('--fromfile', filename)
         self.check_executed_tests(output, tests)

+    @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build environment.')
     def test_interrupted(self):
         code = TEST_INTERRUPTED
         test = self.create_test('sigint', code=code)
@@ -779,6 +780,7 @@ class ArgsTestCase(BaseTestCase):
                  % (self.TESTNAME_REGEX, len(tests)))
         self.check_line(output, regex)

+    @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build environment.')
     def test_slowest_interrupted(self):
         # Issue #25373: test --slowest with an interrupted test
         code = TEST_INTERRUPTED
diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py
--- a/Lib/test/test_resource.py
+++ b/Lib/test/test_resource.py
@@ -145,6 +145,7 @@ class ResourceTest(unittest.TestCase):

     @unittest.skipUnless(hasattr(resource, 'prlimit'), 'no prlimit')
     @support.requires_linux_version(2, 6, 36)
+    @unittest.skipIf(True, "Bug: the PermissionError is not raised")
     def test_prlimit(self):
         self.assertRaises(TypeError, resource.prlimit)
         self.assertRaises(ProcessLookupError, resource.prlimit,
diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
--- a/Lib/test/test_shutil.py
+++ b/Lib/test/test_shutil.py
@@ -1143,6 +1143,7 @@ class TestShutil(unittest.TestCase):
         self.assertRaises(ValueError, make_archive, base_name, 'xxx')

     @support.requires_zlib
+    @unittest.skipIf(True, "getgrgid(0)[0] raises a KeyError on Guix")
     def test_make_archive_owner_group(self):
         # testing make_archive with owner and group, with various combinations
         # this works even if there's not gid/uid support
@@ -1171,6 +1172,7 @@ class TestShutil(unittest.TestCase):

     @support.requires_zlib
+    @unittest.skipIf(True, "getgrgid(0)[0] raises a KeyError on Guix")
     @unittest.skipUnless(UID_GID_SUPPORT, "Requires grp and pwd support")
     def test_tarfile_root_owner(self):
         root_dir, base_dir = self._create_files()
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -875,6 +875,8 @@ class GeneralModuleTests(unittest.TestCase):
         if not fqhn in all_host_names:
             self.fail("Error testing host resolution mechanisms. (fqdn: %s, all: %s)" % (fqhn, repr(all_host_names)))

+    @unittest.skipUnless(support.is_resource_enabled('network'),
+                         'network is not enabled')
     def test_host_resolution(self):
         for addr in [support.HOSTv4, '10.0.0.1', '255.255.255.255']:
             self.assertEqual(socket.gethostbyname(addr), addr)
@@ -1004,6 +1006,8 @@ class GeneralModuleTests(unittest.TestCase):
             self.assertWarns(DeprecationWarning, socket.ntohs, k)
             self.assertWarns(DeprecationWarning, socket.htons, k)

+    @unittest.skipUnless(os.path.exists("/etc/services"),
+                         "getservbyname uses /etc/services, which is not in the chroot")
     def testGetServBy(self):
         eq = self.assertEqual
         # Find one service that exists, then check all the related interfaces.
@@ -1358,6 +1362,8 @@ class GeneralModuleTests(unittest.TestCase):
             raise
         self.assertRaises(TypeError, s.ioctl, socket.SIO_LOOPBACK_FAST_PATH, None)

+    @unittest.skipUnless(os.path.exists("/etc/gai.conf"),
+                         "getaddrinfo() will fail")
     def testGetaddrinfo(self):
         try:
             socket.getaddrinfo('localhost', 80)
@@ -1440,6 +1446,8 @@ class GeneralModuleTests(unittest.TestCase):
         # only IP addresses are allowed
         self.assertRaises(OSError, socket.getnameinfo, ('mail.python.org',0), 0)

+    @unittest.skipUnless(os.path.exists("/etc/gai.conf"),
+                         "getaddrinfo() will fail")
     @unittest.skipUnless(support.is_resource_enabled('network'),
                          'network is not enabled')
     def test_idna(self):
diff --git a/Lib/test/test_spwd.py b/Lib/test/test_spwd.py
--- a/Lib/test/test_spwd.py
+++ b/Lib/test/test_spwd.py
@@ -5,8 +5,7 @@ from test import support
 spwd = support.import_module('spwd')

-@unittest.skipUnless(hasattr(os, 'geteuid') and os.geteuid() == 0,
-                     'root privileges required')
+@unittest.skipUnless(os.path.exists("/etc/shadow"), 'spwd tests require /etc/shadow')
 class TestSpwdRoot(unittest.TestCase):

     def test_getspall(self):
@@ -56,8 +55,7 @@ class TestSpwdRoot(unittest.TestCase):
             self.assertRaises(TypeError, spwd.getspnam, bytes_name)

-@unittest.skipUnless(hasattr(os, 'geteuid') and os.geteuid() != 0,
-                     'non-root user required')
+@unittest.skipUnless(os.path.exists("/etc/shadow"), 'spwd tests require /etc/shadow')
 class TestSpwdNonRoot(unittest.TestCase):

     def test_getspnam_exception(self):
diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
--- a/Lib/test/test_tarfile.py
+++ b/Lib/test/test_tarfile.py
@@ -2509,9 +2509,12 @@ def root_is_uid_gid_0():
         import pwd, grp
     except ImportError:
         return False
-    if pwd.getpwuid(0)[0] != 'root':
-        return False
-    if grp.getgrgid(0)[0] != 'root':
+    try:
+        if pwd.getpwuid(0)[0] != 'root':
+            return False
+        if grp.getgrgid(0)[0] != 'root':
+            return False
+    except KeyError:
         return False
     return True

diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py
--- a/Lib/test/test_threading.py
+++ b/Lib/test/test_threading.py
@@ -1249,6 +1249,7 @@ class MiscTestCase(unittest.TestCase):

 class InterruptMainTests(unittest.TestCase):
+    @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build container.')
     def test_interrupt_main_subthread(self):
         # Calling start_new_thread with a function that executes interrupt_main
         # should raise KeyboardInterrupt upon completion.
@@ -1260,6 +1261,8 @@ class InterruptMainTests(unittest.TestCase):
             t.join()
         t.join()

+
+    @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build container.')
     def test_interrupt_main_mainthread(self):
         # Make sure that if interrupt_main is called in main thread that
         # KeyboardInterrupt is raised instantly.
diff --git a/Tools/scripts/run_tests.py b/Tools/scripts/run_tests.py
--- a/Tools/scripts/run_tests.py
+++ b/Tools/scripts/run_tests.py
@@ -39,7 +39,7 @@ def main(regrtest_args):
     if not any(is_multiprocess_flag(arg) for arg in regrtest_args):
         args.extend(['-j', '0'])  # Use all CPU cores
     if not any(is_resource_use_flag(arg) for arg in regrtest_args):
-        args.extend(['-u', 'all,-largefile,-audio,-gui'])
+        args.extend(['-u', 'all,-largefile,-audio,-gui,-network'])
     args.extend(regrtest_args)
     print(' '.join(args))
     if sys.platform == 'win32':


code:
Make sure the build system honors C_INCLUDE_PATH and LIBRARY_PATH when
looking for headers and libraries.

--- a/setup.py	2015-10-07 23:32:58.891329173 +0200
+++ b/setup.py	2015-10-07 23:46:29.653349924 +0200
@@ -676,15 +676,15 @@
         # if a file is found in one of those directories, it can
         # be assumed that no additional -I,-L directives are needed.
         if not CROSS_COMPILING:
-            self.lib_dirs = self.compiler.library_dirs + system_lib_dirs
-            self.inc_dirs = self.compiler.include_dirs + system_include_dirs
+            self.lib_dirs = os.getenv('LIBRARY_PATH', '').split(os.pathsep)
+            self.inc_dirs = os.getenv('C_INCLUDE_PATH', '').split(os.pathsep)
         else:
             # Add the sysroot paths. 'sysroot' is a compiler option used to
             # set the logical path of the standard system headers and
             # libraries.
-            self.lib_dirs = (self.compiler.library_dirs +
+            self.lib_dirs = (os.getenv('CROSS_LIBRARY_PATH', '').split(os.pathsep) +
                              sysroot_paths(('LDFLAGS', 'CC'), system_lib_dirs))
-            self.inc_dirs = (self.compiler.include_dirs +
+            self.inc_dirs = (os.getenv('CROSS_C_INCLUDE_PATH', '').split(os.pathsep) +
                              sysroot_paths(('CPPFLAGS', 'CFLAGS', 'CC'),
                                            system_include_dirs))


code:
diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
index 1474624..887f8ee 100644
--- a/Lib/test/_test_multiprocessing.py
+++ b/Lib/test/_test_multiprocessing.py
@@ -3801,6 +3801,7 @@ class _TestSharedMemory(BaseTestCase):
         sms.close()

     @unittest.skipIf(os.name != "posix", "not feasible in non-posix platforms")
+    @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
     def test_shared_memory_SharedMemoryServer_ignores_sigint(self):
         # bpo-36368: protect SharedMemoryManager server process from
         # KeyboardInterrupt signals.
diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py
index d41e94b..a1c15e7 100644
--- a/Lib/test/test_signal.py
+++ b/Lib/test/test_signal.py
@@ -78,6 +78,7 @@ class PosixTests(unittest.TestCase):
         self.assertLess(len(s), signal.NSIG)

     @unittest.skipUnless(sys.executable, "sys.executable required.")
+    @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
     def test_keyboard_interrupt_exit_code(self):
         """KeyboardInterrupt triggers exit via SIGINT."""
         process = subprocess.run(
@@ -128,6 +129,7 @@ class WindowsSignalTests(unittest.TestCase):
             signal.signal(7, handler)

     @unittest.skipUnless(sys.executable, "sys.executable required.")
+    @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
     def test_keyboard_interrupt_exit_code(self):
         """KeyboardInterrupt triggers an exit using STATUS_CONTROL_C_EXIT."""
         # We don't test via os.kill(os.getpid(), signal.CTRL_C_EVENT) here
@@ -1245,6 +1247,7 @@ class StressTest(unittest.TestCase):

 class RaiseSignalTest(unittest.TestCase):

+    @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
     def test_sigint(self):
         with self.assertRaises(KeyboardInterrupt):
             signal.raise_signal(signal.SIGINT)
--
2.23.0


code:
Fix CVE-2018-14647:
https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-14647
https://bugs.python.org/issue34623

Taken from upstream:
https://github.com/python/cpython/commit/f7666e828cc3d5873136473ea36ba2013d624fa1

diff --git Include/pyexpat.h Include/pyexpat.h
index 44259bf6d7..07020b5dc9 100644
--- Include/pyexpat.h
+++ Include/pyexpat.h
@@ -3,7 +3,7 @@

 /* note: you must import expat.h before importing this module! */

-#define PyExpat_CAPI_MAGIC  "pyexpat.expat_CAPI 1.0"
+#define PyExpat_CAPI_MAGIC  "pyexpat.expat_CAPI 1.1"
 #define PyExpat_CAPSULE_NAME "pyexpat.expat_CAPI"

 struct PyExpat_CAPI
@@ -48,6 +48,8 @@ struct PyExpat_CAPI
     enum XML_Status (*SetEncoding)(XML_Parser parser, const XML_Char *encoding);
     int (*DefaultUnknownEncodingHandler)(
         void *encodingHandlerData, const XML_Char *name, XML_Encoding *info);
+    /* might be none for expat < 2.1.0 */
+    int (*SetHashSalt)(XML_Parser parser, unsigned long hash_salt);
     /* always add new stuff to the end! */
 };

diff --git Modules/_elementtree.c Modules/_elementtree.c
index 707ab2912b..53f05f937f 100644
--- Modules/_elementtree.c
+++ Modules/_elementtree.c
@@ -3261,6 +3261,11 @@ _elementtree_XMLParser___init___impl(XMLParserObject *self, PyObject *html,
         PyErr_NoMemory();
         return -1;
     }
+    /* expat < 2.1.0 has no XML_SetHashSalt() */
+    if (EXPAT(SetHashSalt) != NULL) {
+        EXPAT(SetHashSalt)(self->parser,
+                           (unsigned long)_Py_HashSecret.expat.hashsalt);
+    }

     if (target) {
         Py_INCREF(target);
diff --git Modules/pyexpat.c Modules/pyexpat.c
index 47c3e86c20..aa21d93c11 100644
--- Modules/pyexpat.c
+++ Modules/pyexpat.c
@@ -1887,6 +1887,11 @@ MODULE_INITFUNC(void)
     capi.SetStartDoctypeDeclHandler = XML_SetStartDoctypeDeclHandler;
     capi.SetEncoding = XML_SetEncoding;
     capi.DefaultUnknownEncodingHandler = PyUnknownEncodingHandler;
+#if XML_COMBINED_VERSION >= 20100
+    capi.SetHashSalt = XML_SetHashSalt;
+#else
+    capi.SetHashSalt = NULL;
+#endif

     /* export using capsule */
     capi_object = PyCapsule_New(&capi, PyExpat_CAPSULE_NAME, NULL);


code:
Do not fail test on runtime warning like: RuntimeWarning: coroutine 'noop2' was
never awaited. This could be related to
https://github.com/aio-libs/aiohttp/commit/60f01cca36b9f9d8d35dd351384eaae2f8fd0d4b,
which does not fix this issue though.

--- a/aiohttp/pytest_plugin.py	2019-10-09 18:52:31.000000000 +0200
+++ b/aiohttp/pytest_plugin.py	2020-03-05 08:35:48.230396025 +0100
@@ -120,15 +120,6 @@
     """
     with warnings.catch_warnings(record=True) as _warnings:
         yield
-        rw = ['{w.filename}:{w.lineno}:{w.message}'.format(w=w)
-              for w in _warnings  # type: ignore
-              if w.category == RuntimeWarning]
-        if rw:
-            raise RuntimeError('{} Runtime Warning{},\n{}'.format(
-                len(rw),
-                '' if len(rw) == 1 else 's',
-                '\n'.join(rw)
-            ))

 @contextlib.contextmanager
--- a/tests/test_pytest_plugin.py	2020-03-05 09:26:58.502284893 +0100
+++ a/tests/test_pytest_plugin.py	2020-03-05 09:27:06.074284619 +0100
@@ -170,7 +170,7 @@
     expected_outcomes = (
         {'failed': 0, 'passed': 2}
         if IS_PYPY and bool(os.environ.get('PYTHONASYNCIODEBUG'))
-        else {'failed': 1, 'passed': 1}
+        else {'failed': 0, 'passed': 2}
     )
     """Under PyPy "coroutine 'foobar' was never awaited" does not happen."""
     result.assert_outcomes(**expected_outcomes)


code:
Compatibility with Python 3.8, see upstream issue
https://github.com/rbarrois/aionotify/pull/15

diff --git a/setup.py b/setup.py
index 21a554f..094de64 100755
--- a/setup.py
+++ b/setup.py
@@ -40,7 +40,7 @@ setup(
     setup_requires=[
     ],
     tests_require=[
-        'asynctest',
+        'asynctest; python_version<"3.8"',
     ],
     classifiers=[
         "Development Status :: 4 - Beta",
diff --git a/tests/test_usage.py b/tests/test_usage.py
index f156291..0476ff1 100644
--- a/tests/test_usage.py
+++ b/tests/test_usage.py
@@ -8,7 +8,11 @@ import os.path
 import tempfile
 import unittest

-import asynctest
+try:
+    testBase = unittest.IsolatedAsyncioTestCase
+except AttributeError:
+    import asynctest
+    testBase = asynctest.TestCase

 import aionotify

@@ -25,11 +29,13 @@ if AIODEBUG:
 TESTDIR = os.environ.get('AIOTESTDIR') or os.path.join(os.path.dirname(__file__), 'testevents')

-class AIONotifyTestCase(asynctest.TestCase):
+class AIONotifyTestCase(testBase):
     forbid_get_event_loop = True
     timeout = 3

     def setUp(self):
+        if not getattr (self, 'loop', None):
+            self.loop = asyncio.get_event_loop()
         if AIODEBUG:
             self.loop.set_debug(True)
         self.watcher = aionotify.Watcher()


code:
Upstream commit fixing testcases for fish>=3.1, see
https://github.com/kislyuk/argcomplete/commit/08bfc8a788e8081515d733e67be026d051c726f7

diff --git a/test/test.py b/test/test.py
index e91352b..2c34806 100755
--- a/test/test.py
+++ b/test/test.py
@@ -28,6 +28,8 @@

 BASH_VERSION = subprocess.check_output(['bash', '-c', 'echo $BASH_VERSION']).decode()
 BASH_MAJOR_VERSION = int(BASH_VERSION.split('.')[0])
+FISH_VERSION_STR = subprocess.check_output(['fish', '-c', 'echo -n $FISH_VERSION']).decode()
+FISH_VERSION_TUPLE = tuple(int(x) for x in FISH_VERSION_STR.split('.'))

 class TempDir(object):
@@ -1258,8 +1260,11 @@ class TestFish(_TestSh, unittest.TestCase):
     expected_failures = [
         'test_parse_special_characters',
         'test_comp_point',
-        'test_special_characters_double_quoted'
     ]
+    if FISH_VERSION_TUPLE < (3, 1):
+        expected_failures.extend([
+            'test_special_characters_double_quoted'
+        ])

     skipped = [
         'test_single_quotes_in_single_quotes',


code:
Patch taken from the Debian package for python-axolotl-0.1.39.
See <https://bugs.gnu.org/29415>.

Description: Removes IV paramenter from AES constructor, since it is not necessary for ctr mode.
Author: Josue Ortega <josue@debian.org>
Last-Update: 2017-04-13

--- a/axolotl/sessioncipher.py
+++ b/axolotl/sessioncipher.py
@@ -228,13 +228,7 @@
         # counterint = struct.unpack(">L", counterbytes)[0]
         # counterint = int.from_bytes(counterbytes, byteorder='big')
         ctr = Counter.new(128, initial_value=counter)
-
-        # cipher = AES.new(key, AES.MODE_CTR, counter=ctr)
-        ivBytes = bytearray(16)
-        ByteUtil.intToByteArray(ivBytes, 0, counter)
-
-        cipher = AES.new(key, AES.MODE_CTR, IV=bytes(ivBytes), counter=ctr)
-
+        cipher = AES.new(key, AES.MODE_CTR, counter=ctr)
         return cipher


code:
--- cairocffi-0.8.0/cairocffi/__init__.py.orig	2018-07-16 11:00:59.075664158 +0200
+++ cairocffi-0.8.0/cairocffi/__init__.py	2018-07-16 17:09:42.471958015 +0200
@@ -35,6 +35,7 @@
                         return lib
             except OSError:
                 pass
+        return ffi.dlopen(name)
     raise OSError("dlopen() failed to load a library: %s" % ' / '.join(names))


code:
From 16fbc38f13e435b4e3e1a37d706e64e05bad4691 Mon Sep 17 00:00:00 2001
From: Leo Famulari <leo@famulari.name>
Date: Tue, 10 Nov 2015 23:09:24 -0500
Subject: [PATCH] patch build to use setuptools

---
 setup.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/setup.py b/setup.py
index c6d57a6..27bf260 100644
--- a/setup.py
+++ b/setup.py
@@ -12,7 +12,12 @@
 # http://opensource.org/licenses/BSD-3-Clause
 import os
 import sys
-from distutils.core import setup
+
+try:
+    from setuptools import setup
+except ImportError:
+    from distutils.core import setup
+
 # a simple import wouldn't work if we moved towards a package with __init__
 from _version import __version__

--
2.6.2


code:
Patch taken from https://bugs.python.org/issue22724 and augmented with
following Nix patch
https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/interpreters/python/cpython/2.7/cross-compile.patch
to fix the whole cross-compilation circus.

---
 Makefile.pre.in | 14 +++++++-------
 configure       |  5 ++++-
 setup.py        |  9 ++++++---
 3 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/Makefile.pre.in b/Makefile.pre.in
index 2a14f3323b..6239fc32fc 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -492,7 +492,7 @@ $(BUILDPYTHON):	Modules/python.o $(LIBRARY) $(LDLIBRARY)
 			$(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST)

 platform: $(BUILDPYTHON) pybuilddir.txt
-	$(RUNSHARED) $(PYTHON_FOR_BUILD) -c 'import sys ; from sysconfig import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform
+	$(RUNSHARED) $(PY_BUILD_ENVIRON) $(PYTHON_FOR_BUILD) -c 'import sys ; from sysconfig import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform

 # Create build directory and generate the sysconfig build-time data there.
 # pybuilddir.txt contains the name of the build dir and is used for
@@ -503,7 +503,7 @@ platform: $(BUILDPYTHON) pybuilddir.txt
 # or removed in case of failure.
 pybuilddir.txt: $(BUILDPYTHON)
 	@echo "none" > ./pybuilddir.txt
-	$(RUNSHARED) $(PYTHON_FOR_BUILD) -S -m sysconfig --generate-posix-vars ;\
+	$(RUNSHARED) $(PY_BUILD_ENVIRON) $(PYTHON_FOR_BUILD) -S -m sysconfig --generate-posix-vars ;\
 	if test $$? -ne 0 ; then \
 		echo "generate-posix-vars failed" ; \
 		rm -f ./pybuilddir.txt ; \
@@ -525,7 +525,7 @@ sharedmods: $(BUILDPYTHON) pybuilddir.txt Modules/_math.o
 	esac; \
 	$(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \
 		_TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \
-		$(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build
+		$(PY_BUILD_ENVIRON) $(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build

 # Build static library
 # avoid long command lines, same as LIBRARY_OBJS
@@ -928,7 +928,7 @@ install:	@FRAMEWORKINSTALLFIRST@ commoninstall bininstall maninstall @FRAMEWORKI
 			upgrade) ensurepip="--upgrade" ;; \
 			install|*) ensurepip="" ;; \
 		esac; \
-		$(RUNSHARED) $(PYTHON_FOR_BUILD) -m ensurepip \
+		$(RUNSHARED) $(PY_BUILD_ENVIRON) $(PYTHON_FOR_BUILD) -m ensurepip \
 			$$ensurepip --root=$(DESTDIR)/ ; \
 	fi

@@ -939,7 +939,7 @@ altinstall:	commoninstall
 			upgrade) ensurepip="--altinstall --upgrade --no-default-pip" ;; \
 			install|*) ensurepip="--altinstall --no-default-pip" ;; \
 		esac; \
-		$(RUNSHARED) $(PYTHON_FOR_BUILD) -m ensurepip \
+		$(RUNSHARED) $(PY_BUILD_ENVIRON) $(PYTHON_FOR_BUILD) -m ensurepip \
 			$$ensurepip --root=$(DESTDIR)/ ; \
 	fi

@@ -1270,7 +1270,7 @@ libainstall:	@DEF_MAKE_RULE@ python-config
 # Install the dynamically loadable modules
 # This goes into $(exec_prefix)
 sharedinstall: sharedmods
-	$(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/setup.py install \
+	$(RUNSHARED) $(PY_BUILD_ENVIRON) $(PYTHON_FOR_BUILD) $(srcdir)/setup.py install \
 	   	--prefix=$(prefix) \
 		--install-scripts=$(BINDIR) \
 		--install-platlib=$(DESTSHARED) \
@@ -1344,7 +1344,7 @@ frameworkinstallextras:
 # This installs a few of the useful scripts in Tools/scripts
 scriptsinstall:
 	SRCDIR=$(srcdir) $(RUNSHARED) \
-	$(PYTHON_FOR_BUILD) $(srcdir)/Tools/scripts/setup.py install \
+	$(PY_BUILD_ENVIRON) $(PYTHON_FOR_BUILD) $(srcdir)/Tools/scripts/setup.py install \
 	--prefix=$(prefix) \
 	--install-scripts=$(BINDIR) \
 	--root=$(DESTDIR)/
diff --git a/configure b/configure
index 67300fe2b6..6050f588c5 100755
--- a/configure
+++ b/configure
@@ -741,6 +741,7 @@ CONFIG_ARGS
 SOVERSION
 VERSION
 PYTHON_FOR_BUILD
+PY_BUILD_ENVIRON
 PYTHON_FOR_REGEN
 host_os
 host_vendor
@@ -2964,7 +2965,8 @@ $as_echo_n "checking for python interpreter for cross build... " >&6; }
 	fi
         { $as_echo "$as_me:${as_lineno-$LINENO}: result: $interp" >&5
 $as_echo "$interp" >&6; }
-	PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/$(PLATDIR) '$interp
+	PY_BUILD_ENVIRON='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/$(PLATDIR)'
+	PYTHON_FOR_BUILD=$interp
     fi
 elif test "$cross_compiling" = maybe; then
     as_fn_error $? "Cross compiling required --host=HOST-TUPLE and --build=ARCH" "$LINENO" 5
@@ -2974,6 +2976,7 @@ fi

+
 if test "$prefix" != "/"; then
     prefix=`echo "$prefix" | sed -e 's/\/$//g'`
 fi
diff --git a/setup.py b/setup.py
index cb47a2339c..472e7e2b26 100644
--- a/setup.py
+++ b/setup.py
@@ -497,8 +497,6 @@ class PyBuildExt(build_ext):
         if not cross_compiling:
             add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
             add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
-        if cross_compiling:
-            self.add_gcc_paths()
         self.add_multiarch_paths()

         # Add paths specified in the environment variables LDFLAGS and
@@ -556,7 +554,10 @@ class PyBuildExt(build_ext):
         # be assumed that no additional -I,-L directives are needed.
         inc_dirs = self.compiler.include_dirs[:]
         lib_dirs = self.compiler.library_dirs[:]
-        if not cross_compiling:
+        if cross_compiling:
+            inc_dirs = []
+            lib_dirs = []
+        else:
             for d in (
                 '/usr/include',
                 ):
@@ -621,6 +622,8 @@ class PyBuildExt(build_ext):
         # Some modules that are normally always on:
         #exts.append( Extension('_weakref', ['_weakref.c']) )

+        self.compiler.library_dirs = lib_dirs + [ '.' ]
+
         # array objects
         exts.append( Extension('array', ['arraymodule.c']) )

--
2.17.1


code:
We need one patch on top of 0.3.8 for compatibility with Werkzeug 1.0.

Taken from upstream:
https://github.com/flask-restful/flask-restful/commit/73376a488907af3042b52678ac4c23f8a8911e5b

diff --git a/tests/test_api.py b/tests/test_api.py
index f7f8e661..6795d362 100644
--- a/tests/test_api.py
+++ b/tests/test_api.py
@@ -445,7 +445,9 @@ def test_handle_non_api_error(self):

         resp = app.get("/foo")
         self.assertEquals(resp.status_code, 404)
-        self.assertEquals('text/html', resp.headers['Content-Type'])
+        # in newer versions of werkzeug this is `text/html; charset=utf8`
+        content_type, _, _ = resp.headers['Content-Type'].partition(';')
+        self.assertEquals('text/html', content_type)

     def test_non_api_error_404_catchall(self):
         app = Flask(__name__)
diff --git a/tests/test_reqparse.py b/tests/test_reqparse.py
index 2f1fbedf..9776f17c 100644
--- a/tests/test_reqparse.py
+++ b/tests/test_reqparse.py
@@ -2,9 +2,9 @@
 import unittest
 from mock import Mock, patch
 from flask import Flask
-from werkzeug import exceptions, MultiDict
+from werkzeug import exceptions
 from werkzeug.wrappers import Request
-from werkzeug.datastructures import FileStorage
+from werkzeug.datastructures import FileStorage, MultiDict
 from flask_restful.reqparse import Argument, RequestParser, Namespace
 import six
 import decimal


code:
The following patch, authored by Andreas Enge, looks for the flint include
files in the correct subdirectory.

diff -u -r python-flint-old/src/flint.pxd python-flint-new/src/flint.pxd
--- python-flint-old/src/flint.pxd	2019-03-19 10:26:11.055748626 +0100
+++ python-flint-new/src/flint.pxd	2019-03-19 10:35:23.269341203 +0100
@@ -27,7 +27,7 @@

 ctypedef long fmpz_struct

-cdef extern from "flint.h":
+cdef extern from "flint/flint.h":
     ctypedef void * flint_rand_t
     void flint_randinit(flint_rand_t state)
     void flint_randclear(flint_rand_t state)
@@ -35,7 +35,7 @@
     long flint_get_num_threads()
     void flint_cleanup()

-cdef extern from "nmod_vec.h":
+cdef extern from "flint/nmod_vec.h":
     ctypedef struct nmod_t:
        mp_limb_t n
        mp_limb_t ninv
@@ -47,7 +47,7 @@
     mp_limb_t nmod_mul(mp_limb_t a, mp_limb_t b, nmod_t mod)
     mp_limb_t nmod_div(mp_limb_t a, mp_limb_t b, nmod_t mod)

-cdef extern from "nmod_poly.h":
+cdef extern from "flint/nmod_poly.h":
     ctypedef struct nmod_poly_struct:
         mp_ptr coeffs
         long alloc
@@ -129,7 +129,7 @@
     void nmod_poly_factor_init(nmod_poly_factor_t fac)
     void nmod_poly_factor_clear(nmod_poly_factor_t fac)

-cdef extern from "nmod_mat.h":
+cdef extern from "flint/nmod_mat.h":
     ctypedef struct nmod_mat_struct:
         mp_limb_t * entries
         long r
@@ -178,7 +178,7 @@
     long nmod_mat_rref(nmod_mat_t A)
     long nmod_mat_nullspace(nmod_mat_t X, nmod_mat_t A)

-cdef extern from "fmpz.h":
+cdef extern from "flint/fmpz.h":
     ctypedef fmpz_struct fmpz_t[1]
     int COEFF_IS_MPZ(fmpz_struct v)
     void fmpz_init(fmpz_t op)
@@ -268,7 +268,7 @@
     void fmpz_rfac_uiui(fmpz_t r, ulong x, ulong n)
     void fmpz_primorial(fmpz_t res, ulong n)

-cdef extern from "fmpz_factor.h":
+cdef extern from "flint/fmpz_factor.h":
     ctypedef struct fmpz_factor_struct:
         int sign
         fmpz_struct * p
@@ -280,7 +280,7 @@
     void fmpz_factor_clear(fmpz_factor_t factor)
     void fmpz_factor(fmpz_factor_t factor, fmpz_t n)

-cdef extern from "fmpz_poly.h":
+cdef extern from "flint/fmpz_poly.h":
     ctypedef struct fmpz_poly_struct:
         fmpz_struct * coeffs
         long alloc
@@ -390,14 +390,14 @@
     void fmpz_poly_cos_minpoly(fmpz_poly_t, ulong)
     void fmpz_poly_swinnerton_dyer(fmpz_poly_t, ulong)

-cdef extern from "fmpz_poly_factor.h":
+cdef extern from "flint/fmpz_poly_factor.h":
     void fmpz_poly_factor_init(fmpz_poly_factor_t fac)
     void fmpz_poly_factor_clear(fmpz_poly_factor_t fac)
     void fmpz_poly_factor_zassenhaus(fmpz_poly_factor_t fac, fmpz_poly_t G)
     void fmpz_poly_factor(fmpz_poly_factor_t fac, fmpz_poly_t G)
     void fmpz_poly_factor_squarefree(fmpz_poly_factor_t fac, fmpz_poly_t G)

-cdef extern from "fmpz_mat.h":
+cdef extern from "flint/fmpz_mat.h":
     ctypedef struct fmpz_mat_struct:
         fmpz_struct * entries
         long r
@@ -448,7 +448,7 @@
     void fmpz_mat_snf(fmpz_mat_t S, const fmpz_mat_t A)
     int fmpz_mat_is_in_snf(const fmpz_mat_t A)

-cdef extern from "fmpz_lll.h":
+cdef extern from "flint/fmpz_lll.h":
     ctypedef struct fmpz_lll_struct:
         double delta
         double eta
@@ -461,7 +461,7 @@
     void fmpz_lll(fmpz_mat_t B, fmpz_mat_t U, const fmpz_lll_t fl)

-cdef extern from "fmpq.h":
+cdef extern from "flint/fmpq.h":
     ctypedef struct fmpq_struct:
         fmpz_struct num
         fmpz_struct den
@@ -506,7 +506,7 @@
     void fmpq_next_signed_minimal(fmpq_t res, fmpq_t x)
     void fmpq_harmonic_ui(fmpq_t res, ulong n)

-cdef extern from "fmpq_poly.h":
+cdef extern from "flint/fmpq_poly.h":
     ctypedef struct fmpq_poly_struct:
         fmpz_struct * coeffs
         fmpz_t den
@@ -620,7 +620,7 @@
     void fmpq_poly_compose_series(fmpq_poly_t res, fmpq_poly_t poly1, fmpq_poly_t poly2, long n)
     void fmpq_poly_revert_series(fmpq_poly_t res, fmpq_poly_t poly1, long n)

-cdef extern from "fmpq_mat.h":
+cdef extern from "flint/fmpq_mat.h":
     ctypedef struct fmpq_mat_struct:
         fmpq_struct * entries
         long r
@@ -672,7 +672,7 @@
     long fmpq_mat_rref(fmpq_mat_t B, fmpq_mat_t A)
     void fmpq_mat_transpose(fmpq_mat_t B, fmpq_mat_t A)

-cdef extern from "arith.h":
+cdef extern from "flint/arith.h":
     void arith_number_of_partitions(fmpz_t res, ulong n)
     int arith_moebius_mu(fmpz_t n)
     void arith_divisor_sigma(fmpz_t v, fmpz_t n, ulong k)


code:
Fix build with Python 3.8 by also checking for python-3.X-embed.pc. Since
Python 3.8 the normal checks don't include the Python libraries anymore and
linking of the gst-python module would fail.

See also https://github.com/mesonbuild/meson/issues/5629
Fixes https://gitlab.freedesktop.org/gstreamer/gst-python/issues/28

Patch based on upstream commit:

https://gitlab.freedesktop.org/gstreamer/gst-python/-/commit/10707f437f2fc3632067c6a0efa4432f7ebaf362

diff --git a/meson.build b/meson.build
index 5f13b48..d7c7e66 100644
--- a/meson.build
+++ b/meson.build
@@ -23,7 +23,17 @@ pygobject_dep = dependency('pygobject-3.0', fallback: ['pygobject', 'pygobject_d

 pymod = import('python')
 python = pymod.find_installation(get_option('python'))
-python_dep = python.dependency(required : true)
+pythonver = python.language_version()
+if pythonver.version_compare('<3.0')
+   error('Python2 is not supported anymore, please port your code to python3 (@0@ specified)'.format(python.language_version()))
+endif
+
+# Workaround for https://github.com/mesonbuild/meson/issues/5629
+# https://gitlab.freedesktop.org/gstreamer/gst-python/issues/28
+python_dep = dependency('python-@0@-embed'.format(pythonver), version: '>=3', required: false)
+if not python_dep.found()
+  python_dep = python.dependency(required : true)
+endif

 python_abi_flags = python.get_variable('ABIFLAGS', '')
 pylib_loc = get_option('libpython-dir')
--
2.26.2


code:
Fix a test failure with recent versions of ... Pytest?  Python?

Taken from upstream:
https://github.com/keras-team/keras/commit/fe35050a8f18dc52304aa8da4e463eececa25240

diff --git a/tests/integration_tests/applications_test.py b/tests/integration_tests/applications_test.py
index 979f2f2abd6..6e3b57fa8e2 100644
--- a/tests/integration_tests/applications_test.py
+++ b/tests/integration_tests/applications_test.py
@@ -58,7 +58,8 @@ def _test_application_basic(app, last_dim=1000):
 def _test_application_notop(app, last_dim):
     output_shape = _get_output_shape(
         lambda: app(weights=None, include_top=False))
-    assert output_shape == (None, None, None, last_dim)
+    assert len(output_shape) == 4
+    assert output_shape[-1] == last_dim

 def test_mobilenet_v2_legacy_import():


code:
This patch fixes a crash in the libxml2 bindings for Python 3.x
that 'itstool' stumbles upon when processing UTF-8 data:

  https://issues.guix.gnu.org/issue/37468

Patch by Jan Matejek
from <https://bugzilla.opensuse.org/show_bug.cgi?id=1065270>.

--- libxml2-2.9.5.orig/python/libxml.c
+++ libxml2-2.9.5/python/libxml.c
@@ -1620,6 +1620,7 @@ libxml_xmlErrorFuncHandler(ATTRIBUTE_UNU
     PyObject *message;
     PyObject *result;
     char str[1000];
+    unsigned char *ptr = (unsigned char *)str;

 #ifdef DEBUG_ERROR
     printf("libxml_xmlErrorFuncHandler(%p, %s, ...) called\n", ctx, msg);
@@ -1636,12 +1637,20 @@ libxml_xmlErrorFuncHandler(ATTRIBUTE_UNU
 	    str[999] = 0;
         va_end(ap);

+#if PY_MAJOR_VERSION >= 3
+        /* Ensure the error string doesn't start at UTF8 continuation. */
+        while (*ptr && (*ptr & 0xc0) == 0x80)
+            ptr++;
+#endif
+
         list = PyTuple_New(2);
         PyTuple_SetItem(list, 0, libxml_xmlPythonErrorFuncCtxt);
         Py_XINCREF(libxml_xmlPythonErrorFuncCtxt);
-        message = libxml_charPtrConstWrap(str);
+        message = libxml_charPtrConstWrap(ptr);
         PyTuple_SetItem(list, 1, message);
         result = PyEval_CallObject(libxml_xmlPythonErrorFuncHandler, list);
+        /* Forget any errors caused in the error handler. */
+        PyErr_Clear();
         Py_XDECREF(list);
         Py_XDECREF(result);
     }


code:
Problem reported upstream:
https://github.com/linsomniac/python-memcached/issues/176

---
 memcache.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/memcache.py b/memcache.py
index 05b6657..b935681 100644
--- a/memcache.py
+++ b/memcache.py
@@ -1300,8 +1300,8 @@ class Client(threading.local):
             key = key[1]
         if key is None:
             raise Client.MemcachedKeyNoneError("Key is None")
-        if key is '':
-            if key_extra_len is 0:
+        if key == '':
+            if key_extra_len == 0:
                 raise Client.MemcachedKeyNoneError("Key is empty")

             #  key is empty but there is some other component to key
--
2.26.2


code:
Fix regex so that it works with Python 3.6.

See <https://docs.python.org/3/library/re.html#re.LOCALE>.

Copied from upstream bug report:
https://bugs.launchpad.net/python-mox3/+bug/1665266

From 05064cdb6ea7a16450c6beae2b6f7c6074212a69 Mon Sep 17 00:00:00 2001
From: Zac Medico <zmedico@gentoo.org>
Date: Thu, 16 Feb 2017 00:24:10 -0800
Subject: [PATCH] RegexTest: python3.6 compatibility

These fixes are backward-compatible with older python versions:

* raw strings fix invalid escape sequences
* flags=8 fixes ValueError: cannot use LOCALE flag with a str pattern
---
 mox3/tests/test_mox.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/mox3/tests/test_mox.py b/mox3/tests/test_mox.py
index 15ac565..3a1af17 100644
--- a/mox3/tests/test_mox.py
+++ b/mox3/tests/test_mox.py
@@ -312,12 +312,12 @@ class RegexTest(testtools.TestCase):
     def testReprWithoutFlags(self):
         """repr should return the regular expression pattern."""
         self.assertTrue(
-            repr(mox.Regex(r"a\s+b")) == "<regular expression 'a\s+b'>")
+            repr(mox.Regex(r"a\s+b")) == r"<regular expression 'a\s+b'>")

     def testReprWithFlags(self):
         """repr should return the regular expression pattern and flags."""
-        self.assertTrue(repr(mox.Regex(r"a\s+b", flags=4)) ==
-                        "<regular expression 'a\s+b', flags=4>")
+        self.assertTrue(repr(mox.Regex(r"a\s+b", flags=8)) ==
+                        r"<regular expression 'a\s+b', flags=8>")

 class IsTest(testtools.TestCase):
--
2.10.2


code:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0aa9fda2..a573170c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -22,7 +22,7 @@ option(BUILD_ONNX_PYTHON "Build Python binaries" OFF)
 option(ONNX_GEN_PB_TYPE_STUBS "Generate protobuf python type stubs" ON)
 option(ONNX_WERROR "Build with Werror" OFF)
 option(ONNX_COVERAGE "Build with coverage instrumentation" OFF)
-option(ONNX_BUILD_TESTS "Build ONNX C++ APIs Tests" OFF)
+option(ONNX_BUILD_TESTS "Build ONNX C++ APIs Tests" ON)
 option(ONNX_USE_LITE_PROTO "Use lite protobuf instead of full." OFF)
 option(ONNXIFI_ENABLE_EXT "Enable onnxifi extensions." OFF)
 if(NOT DEFINED ONNX_ML)
@@ -82,8 +82,10 @@ if(CMAKE_SYSTEM_NAME STREQUAL "AIX")
 endif()

 if(ONNX_BUILD_TESTS)
-  list(APPEND CMAKE_MODULE_PATH ${ONNX_ROOT}/cmake/external)
-  include(googletest)
+  find_package(GTest REQUIRED)
+  if(NOT GTest_FOUND)
+    message(FATAL_ERROR "cannot find googletest")
+  endif()
 endif()

 if((ONNX_USE_LITE_PROTO AND TARGET protobuf::libprotobuf-lite) OR ((NOT ONNX_USE_LITE_PROTO) AND TARGET protobuf::libprotobuf))
diff --git a/cmake/unittest.cmake b/cmake/unittest.cmake
index e29a93ff..ae146390 100644
--- a/cmake/unittest.cmake
+++ b/cmake/unittest.cmake
@@ -6,8 +6,8 @@ include(${ONNX_ROOT}/cmake/Utils.cmake)

 find_package(Threads)

-set(${UT_NAME}_libs ${googletest_STATIC_LIBRARIES})
-set(${ONNXIFI_TEST_DRIVER}_libs ${googletest_STATIC_LIBRARIES})
+set(${UT_NAME}_libs ${GTEST_LIBRARIES})
+set(${ONNXIFI_TEST_DRIVER}_libs ${GTEST_LIBRARIES})

 list(APPEND ${UT_NAME}_libs onnx)
 list(APPEND ${UT_NAME}_libs onnx_proto)
@@ -31,10 +31,10 @@ function(AddTest)
   list(REMOVE_DUPLICATES _UT_SOURCES)

   add_executable(${_UT_TARGET} ${_UT_SOURCES})
-  add_dependencies(${_UT_TARGET} onnx onnx_proto googletest)
+  add_dependencies(${_UT_TARGET} onnx onnx_proto)

   target_include_directories(${_UT_TARGET}
-                             PUBLIC ${googletest_INCLUDE_DIRS}
+                             PUBLIC ${GTEST_INCLUDE_DIRS}
                                     ${ONNX_INCLUDE_DIRS}
                                     ${PROTOBUF_INCLUDE_DIRS}
                                     ${ONNX_ROOT}


code:
Fix tests that are "hard coded" to expect x86_64 output by mocking the platform interface.

Submitted upstream:
https://github.com/pypa/packaging/pull/176

diff --git a/tests/test_tags.py b/tests/test_tags.py
index 1eacf68..0a3f1b4 100644
--- a/tests/test_tags.py
+++ b/tests/test_tags.py
@@ -435,37 +435,43 @@ class TestManylinuxPlatform:
         linux_platform = list(tags._linux_platforms(is_32bit=False))
         assert linux_platform == ["linux_x86_64"]

-    def test_linux_platforms_manylinux1(self, monkeypatch):
+    def test_linux_platforms_manylinux1(self, is_x86, monkeypatch):
         monkeypatch.setattr(
             tags, "_is_manylinux_compatible", lambda name, _: name == "manylinux1"
         )
-        if platform.system() != "Linux":
+        if platform.system() != "Linux" or not is_x86:
             monkeypatch.setattr(distutils.util, "get_platform", lambda: "linux_x86_64")
+            monkeypatch.setattr(platform, "machine", lambda: "x86_64")
         platforms = list(tags._linux_platforms(is_32bit=False))
-        assert platforms == ["manylinux1_x86_64", "linux_x86_64"]
+        arch = platform.machine()
+        assert platforms == ["manylinux1_" + arch, "linux_" + arch]

-    def test_linux_platforms_manylinux2010(self, monkeypatch):
+    def test_linux_platforms_manylinux2010(self, is_x86, monkeypatch):
         monkeypatch.setattr(
             tags, "_is_manylinux_compatible", lambda name, _: name == "manylinux2010"
         )
-        if platform.system() != "Linux":
+        if platform.system() != "Linux" or not is_x86:
             monkeypatch.setattr(distutils.util, "get_platform", lambda: "linux_x86_64")
+            monkeypatch.setattr(platform, "machine", lambda: "x86_64")
         platforms = list(tags._linux_platforms(is_32bit=False))
-        expected = ["manylinux2010_x86_64", "manylinux1_x86_64", "linux_x86_64"]
+        arch = platform.machine()
+        expected = ["manylinux2010_" + arch, "manylinux1_" + arch, "linux_" + arch]
         assert platforms == expected

-    def test_linux_platforms_manylinux2014(self, monkeypatch):
+    def test_linux_platforms_manylinux2014(self, is_x86, monkeypatch):
         monkeypatch.setattr(
             tags, "_is_manylinux_compatible", lambda name, _: name == "manylinux2014"
         )
-        if platform.system() != "Linux":
+        if platform.system() != "Linux" or not is_x86:
             monkeypatch.setattr(distutils.util, "get_platform", lambda: "linux_x86_64")
+            monkeypatch.setattr(platform, "machine", lambda: "x86_64")
         platforms = list(tags._linux_platforms(is_32bit=False))
+        arch = platform.machine()
         expected = [
-            "manylinux2014_x86_64",
-            "manylinux2010_x86_64",
-            "manylinux1_x86_64",
-            "linux_x86_64",
+            "manylinux2014_" + arch,
+            "manylinux2010_" + arch,
+            "manylinux1_" + arch,
+            "linux_" + arch,
         ]
         assert platforms == expected


code:
Remove this test to verify that things were modified since a certain time.

That assumption doesn't hold up when your environment doesn't have access to a
real clock and thinks it's living in 1970 :)

--- a/tests/test_fileapp.py    2015-04-23 13:48:37.000000000 -0700
+++ b/tests/test_fileapp.py	2016-02-22 19:20:08.332802417 -0800
@@ -223,8 +223,6 @@
                   status=304)
     res = app.get('/', headers={'If-None-Match': 'asdf'},
                   status=200)
-    res = app.get('/', headers={'If-Modified-Since': 'Sat, 1 Jan 2005 12:00:00 GMT'},
-                  status=200)
     res = app.get('/', headers={'If-Modified-Since': last_mod + '; length=100'},
                   status=304)
     res = app.get('/', headers={'If-Modified-Since': 'invalid date'},


code:
From 397463014fda3cdefe8d6c9d117ae16d878dc494 Mon Sep 17 00:00:00 2001
From: Michael Hudson-Doyle <michael.hudson@canonical.com>
Date: Tue, 25 Sep 2018 14:58:57 +1200
Subject: [PATCH] Keep compability with stdlib tokenize.py changes

https://github.com/python/cpython/commit/c4ef4896eac86a6759901c8546e26de4695a1389
is not yet part of any release of Python but has been backported to all
versions in Git (includeing 2.7!). It causes the tokenize.py module to
emit a synthetic NEWLINE token for files that do not in fact end with a
newline, which confuses pycodestyle's checks for blank lines at the end
of a file. Fortunately the synthetic NEWLINE tokens are easy to detect
(the token text is "").

Fixes #786
---
 pycodestyle.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pycodestyle.py b/pycodestyle.py
index 0d725d27..fbc3dca3 100755
--- a/pep8.py
+++ b/pep8.py
@@ -258,10 +258,10 @@ def trailing_blank_lines(physical_line, lines, line_number, total_lines):
     """
     if line_number == total_lines:
         stripped_last_line = physical_line.rstrip()
-        if not stripped_last_line:
+        if physical_line and not stripped_last_line:
             return 0, "W391 blank line at end of file"
         if stripped_last_line == physical_line:
-            return len(physical_line), "W292 no newline at end of file"
+            return len(lines[-1]), "W292 no newline at end of file"

 @register_check


code:
Fix CVE-2013-7459:

https://github.com/dlitz/pycrypto/issues/176
https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2013-7459

Copied from Debian:

https://anonscm.debian.org/cgit/collab-maint/python-crypto.git/commit/?id=0de2243837ed369a086f15c50cca2be85bdfab9d

Debian adapts this upstream commit:

https://github.com/dlitz/pycrypto/commit/8dbe0dc3eea5c689d4f76b37b93fe216cf1f00d4

From 8dbe0dc3eea5c689d4f76b37b93fe216cf1f00d4 Mon Sep 17 00:00:00 2001
From: Legrandin <helderijs@gmail.com>
Date: Sun, 22 Dec 2013 22:24:46 +0100
Subject: [PATCH] Throw exception when IV is used with ECB or CTR

The IV parameter is currently ignored when initializing
a cipher in ECB or CTR mode.

For CTR mode, it is confusing: it takes some time to see
that a different parameter is needed (the counter).

For ECB mode, it is outright dangerous.

This patch forces an exception to be raised.
---
 lib/Crypto/SelfTest/Cipher/common.py | 31 +++++++++++++++++++++++--------
 src/block_template.c                 | 11 +++++++++++
 2 files changed, 34 insertions(+), 8 deletions(-)

--- a/lib/Crypto/SelfTest/Cipher/common.py
+++ b/lib/Crypto/SelfTest/Cipher/common.py
@@ -239,19 +239,34 @@ class RoundtripTest(unittest.TestCase):
         return """%s .decrypt() output of .encrypt() should not be garbled""" % (self.module_name,)

     def runTest(self):
-        for mode in (self.module.MODE_ECB, self.module.MODE_CBC, self.module.MODE_CFB, self.module.MODE_OFB, self.module.MODE_OPENPGP):
+
+        ## ECB mode
+        mode = self.module.MODE_ECB
+        encryption_cipher = self.module.new(a2b_hex(self.key), mode)
+        ciphertext = encryption_cipher.encrypt(self.plaintext)
+        decryption_cipher = self.module.new(a2b_hex(self.key), mode)
+        decrypted_plaintext = decryption_cipher.decrypt(ciphertext)
+        self.assertEqual(self.plaintext, decrypted_plaintext)
+
+        ## OPENPGP mode
+        mode = self.module.MODE_OPENPGP
+        encryption_cipher = self.module.new(a2b_hex(self.key), mode, self.iv)
+        eiv_ciphertext = encryption_cipher.encrypt(self.plaintext)
+        eiv = eiv_ciphertext[:self.module.block_size+2]
+        ciphertext = eiv_ciphertext[self.module.block_size+2:]
+        decryption_cipher = self.module.new(a2b_hex(self.key), mode, eiv)
+        decrypted_plaintext = decryption_cipher.decrypt(ciphertext)
+        self.assertEqual(self.plaintext, decrypted_plaintext)
+
+        ## All other non-AEAD modes (but CTR)
+        for mode in (self.module.MODE_CBC, self.module.MODE_CFB, self.module.MODE_OFB):
             encryption_cipher = self.module.new(a2b_hex(self.key), mode, self.iv)
             ciphertext = encryption_cipher.encrypt(self.plaintext)
-
-            if mode != self.module.MODE_OPENPGP:
-                decryption_cipher = self.module.new(a2b_hex(self.key), mode, self.iv)
-            else:
-                eiv = ciphertext[:self.module.block_size+2]
-                ciphertext = ciphertext[self.module.block_size+2:]
-                decryption_cipher = self.module.new(a2b_hex(self.key), mode, eiv)
+            decryption_cipher = self.module.new(a2b_hex(self.key), mode, self.iv)
             decrypted_plaintext = decryption_cipher.decrypt(ciphertext)
             self.assertEqual(self.plaintext, decrypted_plaintext)

+
 class PGPTest(unittest.TestCase):
     def __init__(self, module, params):
         unittest.TestCase.__init__(self)
--- a/src/block_template.c
+++ b/src/block_template.c
@@ -170,6 +170,17 @@ ALGnew(PyObject *self, PyObject *args, P
 				"Key cannot be the null string");
 		return NULL;
 	}
+	if (IVlen != 0 && mode == MODE_ECB)
+	{
+		PyErr_Format(PyExc_ValueError, "ECB mode does not use IV");
+		return NULL;
+	}
+	if (IVlen != 0 && mode == MODE_CTR)
+	{
+		PyErr_Format(PyExc_ValueError,
+			"CTR mode needs counter parameter, not IV");
+		return NULL;
+	}
 	if (IVlen != BLOCK_SIZE && mode != MODE_ECB && mode != MODE_CTR)
 	{
 		PyErr_Format(PyExc_ValueError,


code:
Drop use of the deprecated time.clock which was removed in Python 3.8.

Adapted from upstream pull request:

https://github.com/dlitz/pycrypto/pull/296

diff --git a/lib/Crypto/Random/_UserFriendlyRNG.py b/lib/Crypto/Random/_UserFriendlyRNG.py
--- a/lib/Crypto/Random/_UserFriendlyRNG.py
+++ b/lib/Crypto/Random/_UserFriendlyRNG.py
@@ -73,8 +73,11 @@ class _EntropyCollector(object):
         t = time.time()
         self._time_es.feed(struct.pack("@I", int(2**30 * (t - floor(t)))))

-        # Add the fractional part of time.clock()
-        t = time.clock()
+        # Add the fractional part of time.process_time()
+        try:
+           t = time.process_time()
+        except AttributeError:
+           t = time.clock()
         self._clock_es.feed(struct.pack("@I", int(2**30 * (t - floor(t)))))


code:
This test incorrectly assumes that the root user is always available.
However, in the build environment, the root user is not available.
Note that because the original file distributed in the release on PyPi
has lines ending in CRLF, those are retained in the diff below.

--- a/pyfakefs/tests/fake_filesystem_test.py	1969-12-31 16:00:00.000000000 -0800
+++ b/pyfakefs/tests/fake_filesystem_test.py	1969-12-31 16:00:00.000000000 -0800
@@ -1021,15 +1021,6 @@
             self.assertEqual(self.path.expanduser('~'),
                              self.os.environ['HOME'].replace('/', '!'))

-    @unittest.skipIf(TestCase.is_windows or TestCase.is_cygwin,
-                     'only tested on unix systems')
-    def test_expand_root(self):
-        if sys.platform == 'darwin':
-            roothome = '!var!root'
-        else:
-            roothome = '!root'
-        self.assertEqual(self.path.expanduser('~root'), roothome)
-
     def test_getsize_path_nonexistent(self):
         file_path = 'foo!bar!baz'
         self.assertRaises(os.error, self.path.getsize, file_path)


code:
Fix test failure of test_XXX caused by upgrade of gpgme from 1.6.0 to
1.8.0:

======================================================================
FAIL: test_encrypt_to_signonly (tests.test_encrypt_decrypt.EncryptDecryptTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/guix-build-python2-pygpgme-0.3.drv-0/pygpgme-0.3/tests/test_encrypt_decrypt.py", line 185, in test_encrypt_to_signonly
    self.assertEqual(exc.args[0], gpgme.ERR_SOURCE_UNKNOWN)
AssertionError: 7 != 0

----------------------------------------------------------------------

Patch copied from the Debian package pygpgme-0.3-1.2:

https://sources.debian.net/src/pygpgme/0.3-1.2/debian/patches/0005-Fix-test-failures-with-pinentry.patch/

From: "Dr. Tobias Quathamer" <toddy@debian.org>
Date: Thu, 24 Nov 2016 12:20:54 +0100
Subject: Fix test failures with pinentry

---
 tests/test_encrypt_decrypt.py | 5 +++--
 tests/test_passphrase.py      | 2 ++
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/tests/test_encrypt_decrypt.py b/tests/test_encrypt_decrypt.py
index 21ae83e..05707e1 100644
--- a/tests/test_encrypt_decrypt.py
+++ b/tests/test_encrypt_decrypt.py
@@ -132,6 +132,7 @@ class EncryptDecryptTestCase(GpgHomeTestCase):
             os.write(fd, b'Symmetric passphrase\n')
         ctx = gpgme.Context()
         ctx.armor = True
+        ctx.pinentry_mode = gpgme.PINENTRY_MODE_LOOPBACK
         ctx.passphrase_cb = passphrase
         ctx.encrypt(None, 0, plaintext, ciphertext)
         self.assertTrue(
@@ -182,8 +183,8 @@ class EncryptDecryptTestCase(GpgHomeTestCase):
             ctx.encrypt([recipient], gpgme.ENCRYPT_ALWAYS_TRUST,
                         plaintext, ciphertext)
         except gpgme.GpgmeError as exc:
-            self.assertEqual(exc.args[0], gpgme.ERR_SOURCE_UNKNOWN)
-            self.assertEqual(exc.args[1], gpgme.ERR_GENERAL)
+            self.assertEqual(exc.args[0], gpgme.ERR_SOURCE_GPGME)
+            self.assertEqual(exc.args[1], gpgme.ERR_UNUSABLE_PUBKEY)
         else:
             self.fail('gpgme.GpgmeError not raised')

diff --git a/tests/test_passphrase.py b/tests/test_passphrase.py
index 35b3c59..05e6811 100644
--- a/tests/test_passphrase.py
+++ b/tests/test_passphrase.py
@@ -34,6 +34,7 @@ class PassphraseTestCase(GpgHomeTestCase):
         ctx = gpgme.Context()
         key = ctx.get_key('EFB052B4230BBBC51914BCBB54DCBBC8DBFB9EB3')
         ctx.signers = [key]
+        ctx.pinentry_mode = gpgme.PINENTRY_MODE_LOOPBACK
         plaintext = BytesIO(b'Hello World\n')
         signature = BytesIO()

@@ -55,6 +56,7 @@ class PassphraseTestCase(GpgHomeTestCase):
         ctx = gpgme.Context()
         key = ctx.get_key('EFB052B4230BBBC51914BCBB54DCBBC8DBFB9EB3')
         ctx.signers = [key]
+        ctx.pinentry_mode = gpgme.PINENTRY_MODE_LOOPBACK
         ctx.passphrase_cb = self.passphrase_cb
         plaintext = BytesIO(b'Hello World\n')
         signature = BytesIO()


code:
From 3cc41c05fad5601c0dd1832f64a6e9efca017727 Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Date: Mon, 1 Apr 2019 11:36:04 -0400
Subject: [PATCH] robottime: Honor the SOURCE_DATE_EPOCH environment variable.

Honoring the SOURCE_DATE_EPOCH environment variable allows building
the documentation using libdoc reproducibly, by setting the generated
timestamp to a fixed value.

For more background on reproducible builds and the SOURCE_DATE_EPOCH
environment variable, see:
https://reproducible-builds.org/specs/source-date-epoch/.

* src/robot/utils/robottime.py: import `os'.
(TimestampCache._get_epoch): Retrieve date from SOURCE_DATE_EPOCH if
it is defined, otherwise from time.time().
* utest/output/test_logger.py (TestLogger.test_write_to_one_logger):
Check for the existance of a timestamp attribute instead of checking
for its content as the later is easy to break when using the
SOURCE_DATE_EPOCH environment variable.
---
 src/robot/utils/robottime.py | 3 +++
 utest/output/test_logger.py  | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/robot/utils/robottime.py b/src/robot/utils/robottime.py
index 06432a4a6..91526f826 100644
--- a/src/robot/utils/robottime.py
+++ b/src/robot/utils/robottime.py
@@ -14,6 +14,7 @@
 #  limitations under the License.

 import datetime
+import os
 import time
 import re

@@ -395,6 +396,8 @@ class TimestampCache(object):

     # Seam for mocking
     def _get_epoch(self):
+        if os.getenv('SOURCE_DATE_EPOCH'):
+            return float(os.getenv('SOURCE_DATE_EPOCH'))
         return time.time()

     def _use_cache(self, secs, *separators):
diff --git a/utest/output/test_logger.py b/utest/output/test_logger.py
index 92fe6d77d..e980227aa 100644
--- a/utest/output/test_logger.py
+++ b/utest/output/test_logger.py
@@ -46,7 +46,7 @@ class TestLogger(unittest.TestCase):
         logger = LoggerMock(('Hello, world!', 'INFO'))
         self.logger.register_logger(logger)
         self.logger.write('Hello, world!', 'INFO')
-        assert_true(logger.msg.timestamp.startswith('20'))
+        assert_true(hasattr(logger.msg, 'timestamp'))

     def test_write_to_one_logger_with_trace_level(self):
         logger = LoggerMock(('expected message', 'TRACE'))
--
2.20.1


code:
Fix compatibility with Python 3.8.

Upstream issue: https://github.com/DirectXMan12/should_be/pull/5

diff -x '*.pyc' -Naur shouldbe-0.1.2/should_be/core.py shouldbe-0.1.2.patched/should_be/core.py
--- shouldbe-0.1.2/should_be/core.py	2019-03-06 07:38:22.000000000 +0100
+++ shouldbe-0.1.2.patched/should_be/core.py	2020-05-18 08:44:24.214664704 +0200
@@ -103,7 +103,7 @@
     return resf

-def buildCode(baseCode, argcount=None, kwonlyargcount=None,
+def buildCode(baseCode, argcount=None, posonlyargcount=None, kwonlyargcount=None,
               nlocals=None, stacksize=None, flags=None,
               code=None, consts=None, names=None,
               varnames=None, filename=None, name=None,
@@ -121,6 +121,24 @@
                         nlocals or baseCode.co_nlocals,
                         stacksize or baseCode.co_stacksize,
                         flags or baseCode.co_flags,
+                        code or baseCode.co_code,
+                        consts or baseCode.co_consts,
+                        names or baseCode.co_names,
+                        varnames or baseCode.co_varnames,
+                        filename or baseCode.co_filename,
+                        name or baseCode.co_name,
+                        firstlineno or baseCode.co_firstlineno,
+                        lnotab or baseCode.co_lnotab,
+                        freevars or baseCode.co_freevars,
+                        cellvars or baseCode.co_cellvars)
+    elif hasattr(baseCode, 'co_posonlyargcount'):
+        # Python 3.8
+        resc = CodeType(argcount or baseCode.co_argcount,
+                        posonlyargcount or baseCode.co_posonlyargcount,
+                        kwonlyargcount or baseCode.co_kwonlyargcount,
+                        nlocals or baseCode.co_nlocals,
+                        stacksize or baseCode.co_stacksize,
+                        flags or baseCode.co_flags,
                         code or baseCode.co_code,
                         consts or baseCode.co_consts,
                         names or baseCode.co_names,
diff -x '*.pyc' -Naur shouldbe-0.1.2/should_be/tests/test_container_mixin.py shouldbe-0.1.2.patched/should_be/tests/test_container_mixin.py
--- shouldbe-0.1.2/should_be/tests/test_container_mixin.py	2019-03-01 06:38:16.000000000 +0100
+++ shouldbe-0.1.2.patched/should_be/tests/test_container_mixin.py	2020-05-18 09:00:51.372531064 +0200
@@ -7,31 +7,31 @@
         self.lst = [1, 2, 3]

     def test_should_include_iter(self):
-        err_msg = (r'[a-zA-Z0-9.]+ should have included \[.+?\]'
+        err_msg = (r'[a-zA-Z0-9.()]+ should have included \[.+?\]'
                    r', but did not have items .+')
-        self.assertRaisesRegexp(AssertionError, err_msg,
+        self.assertRaisesRegex(AssertionError, err_msg,
                                 self.lst.should_include, [4])

         self.lst.should_include([1, 2, 3])

     def test_should_include_item(self):
-        err_msg = (r'[a-zA-Z0-9.]+ should have included .+?'
+        err_msg = (r'[a-zA-Z0-9.()]+ should have included .+?'
                    r', but did not')
-        self.assertRaisesRegexp(AssertionError, err_msg,
+        self.assertRaisesRegex(AssertionError, err_msg,
                                 self.lst.should_include, 4)

         self.lst.should_include(3)

     def test_shouldnt_include_iter(self):
         err_msg = 'should not have included'
-        self.assertRaisesRegexp(AssertionError, err_msg,
+        self.assertRaisesRegex(AssertionError, err_msg,
                                 self.lst.shouldnt_include, [2, 3])

         self.lst.shouldnt_include([4, 5])

     def test_shouldnt_include_item(self):
         err_msg = 'should not have included'
-        self.assertRaisesRegexp(AssertionError, err_msg,
+        self.assertRaisesRegex(AssertionError, err_msg,
                                 self.lst.shouldnt_include, 3)

         self.lst.shouldnt_include(4)


code:
https://github.com/testing-cabal/testtools/commit/29004731f9c480b7c44a9c2605513d50d372898f.patch
Should be fixed in the next release

From 29004731f9c480b7c44a9c2605513d50d372898f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
Date: Thu, 17 May 2018 17:52:26 +0200
Subject: [PATCH] Fix the tests on Python 3.7

Exception's repr got changed not to include trailing comma

Fixes https://github.com/testing-cabal/testtools/issues/270
---
 .travis.yml                                |  1 +
 testtools/tests/matchers/test_exception.py | 11 +++++++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 7f1f4db7..784608e0 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,6 +5,7 @@ python:
   - "3.4"
   - "3.5"
   - "3.6"
+  - "3.7-dev"
   - "pypy"

 install:
diff --git a/testtools/tests/matchers/test_exception.py b/testtools/tests/matchers/test_exception.py
index 6cd80af1..acd39252 100644
--- a/testtools/tests/matchers/test_exception.py
+++ b/testtools/tests/matchers/test_exception.py
@@ -32,15 +32,22 @@ class TestMatchesExceptionInstanceInterface(TestCase, TestMatchersInterface):
     matches_matches = [error_foo]
     matches_mismatches = [error_bar, error_base_foo]

+    if sys.version_info >= (3, 7):
+        # exception's repr has changed
+        _e = ''
+    else:
+        _e = ','
+
     str_examples = [
-        ("MatchesException(Exception('foo',))",
+        ("MatchesException(Exception('foo'%s))" % _e,
          MatchesException(Exception('foo')))
         ]
     describe_examples = [
         ("%r is not a %r" % (Exception, ValueError),
          error_base_foo,
          MatchesException(ValueError("foo"))),
-        ("ValueError('bar',) has different arguments to ValueError('foo',).",
+        ("ValueError('bar'%s) has different arguments to ValueError('foo'%s)."
+         % (_e, _e),
          error_bar,
          MatchesException(ValueError("foo"))),
         ]


code:
Fix test failure that occurs with recent versions of Flake8.

Taken from upstream:
https://github.com/Kozea/tinycss2/commit/6556604fb98c2153412384d6f0f705db2da1aa60

diff --git a/tinycss2/css-parsing-tests/make_color3_hsl.py b/tinycss2/css-parsing-tests/make_color3_hsl.py
index d1fd3a6..56fda0c 100644
--- a/tinycss2/css-parsing-tests/make_color3_hsl.py
+++ b/tinycss2/css-parsing-tests/make_color3_hsl.py
@@ -8,16 +8,17 @@ def trim(s):
 print('[')
 print(',\n'.join(
     '"hsl%s(%s, %s%%, %s%%%s)", [%s, %s, %s, %s]' % (
-        ('a' if a is not None else '', h,
-         trim(str(s / 10.)), trim(str(l / 10.)),
-         ', %s' % a if a is not None else '') +
+        ('a' if alpha is not None else '', hue,
+         trim(str(saturation / 10.)), trim(str(light / 10.)),
+         ', %s' % alpha if alpha is not None else '') +
         tuple(trim(str(round(v, 10)))
-              for v in colorsys.hls_to_rgb(h / 360., l / 1000., s / 1000.)) +
-        (a if a is not None else 1,)
+              for v in colorsys.hls_to_rgb(
+                hue / 360., light / 1000., saturation / 1000.)) +
+        (alpha if alpha is not None else 1,)
     )
-    for a in [None, 1, .2, 0]
-    for l in range(0, 1001, 125)
-    for s in range(0, 1001, 125)
-    for h in range(0, 360, 30)
+    for alpha in [None, 1, .2, 0]
+    for light in range(0, 1001, 125)
+    for saturation in range(0, 1001, 125)
+    for hue in range(0, 360, 30)
 ))
 print(']')


code:
Skip tests that fail with newer versions of Python.

Patch copied from Gentoo:

https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-python/unittest2/files/unittest2-1.1.0-python3.5-test.patch

diff --git a/unittest2/test/test_loader.py b/unittest2/test/test_loader.py
index 683f662..347eea5 100644
--- a/unittest2/test/test_loader.py
+++ b/unittest2/test/test_loader.py
@@ -509,6 +509,7 @@ class Test_TestLoader(unittest2.TestCase):
     #
     # What happens when an impossible name is given, relative to the provided
     # `module`?
+    @unittest.skipIf(sys.version_info[:2] >= (3, 5), "python 3.5 has problems here")
     def test_loadTestsFromName__relative_malformed_name(self):
         loader = unittest.TestLoader()

@@ -811,6 +812,7 @@ class Test_TestLoader(unittest2.TestCase):
     # TestCase or TestSuite instance."
     #
     # What happens when presented with an impossible module name?
+    @unittest.skipIf(sys.version_info[:2] >= (3, 5), "python 3.5 has problems here")
     def test_loadTestsFromNames__malformed_name(self):
         loader = unittest2.TestLoader()

@@ -918,6 +920,7 @@ class Test_TestLoader(unittest2.TestCase):
     # "The method optionally resolves name relative to the given module"
     #
     # What happens when presented with an impossible attribute name?
+    @unittest.skipIf(sys.version_info[:2] >= (3, 5), "python 3.5 has problems here")
     def test_loadTestsFromNames__relative_malformed_name(self):
         loader = unittest.TestLoader()


code:
--- a/setup.py	2017-09-12 01:22:06.273997788 +0200
+++ b/setup.py	2017-09-12 01:22:14.297918757 +0200
@@ -57,7 +57,7 @@
 # Both install and setup requires - because we read VERSION from within the
 # package, and the package also exports all the APIs.
 # six for compat helpers
-REQUIRES = ['argparse', 'six>=1.4', 'traceback2'],
+REQUIRES = ['six>=1.4', 'traceback2'],

 params = dict(
     name=NAME,


code:
Skip test that requires getaddrinfo(), which is not available in the build
environment.  This package uses a regexp for finding tests (see runner.py),
so using @unittest.skip does not work.

--- a/waitress/tests/test_adjustments.py
+++ b/waitress/tests/test_adjustments.py
@@ -185,22 +185,6 @@
     def test_bad_port(self):
         self.assertRaises(ValueError, self._makeOne, listen='127.0.0.1:test')

-    def test_service_port(self):
-        if WIN and PY2: # pragma: no cover
-            # On Windows and Python 2 this is broken, so we raise a ValueError
-            self.assertRaises(
-                ValueError,
-                self._makeOne,
-                listen='127.0.0.1:http',
-            )
-            return
-
-        inst = self._makeOne(listen='127.0.0.1:http 0.0.0.0:https')
-
-        bind_pairs = [sockaddr[:2] for (_, _, _, sockaddr) in inst.listen]
-
-        self.assertEqual(bind_pairs, [('127.0.0.1', 80), ('0.0.0.0', 443)])
-
     def test_dont_mix_host_port_listen(self):
         self.assertRaises(
             ValueError,


code:
From ca548da9ba78ddee90779051210e3e89185e4f7d Mon Sep 17 00:00:00 2001
From: Michel Alexandre Salim <michel@michel-slm.name>
Date: Mon, 15 Feb 2016 23:03:42 +0700
Subject: coverage-4.0a6 compatibility

coverage 4.0a6 no longer generates .coverage file, so use -f when
deleting .coverage to ensure deletion does not fail.
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'Makefile')

diff --git a/Makefile b/Makefile
index 7818f57..362c07f 100644
--- a/Makefile
+++ b/Makefile
@@ -23,7 +23,7 @@ fsck-larch.1: fsck-larch.1.in fsck-larch

 check:
 	python -m CoverageTestRunner --ignore-missing-from=without-tests
-	rm .coverage
+	rm -f .coverage
 	./insert-remove-test tempdir 100
 	rm -r tempdir larch.log
 	cmdtest tests
--
cgit v1.1


code:
Skip unicode docstring test, required when running on Python 2.

See <https://github.com/wolever/parameterized/issues/44>.

--- a/parameterized/test.py
+++ b/parameterized/test.py
@@ -284,11 +284,6 @@
             "        More" %(foo, )
         )

-    @parameterized.expand([param("foo")])
-    def test_unicode_docstring(self, foo):
-        u"""Döcumentation."""
-        self._assert_docstring(u"Döcumentation [with foo=%r]." %(foo, ))
-
     @parameterized.expand([param("foo", )])
     def test_default_values_get_correct_value(self, foo, bar=12):
         """Documentation"""


code:
From e5df32ffbf37481dbb6a70c4d4e7b7b9778c5549 Mon Sep 17 00:00:00 2001
From: "John (J5) Palmieri" <johnp@redhat.com>
Date: Sat, 13 Aug 2011 04:13:28 -0400
Subject: remove references to deprecated GI_INFO_TYPE_ERROR_DOMAIN

diff --git a/gi/pygi-info.c b/gi/pygi-info.c
index 8729e25..007b609 100644
--- a/gi/pygi-info.c
+++ b/gi/pygi-info.c
@@ -165,9 +165,6 @@ _pygi_info_new (GIBaseInfo *info)
         case GI_INFO_TYPE_CONSTANT:
             type = &PyGIConstantInfo_Type;
             break;
-        case GI_INFO_TYPE_ERROR_DOMAIN:
-            type = &PyGIErrorDomainInfo_Type;
-            break;
         case GI_INFO_TYPE_UNION:
             type = &PyGIUnionInfo_Type;
             break;
@@ -484,7 +481,6 @@ _pygi_g_type_info_size (GITypeInfo *type_info)
                 case GI_INFO_TYPE_INVALID:
                 case GI_INFO_TYPE_FUNCTION:
                 case GI_INFO_TYPE_CONSTANT:
-                case GI_INFO_TYPE_ERROR_DOMAIN:
                 case GI_INFO_TYPE_VALUE:
                 case GI_INFO_TYPE_SIGNAL:
                 case GI_INFO_TYPE_PROPERTY:
@@ -863,7 +859,6 @@ pygi_g_struct_info_is_simple (GIStructInfo *struct_info)
                     case GI_INFO_TYPE_INVALID:
                     case GI_INFO_TYPE_FUNCTION:
                     case GI_INFO_TYPE_CONSTANT:
-                    case GI_INFO_TYPE_ERROR_DOMAIN:
                     case GI_INFO_TYPE_VALUE:
                     case GI_INFO_TYPE_SIGNAL:
                     case GI_INFO_TYPE_PROPERTY:
--
cgit v0.10.1


code:
This test tries to send a KeyboardInterrupt, which does
not work in the build environment.

--- a/test_subprocess32.py	2017-03-06 22:21:49.334045485 +0100
+++ b/test_subprocess32.py	2017-03-06 22:22:02.490439949 +0100
@@ -1299,12 +1299,6 @@
         getattr(p, method)(*args)
         return p

-    def test_send_signal(self):
-        p = self._kill_process('send_signal', signal.SIGINT)
-        _, stderr = p.communicate()
-        self.assertIn('KeyboardInterrupt', stderr)
-        self.assertNotEqual(p.wait(), 0)
-
     def test_kill(self):
         p = self._kill_process('kill')
         _, stderr = p.communicate()


code:
From 75e5b70e6b5dcc4f2219992d7cffa462aa406af0 Mon Sep 17 00:00:00 2001
From: Paolo Bonzini <pbonzini@redhat.com>
Date: Tue, 28 Nov 2017 11:51:27 +0100
Subject: [PATCH] memfd: fix configure test
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit

Recent glibc added memfd_create in sys/mman.h.  This conflicts with
the definition in util/memfd.c:

    /builddir/build/BUILD/qemu-2.11.0-rc1/util/memfd.c:40:12: error: static declaration of memfd_create follows non-static declaration

Fix the configure test, and remove the sys/memfd.h inclusion since the
file actually does not exist---it is a typo in the memfd_create(2) man
page.

Cc: Marc-AndrÃ© Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 configure    | 2 +-
 util/memfd.c | 4 +---
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/configure b/configure
index 9c8aa5a..99ccc17 100755
--- a/configure
+++ b/configure
@@ -3923,7 +3923,7 @@ fi
 # check if memfd is supported
 memfd=no
 cat > $TMPC << EOF
-#include <sys/memfd.h>
+#include <sys/mman.h>

 int main(void)
 {
diff --git a/util/memfd.c b/util/memfd.c
index 4571d1a..412e94a 100644
--- a/util/memfd.c
+++ b/util/memfd.c
@@ -31,9 +31,7 @@

 #include "qemu/memfd.h"

-#ifdef CONFIG_MEMFD
-#include <sys/memfd.h>
-#elif defined CONFIG_LINUX
+#if defined CONFIG_LINUX && !defined CONFIG_MEMFD
 #include <sys/syscall.h>
 #include <asm/unistd.h>

--
1.8.3.1


code:
Make the library installable. Patch copied from pull request:

https://github.com/nayuki/QR-Code-generator/pull/72

From 1625fc1665e1f83eb73c0f5670dcfda96dc0b3e4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= <tchvatal@suse.com>
Date: Tue, 3 Dec 2019 11:57:24 +0100
Subject: [PATCH 1/7] Do not append to C/XX/FLAGS but just set them if not
 defined already

---
 c/Makefile   | 2 +-
 cpp/Makefile | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/c/Makefile b/c/Makefile
index fd0c367..b27449c 100644
--- a/c/Makefile
+++ b/c/Makefile
@@ -29,7 +29,7 @@
 # - CFLAGS: Any extra user-specified compiler flags (can be blank).

 # Recommended compiler flags:
-CFLAGS += -std=c99 -O
+CFLAGS ?= -std=c99 -O

 # Extra flags for diagnostics:
 # CFLAGS += -g -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -fsanitize=undefined,address
diff --git a/cpp/Makefile b/cpp/Makefile
index f83c512..666f976 100644
--- a/cpp/Makefile
+++ b/cpp/Makefile
@@ -29,7 +29,7 @@
 # - CXXFLAGS: Any extra user-specified compiler flags (can be blank).

 # Recommended compiler flags:
-CXXFLAGS += -std=c++11 -O
+CXXFLAGS ?= -std=c++11 -O

 # Extra flags for diagnostics:
 # CXXFLAGS += -g -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -fsanitize=undefined,address

From 2e496a0f59d5c6782c1e3e2a3ca36d0272b384f3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= <tchvatal@suse.com>
Date: Tue, 3 Dec 2019 11:59:59 +0100
Subject: [PATCH 2/7] Make use of -fPIC parameter when building'

---
 c/Makefile   | 2 +-
 cpp/Makefile | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/c/Makefile b/c/Makefile
index b27449c..bf79462 100644
--- a/c/Makefile
+++ b/c/Makefile
@@ -77,7 +77,7 @@ $(LIBFILE): $(LIBOBJ)

 # Object files
 %.o: %.c .deps/timestamp
-	$(CC) $(CFLAGS) -c -o $@ -MMD -MF .deps/$*.d $<
+	$(CC) $(CFLAGS) -fPIC -c -o $@ -MMD -MF .deps/$*.d $<

 # Have a place to store header dependencies automatically generated by compiler
 .deps/timestamp:
diff --git a/cpp/Makefile b/cpp/Makefile
index 666f976..f37cf66 100644
--- a/cpp/Makefile
+++ b/cpp/Makefile
@@ -73,7 +73,7 @@ $(LIBFILE): $(LIBOBJ)

 # Object files
 %.o: %.cpp .deps/timestamp
-	$(CXX) $(CXXFLAGS) -c -o $@ -MMD -MF .deps/$*.d $<
+	$(CXX) $(CXXFLAGS) -fPIC -c -o $@ -MMD -MF .deps/$*.d $<

 # Have a place to store header dependencies automatically generated by compiler
 .deps/timestamp:

From 29489faaa5a3b014c5c2d95ca34033df470de73c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= <tchvatal@suse.com>
Date: Tue, 3 Dec 2019 12:07:19 +0100
Subject: [PATCH 3/7] Generate both shared and static libraries

---
 c/Makefile   | 14 ++++++++++----
 cpp/Makefile | 14 ++++++++++----
 2 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/c/Makefile b/c/Makefile
index bf79462..38eda2d 100644
--- a/c/Makefile
+++ b/c/Makefile
@@ -51,16 +51,19 @@ CFLAGS ?= -std=c99 -O
 # ---- Targets to build ----

 LIB = qrcodegen
-LIBFILE = lib$(LIB).a
+ARFILE = lib$(LIB).a
+LIBFILE = lib$(LIB).so
+# Bump the soname number when the ABI changes and gets incompatible
+SO_NAME = $(LIBFILE).1
 LIBOBJ = qrcodegen.o
 MAINS = qrcodegen-demo qrcodegen-test qrcodegen-worker

 # Build all binaries
-all: $(LIBFILE) $(MAINS)
+all: $(LIBFILE) $(ARFILE) $(MAINS)

 # Delete build output
 clean:
-	rm -f -- $(LIBOBJ) $(LIBFILE) $(MAINS:=.o) $(MAINS)
+	rm -f -- $(LIBOBJ) $(LIBFILE) $(ARFILE) $(MAINS:=.o) $(MAINS)
 	rm -rf .deps

 # Executable files
@@ -72,9 +75,12 @@ qrcodegen-test: qrcodegen-test.c $(LIBOBJ:%.o=%.c)
 	$(CC) $(CFLAGS) -DQRCODEGEN_TEST -o $@ $^

 # The library
-$(LIBFILE): $(LIBOBJ)
+$(ARFILE): $(LIBOBJ)
 	$(AR) -crs $@ -- $^

+$(LIBFILE): $(LIBOBJ)
+	$(CC) -shared -Wl,-soname,$(SO_NAME) $(LDFLAGS) -o $@ $^
+
 # Object files
 %.o: %.c .deps/timestamp
 	$(CC) $(CFLAGS) -fPIC -c -o $@ -MMD -MF .deps/$*.d $<
diff --git a/cpp/Makefile b/cpp/Makefile
index f37cf66..606cdad 100644
--- a/cpp/Makefile
+++ b/cpp/Makefile
@@ -51,16 +51,19 @@ CXXFLAGS ?= -std=c++11 -O
 # ---- Targets to build ----

 LIB = qrcodegen
-LIBFILE = lib$(LIB).a
+ARFILE = lib$(LIB).a
+LIBFILE = lib$(LIB).so
+# Bump the soname number when the ABI changes and gets incompatible
+SO_NAME = $(LIBFILE).1
 LIBOBJ = QrCode.o
 MAINS = QrCodeGeneratorDemo QrCodeGeneratorWorker

 # Build all binaries
-all: $(LIBFILE) $(MAINS)
+all: $(LIBFILE) $(ARFILE) $(MAINS)

 # Delete build output
 clean:
-	rm -f -- $(LIBOBJ) $(LIBFILE) $(MAINS:=.o) $(MAINS)
+	rm -f -- $(LIBOBJ) $(LIBFILE) $(ARFILE) $(MAINS:=.o) $(MAINS)
 	rm -rf .deps

 # Executable files
@@ -68,9 +71,12 @@ clean:
 	$(CXX) $(CXXFLAGS) -o $@ $< -L . -l $(LIB)

 # The library
-$(LIBFILE): $(LIBOBJ)
+$(ARFILE): $(LIBOBJ)
 	$(AR) -crs $@ -- $^

+$(LIBFILE): $(LIBOBJ)
+	$(CC) -shared -Wl,-soname,$(SO_NAME) $(LDFLAGS) -o $@ $^
+
 # Object files
 %.o: %.cpp .deps/timestamp
 	$(CXX) $(CXXFLAGS) -fPIC -c -o $@ -MMD -MF .deps/$*.d $<

From 064f38d6a8dc0a457728a47ee4ca1e927e46d5ec Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= <tchvatal@suse.com>
Date: Tue, 3 Dec 2019 12:45:34 +0100
Subject: [PATCH 4/7] Create install targets for C and CPP

---
 c/Makefile   | 26 ++++++++++++++++++++++++++
 cpp/Makefile | 27 +++++++++++++++++++++++++++
 2 files changed, 53 insertions(+)

diff --git a/c/Makefile b/c/Makefile
index 38eda2d..7521944 100644
--- a/c/Makefile
+++ b/c/Makefile
@@ -34,6 +34,8 @@ CFLAGS ?= -std=c99 -O
 # Extra flags for diagnostics:
 # CFLAGS += -g -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -fsanitize=undefined,address

+# Version information
+VERSION = 1.5.0

 # ---- Controlling make ----

@@ -55,9 +57,15 @@ ARFILE = lib$(LIB).a
 LIBFILE = lib$(LIB).so
 # Bump the soname number when the ABI changes and gets incompatible
 SO_NAME = $(LIBFILE).1
+REAL_NAME = $(LIBFILE).$(VERSION)
+HEADERS = qrcodegen.h
 LIBOBJ = qrcodegen.o
 MAINS = qrcodegen-demo qrcodegen-test qrcodegen-worker

+# define paths to install
+INCLUDEDIR ?= $(DESTDIR)/usr/include/qrcodegen
+LIBDIR ?= $(DESTDIR)/usr/lib
+
 # Build all binaries
 all: $(LIBFILE) $(ARFILE) $(MAINS)

@@ -66,6 +74,24 @@ clean:
 	rm -f -- $(LIBOBJ) $(LIBFILE) $(ARFILE) $(MAINS:=.o) $(MAINS)
 	rm -rf .deps

+install-shared: $(LIBFILE)
+	install -d $(LIBDIR) || true
+	install -m 0644 $(LIBFILE) $(LIBDIR)/$(REAL_NAME)
+	rm -f $(LIBDIR)/$(SO_NAME)
+	ln -s $(REAL_NAME) $(LIBDIR)/$(SO_NAME)
+	rm -f $(LIBDIR)/$(LIBFILE)
+	ln -s $(SO_NAME) $(LIBDIR)/$(LIBFILE)
+
+install-static: $(ARFILE)
+	install -d $(LIBDIR) || true
+	install -m 0644 $(ARFILE) $(LIBDIR)/$(ARFILE)
+
+install-header: $(HEADERS)
+	install -d $(INCLUDEDIR) || true
+	install -m 0644 $(HEADERS) $(INCLUDEDIR)/
+
+install: install-shared install-static install-header
+
 # Executable files
 %: %.o $(LIBFILE)
 	$(CC) $(CFLAGS) -o $@ $< -L . -l $(LIB)
diff --git a/cpp/Makefile b/cpp/Makefile
index 606cdad..3271bd8 100644
--- a/cpp/Makefile
+++ b/cpp/Makefile
@@ -34,6 +34,8 @@ CXXFLAGS ?= -std=c++11 -O
 # Extra flags for diagnostics:
 # CXXFLAGS += -g -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -fsanitize=undefined,address

+# Version information
+VERSION = 1.5.0

 # ---- Controlling make ----

@@ -55,9 +57,16 @@ ARFILE = lib$(LIB).a
 LIBFILE = lib$(LIB).so
 # Bump the soname number when the ABI changes and gets incompatible
 SO_NAME = $(LIBFILE).1
+REAL_NAME = $(LIBFILE).$(VERSION)
+HEADERS = QrCode.hpp
 LIBOBJ = QrCode.o
 MAINS = QrCodeGeneratorDemo QrCodeGeneratorWorker

+# define paths to install
+INCLUDEDIR ?= $(DESTDIR)/usr/include/qrcodegen
+LIBDIR ?= $(DESTDIR)/usr/lib
+
+
 # Build all binaries
 all: $(LIBFILE) $(ARFILE) $(MAINS)

@@ -66,6 +75,24 @@ clean:
 	rm -f -- $(LIBOBJ) $(LIBFILE) $(ARFILE) $(MAINS:=.o) $(MAINS)
 	rm -rf .deps

+install-shared: $(LIBFILE)
+	install -d $(LIBDIR) || true
+	install -m 0644 $(LIBFILE) $(LIBDIR)/$(REAL_NAME)
+	rm -f $(LIBDIR)/$(SO_NAME)
+	ln -s $(REAL_NAME) $(LIBDIR)/$(SO_NAME)
+	rm -f $(LIBDIR)/$(LIBFILE)
+	ln -s $(SO_NAME) $(LIBDIR)/$(LIBFILE)
+
+install-static: $(ARFILE)
+	install -d $(LIBDIR) || true
+	install -m 0644 $(ARFILE) $(LIBDIR)/$(ARFILE)
+
+install-header: $(HEADERS)
+	install -d $(INCLUDEDIR) || true
+	install -m 0644 $(HEADERS) $(INCLUDEDIR)/
+
+install: install-shared install-static install-header
+
 # Executable files
 %: %.o $(LIBFILE)
 	$(CXX) $(CXXFLAGS) -o $@ $< -L . -l $(LIB)

From a635ff4654f94ab26b458c46a8841543e5bc8c67 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= <tchvatal@suse.com>
Date: Tue, 3 Dec 2019 12:50:39 +0100
Subject: [PATCH 5/7] Rename cpp library to qrcodegencpp to avoid conflict

---
 cpp/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cpp/Makefile b/cpp/Makefile
index 3271bd8..42fa4ff 100644
--- a/cpp/Makefile
+++ b/cpp/Makefile
@@ -52,7 +52,7 @@ VERSION = 1.5.0

 # ---- Targets to build ----

-LIB = qrcodegen
+LIB = qrcodegencpp
 ARFILE = lib$(LIB).a
 LIBFILE = lib$(LIB).so
 # Bump the soname number when the ABI changes and gets incompatible

From c073e7dfad6454dfd725a69c347f8272d29ea41c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= <tchvatal@suse.com>
Date: Tue, 7 Jan 2020 09:18:59 +0100
Subject: [PATCH 6/7] Add PREFIX variable and few minor fixes from code review

---
 c/Makefile   | 9 +++++----
 cpp/Makefile | 9 +++++----
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/c/Makefile b/c/Makefile
index 7521944..874933e 100644
--- a/c/Makefile
+++ b/c/Makefile
@@ -29,7 +29,7 @@
 # - CFLAGS: Any extra user-specified compiler flags (can be blank).

 # Recommended compiler flags:
-CFLAGS ?= -std=c99 -O
+CFLAGS += -std=c99

 # Extra flags for diagnostics:
 # CFLAGS += -g -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -fsanitize=undefined,address
@@ -63,8 +63,9 @@ LIBOBJ = qrcodegen.o
 MAINS = qrcodegen-demo qrcodegen-test qrcodegen-worker

 # define paths to install
-INCLUDEDIR ?= $(DESTDIR)/usr/include/qrcodegen
-LIBDIR ?= $(DESTDIR)/usr/lib
+PREFIX ?= /usr/local
+INCLUDEDIR ?= $(DESTDIR)$(PREFIX)/include/qrcodegen
+LIBDIR ?= $(DESTDIR)$(PREFIX)/lib

 # Build all binaries
 all: $(LIBFILE) $(ARFILE) $(MAINS)
@@ -105,7 +106,7 @@ $(ARFILE): $(LIBOBJ)
 	$(AR) -crs $@ -- $^

 $(LIBFILE): $(LIBOBJ)
-	$(CC) -shared -Wl,-soname,$(SO_NAME) $(LDFLAGS) -o $@ $^
+	$(CC) $(CFLAGS) -shared -Wl,-soname,$(SO_NAME) $(LDFLAGS) -o $@ $^

 # Object files
 %.o: %.c .deps/timestamp
diff --git a/cpp/Makefile b/cpp/Makefile
index 42fa4ff..f8d9b7f 100644
--- a/cpp/Makefile
+++ b/cpp/Makefile
@@ -29,7 +29,7 @@
 # - CXXFLAGS: Any extra user-specified compiler flags (can be blank).

 # Recommended compiler flags:
-CXXFLAGS ?= -std=c++11 -O
+CXXFLAGS += -std=c++11

 # Extra flags for diagnostics:
 # CXXFLAGS += -g -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -fsanitize=undefined,address
@@ -63,8 +63,9 @@ LIBOBJ = QrCode.o
 MAINS = QrCodeGeneratorDemo QrCodeGeneratorWorker

 # define paths to install
-INCLUDEDIR ?= $(DESTDIR)/usr/include/qrcodegen
-LIBDIR ?= $(DESTDIR)/usr/lib
+PREFIX ?= /usr/local
+INCLUDEDIR ?= $(DESTDIR)$(PREFIX)/include/qrcodegen
+LIBDIR ?= $(DESTDIR)$(PREFIX)/lib

 # Build all binaries
@@ -102,7 +103,7 @@ $(ARFILE): $(LIBOBJ)
 	$(AR) -crs $@ -- $^

 $(LIBFILE): $(LIBOBJ)
-	$(CC) -shared -Wl,-soname,$(SO_NAME) $(LDFLAGS) -o $@ $^
+	$(CXX) $(CXXFLAGS) -shared -Wl,-soname,$(SO_NAME) $(LDFLAGS) -o $@ $^

 # Object files
 %.o: %.cpp .deps/timestamp

From b43c1de5cc874535a7f549cef437f6849528e455 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= <tchvatal@suse.com>
Date: Tue, 7 Jan 2020 13:12:32 +0100
Subject: [PATCH 7/7] Install static and shared library as an executable

---
 c/Makefile   | 4 ++--
 cpp/Makefile | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/c/Makefile b/c/Makefile
index 874933e..631cc71 100644
--- a/c/Makefile
+++ b/c/Makefile
@@ -77,7 +77,7 @@ clean:

 install-shared: $(LIBFILE)
 	install -d $(LIBDIR) || true
-	install -m 0644 $(LIBFILE) $(LIBDIR)/$(REAL_NAME)
+	install -m 0755 $(LIBFILE) $(LIBDIR)/$(REAL_NAME)
 	rm -f $(LIBDIR)/$(SO_NAME)
 	ln -s $(REAL_NAME) $(LIBDIR)/$(SO_NAME)
 	rm -f $(LIBDIR)/$(LIBFILE)
@@ -85,7 +85,7 @@ install-shared: $(LIBFILE)

 install-static: $(ARFILE)
 	install -d $(LIBDIR) || true
-	install -m 0644 $(ARFILE) $(LIBDIR)/$(ARFILE)
+	install -m 0755 $(ARFILE) $(LIBDIR)/$(ARFILE)

 install-header: $(HEADERS)
 	install -d $(INCLUDEDIR) || true
diff --git a/cpp/Makefile b/cpp/Makefile
index f8d9b7f..bbd861e 100644
--- a/cpp/Makefile
+++ b/cpp/Makefile
@@ -78,7 +78,7 @@ clean:

 install-shared: $(LIBFILE)
 	install -d $(LIBDIR) || true
-	install -m 0644 $(LIBFILE) $(LIBDIR)/$(REAL_NAME)
+	install -m 0755 $(LIBFILE) $(LIBDIR)/$(REAL_NAME)
 	rm -f $(LIBDIR)/$(SO_NAME)
 	ln -s $(REAL_NAME) $(LIBDIR)/$(SO_NAME)
 	rm -f $(LIBDIR)/$(LIBFILE)
@@ -86,7 +86,7 @@ install-shared: $(LIBFILE)

 install-static: $(ARFILE)
 	install -d $(LIBDIR) || true
-	install -m 0644 $(ARFILE) $(LIBDIR)/$(ARFILE)
+	install -m 0755 $(ARFILE) $(LIBDIR)/$(ARFILE)

 install-header: $(HEADERS)
 	install -d $(INCLUDEDIR) || true


code:
Explicitly link against libicui18n so that libQtCore.so always finds it.

--- qt-everywhere-opensource-src-4.8.6/src/corelib/corelib.pro	2015-04-15 12:01:41.661862663 +0200
+++ qt-everywhere-opensource-src-4.8.6/src/corelib/corelib.pro	2015-04-15 12:03:57.954586336 +0200
@@ -19,6 +19,13 @@ include(codecs/codecs.pri)
 include(statemachine/statemachine.pri)
 include(xml/xml.pri)

+# Explicitly link with icui18n, which is dlopened by libQtCore.so.
+# We cannot do this by setting LDFLAGS because that then overrides
+# other LDFLAGS: <https://bugreports.qt.io/browse/QTBUG-5471>.
+# XXX: According to the Nixpkgs recipe, this may be necessary for
+# further libraries (cups, gtk-x11-2.0, libgdk-x11-2.0).
+LIBS_PRIVATE += -licui18n
+
 !qpa:mac|darwin:LIBS_PRIVATE += -framework ApplicationServices
 qpa:mac {
     !ios {


code:
Do not use $ORIGIN in RUNPATH so that executables can be copied elsewhere and
still be expected to work (needed for python-pyside-2-tools).

diff --git a/mkspecs/common/linux.conf b/mkspecs/common/linux.conf
--- a/mkspecs/common/linux.conf
+++ b/mkspecs/common/linux.conf
@@ -10,8 +10,8 @@ QMAKE_CFLAGS_THREAD    += -D_REENTRANT
 QMAKE_CXXFLAGS_THREAD  += $$QMAKE_CFLAGS_THREAD
 QMAKE_LFLAGS_GCSECTIONS = -Wl,--gc-sections

-QMAKE_LFLAGS_REL_RPATH  = -Wl,-z,origin
-QMAKE_REL_RPATH_BASE    = $ORIGIN
+QMAKE_LFLAGS_REL_RPATH  =
+QMAKE_REL_RPATH_BASE    =

 QMAKE_INCDIR            =
 QMAKE_LIBDIR            =