[Python-checkins] [3.7] fix CI on macOS due to infrastructure changes (GH-96493)

ned-deily webhook-mailer at python.org
Thu Sep 1 23:46:53 EDT 2022


https://github.com/python/cpython/commit/6fde29377fd57fea13a54dd847b7cf171c2df6d1
commit: 6fde29377fd57fea13a54dd847b7cf171c2df6d1
branch: 3.7
author: Gregory P. Smith <greg at krypto.org>
committer: ned-deily <nad at python.org>
date: 2022-09-01T23:46:48-04:00
summary:

[3.7] fix CI on macOS due to infrastructure changes (GH-96493)

* Add ABI and generated files checks to CI.

This includes checking in an initial Abigail ABI definition for 3.7.

* Backport ctypes test_macholib fix from b29d0a5a7811418c0a1082ca188fd4850185e290.

This is required for the 3.7 tree to pass on modern macOS.

* annotate test_bad_password @requires_zlib.

I don't know why, but macOS in 3.7 CI is failing to build the zlib
module these days so it's exposing this test that didn't have the
proper `@requires_zlib` annotation.

Getting it to build with zlib and other things that are now wrongly
"missing" in the 3.7 CI setup would be nice, but probably involves
invasive backporting of parts of
https://github.com/python/cpython/commit/b29d0a5a7811418c0a1082ca188fd4850185e290
by a macOS domain expert.

Not worth it.

* disable MachOTest.test_find unless macOS 11+ support is backported.

This test also appears to require changes to
Lib/ctypes/macholib/dyld.py to work in the existing macOS CI config.
I'm just skipping it, backporting that would be a feature.
Not going to happen in 3.7.

There may be a way to configure macOS CI to use an older macOS and
toolchain instead as an alternate option.  Someone else can figure
that out if so.  This branch only lives for another 9 months per
https://peps.python.org/pep-0537/

* LOL at my typo

Co-authored-by: Ned Deily <nad at python.org>

files:
M Lib/ctypes/test/test_macholib.py
M Lib/test/test_zipfile.py

diff --git a/Lib/ctypes/test/test_macholib.py b/Lib/ctypes/test/test_macholib.py
index 6b3526951acf..8b13b3af2239 100644
--- a/Lib/ctypes/test/test_macholib.py
+++ b/Lib/ctypes/test/test_macholib.py
@@ -32,6 +32,10 @@
 # -bob
 
 from ctypes.macholib.dyld import dyld_find
+try:
+    from _ctypes import _dyld_shared_cache_contains_path
+except ImportError:
+    _dyld_shared_cache_contains_path = None
 
 def find_lib(name):
     possible = ['lib'+name+'.dylib', name+'.dylib', name+'.framework/'+name]
@@ -44,20 +48,24 @@ def find_lib(name):
 
 class MachOTest(unittest.TestCase):
     @unittest.skipUnless(sys.platform == "darwin", 'OSX-specific test')
+    @unittest.skipUnless(_dyld_shared_cache_contains_path, 'macOS 11+ _ctypes support not present.')
     def test_find(self):
-
-        self.assertEqual(find_lib('pthread'),
-                             '/usr/lib/libSystem.B.dylib')
+        # On Mac OS 11, system dylibs are only present in the shared cache,
+        # so symlinks like libpthread.dylib -> libSystem.B.dylib will not
+        # be resolved by dyld_find
+        self.assertIn(find_lib('pthread'),
+                              ('/usr/lib/libSystem.B.dylib', '/usr/lib/libpthread.dylib'))
 
         result = find_lib('z')
         # Issue #21093: dyld default search path includes $HOME/lib and
         # /usr/local/lib before /usr/lib, which caused test failures if
         # a local copy of libz exists in one of them. Now ignore the head
         # of the path.
-        self.assertRegex(result, r".*/lib/libz\..*.*\.dylib")
+        self.assertRegex(result, r".*/lib/libz.*\.dylib")
 
-        self.assertEqual(find_lib('IOKit'),
-                             '/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit')
+        self.assertIn(find_lib('IOKit'),
+                              ('/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit',
+                              '/System/Library/Frameworks/IOKit.framework/IOKit'))
 
 if __name__ == "__main__":
     unittest.main()
diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py
index 7e8e8d2c89f0..6a6df859856c 100644
--- a/Lib/test/test_zipfile.py
+++ b/Lib/test/test_zipfile.py
@@ -2077,6 +2077,7 @@ def test_no_password(self):
         self.assertRaises(RuntimeError, self.zip.read, "test.txt")
         self.assertRaises(RuntimeError, self.zip2.read, "zero")
 
+    @requires_zlib
     def test_bad_password(self):
         self.zip.setpassword(b"perl")
         self.assertRaises(RuntimeError, self.zip.read, "test.txt")



More information about the Python-checkins mailing list