Skip to content

Commit 0869db6

Browse files
committed
lang/python37: Fix for macOS 11 and Apple Silicon
(Apple Silicon being their aarch64 platform.) This is backport of the same in lang/python39 and lang/python38. Some parts weren't applicable in 3.7. The setup.py script needed some work on the ffi code. Otherwise, minor changes. Patches consist of: - Upstream work: python/cpython#22855 - Fix for setup.py to find libbz2.tbd and libz.tbd now that with the shared library cache there's nothing in /usr/lib. See: https://bugs.python.org/issue41116 - Addition of __arch64__ case to fix _decimal module. A very similar fix has since been committed upstream.
1 parent a6e716a commit 0869db6

25 files changed

Lines changed: 3090 additions & 39 deletions

‎lang/python37/Makefile‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# $NetBSD: Makefile,v 1.21 2020/09/01 09:26:54 schmonz Exp $
1+
# $NetBSD: Makefile,v 1.22 2020/11/17 19:33:26 sjmulder Exp $
22

33
.include "dist.mk"
44

55
PKGNAME= python37-${PY_DISTVERSION}
6-
PKGREVISION= 1
6+
PKGREVISION= 2
77
CATEGORIES= lang python
88

99
MAINTAINER= pkgsrc-users@NetBSD.org

‎lang/python37/distinfo‎

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,42 @@
1-
$NetBSD: distinfo,v 1.21 2020/09/01 09:26:54 schmonz Exp $
1+
$NetBSD: distinfo,v 1.22 2020/11/17 19:33:26 sjmulder Exp $
22

33
SHA1 (Python-3.7.9.tar.xz) = e1de02779a89a94000c0ed340ec126de25825f2f
44
RMD160 (Python-3.7.9.tar.xz) = 6ff3676f84b1a103b0e3161dcc7257936c914daf
55
SHA512 (Python-3.7.9.tar.xz) = e4217b25529b5336e43b63d17f3758a8177a58184564cf02bd92a312f58dba9e096485c9e3cb3544f966e847ea15b3ab30ed065d28a6ca52a6d7e0faddf7d9f9
66
Size (Python-3.7.9.tar.xz) = 17389636 bytes
7+
SHA1 (patch-Lib___osx__support.py) = dbec9925c1a0b6b845101df9825af52d83317773
78
SHA1 (patch-Lib_ctypes_____init____.py) = ded12eb372028288d85ba88b43e45549c6f48144
9+
SHA1 (patch-Lib_ctypes_macholib_dyld.py) = 267f0b39f116bc9df0b24c277b48ce59cfecd397
10+
SHA1 (patch-Lib_ctypes_test_test__macholib.py) = 76bb73619e5a27aa1009d4c65e3be1f69b9b6e91
811
SHA1 (patch-Lib_ctypes_util.py) = 032cc99ebad93ddddfd89073c60424a952e3faa3
912
SHA1 (patch-Lib_distutils_command_install.py) = 6fc6f5d918b7581fc62cd0fe55857ee932c3a341
1013
SHA1 (patch-Lib_distutils_sysconfig.py) = 6822eafb4dfded86d7f7353831816aeb8119e6cf
1114
SHA1 (patch-Lib_distutils_unixccompiler.py) = 2e65a8dd5dd3fe25957206c062106fa7a6fc4e69
1215
SHA1 (patch-Lib_lib2to3_pgen2_driver.py) = 5d6dab14197f27363394ff1aeee22a8ced8026d2
1316
SHA1 (patch-Lib_sysconfig.py) = a4f009ed73ebbd9d9c4bf7e12b7981182ed8fd7c
17+
SHA1 (patch-Lib_test_test__bytes.py) = 9b97cd1cd753a0a7afdc601b606367655d4c47b1
18+
SHA1 (patch-Lib_test_test__platform.py) = b473d766ecdbba93cdcc66a4550c2d02bf37ae79
19+
SHA1 (patch-Lib_test_test__posix.py) = 3fcc7b483f1797d273b2337daeac514bd60a1e78
20+
SHA1 (patch-Lib_test_test__time.py) = e20c40aad6442422fae08ab937b9d128ad4b8fdc
21+
SHA1 (patch-Lib_test_test__unicode.py) = 4dfccf72ae60d1e1092ff84b7c05a735865ba8a8
22+
SHA1 (patch-Mac_BuildScript_build-installer.py) = a377ed164ee2ba72ce0f72ccf9507e775f7b7deb
23+
SHA1 (patch-Mac_Tools_pythonw.c) = 94f27032aac27263bc1c1bd66574121fbca1e380
1424
SHA1 (patch-Makefile.pre.in) = 1393dac225c5a7edcb7947eb707b4526ea884f95
25+
SHA1 (patch-Modules___ctypes_callbacks.c) = 98bd449f9c4bf3acbcfdd24d017f490fc0c9326e
26+
SHA1 (patch-Modules___ctypes_callproc.c) = d0905ede69f2c61d917380d6da73c14e7e31d41f
27+
SHA1 (patch-Modules___ctypes_ctypes.h) = 2589d24c101771f8696b456d594e5f53305cf72c
28+
SHA1 (patch-Modules___ctypes_malloc__closure.c) = 780e7dfa293c57dc28e97358937ed7d148414c8e
29+
SHA1 (patch-Modules___decimal_libmpdec_mpdecimal.h) = 3840dc184f1f5faa590cdca57df911d5c71a9439
1530
SHA1 (patch-Modules_makesetup) = a06786eebffadecedba5e3a50a9785fb47613567
1631
SHA1 (patch-Modules_nismodule.c) = 1bafe9b06359586d027a77011b103877590d947d
32+
SHA1 (patch-Modules_posixmodule.c) = cae3797179c1a4d820dd294b69ca4b9a6fa81899
1733
SHA1 (patch-Modules_socketmodule.c) = c0bdb256bccc176c2406feec4080cd91fcb693b2
1834
SHA1 (patch-Modules_socketmodule.h) = 13a3290eb72078067060d3e71b7baa08f3eb591c
35+
SHA1 (patch-Modules_timemodule.c) = c0fa13e7f02046b1dfde36a50898b4c46ca3792e
36+
SHA1 (patch-Python_bootstrap__hash.c) = c60b3987e549987a1180edaab0ad2d48fc272925
37+
SHA1 (patch-Python_pytime.c) = 5d782457439708f5e8e46043eed5fe7ba40f45f9
1938
SHA1 (patch-Python_thread__pthread.h) = fb81eaa604b4ed7c1b64c3f4731d58a8aee257be
20-
SHA1 (patch-configure) = bb660a76f77d8cd544f6f8344a0a2b9c62953e00
21-
SHA1 (patch-pyconfig.h.in) = 58e2c03489f9b6e4d88f144d8c09773f92eacd61
22-
SHA1 (patch-setup.py) = 3edd2ab894f453be19dc4af06f3e78f49e5e2c34
39+
SHA1 (patch-configure) = 2c7d3fb29c2fc9a7a75adbddf7399f5e69baeaca
40+
SHA1 (patch-configure.ac) = 948e925ef2595058a902ad60762158f16d13db80
41+
SHA1 (patch-pyconfig.h.in) = 1a837a44c9b4f6e538909dba70482082e5a6b80f
42+
SHA1 (patch-setup.py) = d42d76b6edc5b5b7855b2888e0df7ab723ade6a5
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
$NetBSD: patch-Lib___osx__support.py,v 1.1 2020/11/17 19:33:26 sjmulder Exp $
2+
3+
Support for macOS 11 and Apple Silicon (ARM). Mostly backported from:
4+
https://github.com/python/cpython/pull/22855
5+
6+
--- Lib/_osx_support.py.orig 2020-08-15 05:20:16.000000000 +0000
7+
+++ Lib/_osx_support.py
8+
@@ -110,6 +110,25 @@ def _get_system_version():
9+
10+
return _SYSTEM_VERSION
11+
12+
+_SYSTEM_VERSION_TUPLE = None
13+
+def _get_system_version_tuple():
14+
+ """
15+
+ Return the macOS system version as a tuple
16+
+
17+
+ The return value is safe to use to compare
18+
+ two version numbers.
19+
+ """
20+
+ global _SYSTEM_VERSION_TUPLE
21+
+ if _SYSTEM_VERSION_TUPLE is None:
22+
+ osx_version = _get_system_version()
23+
+ if osx_version:
24+
+ try:
25+
+ _SYSTEM_VERSION_TUPLE = tuple(int(i) for i in osx_version.split('.'))
26+
+ except ValueError:
27+
+ _SYSTEM_VERSION_TUPLE = ()
28+
+
29+
+ return _SYSTEM_VERSION_TUPLE
30+
+
31+
def _remove_original_values(_config_vars):
32+
"""Remove original unmodified values for testing"""
33+
# This is needed for higher-level cross-platform tests of get_platform.
34+
@@ -132,14 +151,18 @@ def _supports_universal_builds():
35+
# builds, in particular -isysroot and -arch arguments to the compiler. This
36+
# is in support of allowing 10.4 universal builds to run on 10.3.x systems.
37+
38+
- osx_version = _get_system_version()
39+
- if osx_version:
40+
- try:
41+
- osx_version = tuple(int(i) for i in osx_version.split('.'))
42+
- except ValueError:
43+
- osx_version = ''
44+
+ osx_version = _get_system_version_tuple()
45+
return bool(osx_version >= (10, 4)) if osx_version else False
46+
47+
+def _supports_arm64_builds():
48+
+ """Returns True if arm64 builds are supported on this system"""
49+
+ # There are two sets of systems supporting macOS/arm64 builds:
50+
+ # 1. macOS 11 and later, unconditionally
51+
+ # 2. macOS 10.15 with Xcode 12.2 or later
52+
+ # For now the second category is ignored.
53+
+ osx_version = _get_system_version_tuple()
54+
+ return osx_version >= (11, 0) if osx_version else False
55+
+
56+
57+
def _find_appropriate_compiler(_config_vars):
58+
"""Find appropriate C compiler for extension module builds"""
59+
@@ -331,6 +354,12 @@ def compiler_fixup(compiler_so, cc_args)
60+
except ValueError:
61+
break
62+
63+
+ elif not _supports_arm64_builds():
64+
+ # Look for "-arch arm64" and drop that
65+
+ for idx in range(len(compiler_so)):
66+
+ if compiler_so[idx] == '-arch' and compiler_so[idx+1] == "arm64":
67+
+ del compiler_so[idx:idx+2]
68+
+
69+
if 'ARCHFLAGS' in os.environ and not stripArch:
70+
# User specified different -arch flags in the environ,
71+
# see also distutils.sysconfig
72+
@@ -481,6 +510,8 @@ def get_platform_osx(_config_vars, osnam
73+
74+
if len(archs) == 1:
75+
machine = archs[0]
76+
+ elif archs == ('arm64', 'x86_64'):
77+
+ machine = 'universal2'
78+
elif archs == ('i386', 'ppc'):
79+
machine = 'fat'
80+
elif archs == ('i386', 'x86_64'):
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
$NetBSD: patch-Lib_ctypes_macholib_dyld.py,v 1.1 2020/11/17 19:33:26 sjmulder Exp $
2+
3+
Support for macOS 11 and Apple Silicon (ARM). Mostly backported from:
4+
https://github.com/python/cpython/pull/22855
5+
6+
--- Lib/ctypes/macholib/dyld.py.orig 2020-08-15 05:20:16.000000000 +0000
7+
+++ Lib/ctypes/macholib/dyld.py
8+
@@ -6,6 +6,11 @@ import os
9+
from ctypes.macholib.framework import framework_info
10+
from ctypes.macholib.dylib import dylib_info
11+
from itertools import *
12+
+try:
13+
+ from _ctypes import _dyld_shared_cache_contains_path
14+
+except ImportError:
15+
+ def _dyld_shared_cache_contains_path(*args):
16+
+ raise NotImplementedError
17+
18+
__all__ = [
19+
'dyld_find', 'framework_find',
20+
@@ -122,8 +127,15 @@ def dyld_find(name, executable_path=None
21+
dyld_executable_path_search(name, executable_path),
22+
dyld_default_search(name, env),
23+
), env):
24+
+
25+
if os.path.isfile(path):
26+
return path
27+
+ try:
28+
+ if _dyld_shared_cache_contains_path(path):
29+
+ return path
30+
+ except NotImplementedError:
31+
+ pass
32+
+
33+
raise ValueError("dylib %s could not be found" % (name,))
34+
35+
def framework_find(fn, executable_path=None, env=None):
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
$NetBSD: patch-Lib_ctypes_test_test__macholib.py,v 1.1 2020/11/17 19:33:26 sjmulder Exp $
2+
3+
Support for macOS 11 and Apple Silicon (ARM). Mostly backported from:
4+
https://github.com/python/cpython/pull/22855
5+
6+
--- Lib/ctypes/test/test_macholib.py.orig 2020-08-15 05:20:16.000000000 +0000
7+
+++ Lib/ctypes/test/test_macholib.py
8+
@@ -45,19 +45,22 @@ def find_lib(name):
9+
class MachOTest(unittest.TestCase):
10+
@unittest.skipUnless(sys.platform == "darwin", 'OSX-specific test')
11+
def test_find(self):
12+
-
13+
- self.assertEqual(find_lib('pthread'),
14+
- '/usr/lib/libSystem.B.dylib')
15+
+ # On Mac OS 11, system dylibs are only present in the shared cache,
16+
+ # so symlinks like libpthread.dylib -> libSystem.B.dylib will not
17+
+ # be resolved by dyld_find
18+
+ self.assertIn(find_lib('pthread'),
19+
+ ('/usr/lib/libSystem.B.dylib', '/usr/lib/libpthread.dylib'))
20+
21+
result = find_lib('z')
22+
# Issue #21093: dyld default search path includes $HOME/lib and
23+
# /usr/local/lib before /usr/lib, which caused test failures if
24+
# a local copy of libz exists in one of them. Now ignore the head
25+
# of the path.
26+
- self.assertRegex(result, r".*/lib/libz\..*.*\.dylib")
27+
+ self.assertRegex(result, r".*/lib/libz.*\.dylib")
28+
29+
- self.assertEqual(find_lib('IOKit'),
30+
- '/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit')
31+
+ self.assertIn(find_lib('IOKit'),
32+
+ ('/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit',
33+
+ '/System/Library/Frameworks/IOKit.framework/IOKit'))
34+
35+
if __name__ == "__main__":
36+
unittest.main()
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
$NetBSD: patch-Lib_test_test__bytes.py,v 1.1 2020/11/17 19:33:26 sjmulder Exp $
2+
3+
Support for macOS 11 and Apple Silicon (ARM). Mostly backported from:
4+
https://github.com/python/cpython/pull/22855
5+
6+
--- Lib/test/test_bytes.py.orig 2020-08-15 05:20:16.000000000 +0000
7+
+++ Lib/test/test_bytes.py
8+
@@ -903,6 +903,7 @@ class BytesTest(BaseBytesTest, unittest.
9+
c_char_p)
10+
11+
PyBytes_FromFormat = pythonapi.PyBytes_FromFormat
12+
+ PyBytes_FromFormat.argtypes = (c_char_p,)
13+
PyBytes_FromFormat.restype = py_object
14+
15+
# basic tests
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
$NetBSD: patch-Lib_test_test__platform.py,v 1.1 2020/11/17 19:33:26 sjmulder Exp $
2+
3+
Support for macOS 11 and Apple Silicon (ARM). Mostly backported from:
4+
https://github.com/python/cpython/pull/22855
5+
6+
--- Lib/test/test_platform.py.orig 2020-08-15 05:20:16.000000000 +0000
7+
+++ Lib/test/test_platform.py
8+
@@ -254,7 +254,7 @@ class PlatformTest(unittest.TestCase):
9+
self.assertEqual(res[1], ('', '', ''))
10+
11+
if sys.byteorder == 'little':
12+
- self.assertIn(res[2], ('i386', 'x86_64'))
13+
+ self.assertIn(res[2], ('i386', 'x86_64', 'arm64'))
14+
else:
15+
self.assertEqual(res[2], 'PowerPC')
16+

0 commit comments

Comments
 (0)