Opened 4 years ago

Closed 3 years ago

#62475 closed defect (fixed)

py-pyobjc @7.1_0: Symbol not found: _ffi_find_closure_for_code_np

Reported by: dsedivec Owned by: danchr (Dan Villiom Podlaski Christiansen)
Priority: Normal Milestone:
Component: ports Version: 2.6.4
Keywords: Cc: dsavransky (Dmitry Savransky), DanielO (Daniel O'Connor), gallafent
Port: py-pyobjc

Description

I get the following error when trying to use PyObjC as bundled by MacPorts:

$ /opt/local/bin/python3.9
Python 3.9.2 (default, Mar 16 2021, 12:04:06)
[Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import Cocoa
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/Cocoa/__init__.py", line 9, in <module>
    import AppKit
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/AppKit/__init__.py", line 10, in <module>
    import Foundation
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/Foundation/__init__.py", line 9, in <module>
    import CoreFoundation
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/CoreFoundation/__init__.py", line 9, in <module>
    import objc
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/objc/__init__.py", line 6, in <module>
    from . import _objc
ImportError: dlopen(/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/objc/_objc.cpython-39-darwin.so, 2): Symbol not found: _ffi_find_closure_for_code_np
  Referenced from: /opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/objc/_objc.cpython-39-darwin.so
  Expected in: flat namespace
 in /opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/objc/_objc.cpython-39-darwin.so

(Faster way to test this from your shell: `/opt/local/bin/python3.9 -c 'import Cocoa')

Test system is a freshly-reinstalled 2019 MBP (so x86_64 not M1) running macOS 11.2.3.

I got the same error when testing with Python 3.8 from MacPorts. Using Apple's /usr/bin/python3 to make a virtualenv and install PyObjC with pip works fine.

Change History (9)

comment:1 Changed 4 years ago by mf2k (Frank Schima)

Cc: danchr@… removed
Owner: set to danchr
Status: newassigned

comment:2 Changed 4 years ago by danchr (Dan Villiom Podlaski Christiansen)

I've posted a pull request which should fix this:

https://github.com/macports/macports-ports/pull/10336

The underlying issue is that PyObjC does not work with the libffi included with MacPorts on Big Sur.

comment:3 Changed 4 years ago by cctile (Charles Choi)

FWIW, also seeing this issue.

comment:4 Changed 4 years ago by dsavransky (Dmitry Savransky)

Last edited 4 years ago by dsavransky (Dmitry Savransky) (previous) (diff)

comment:5 Changed 4 years ago by dsavransky (Dmitry Savransky)

Cc: dsavransky added

comment:6 Changed 3 years ago by DanielO (Daniel O'Connor)

Cc: DanielO added

comment:7 Changed 3 years ago by gallafent

Cc: gallafent added

comment:8 in reply to:  2 Changed 3 years ago by DanielO (Daniel O'Connor)

Replying to danchr:

I've posted a pull request which should fix this:

https://github.com/macports/macports-ports/pull/10336

The underlying issue is that PyObjC does not work with the libffi included with MacPorts on Big Sur.

+1 for this pull request - works for me.

Perhaps even if this is not a perfect solution it can be used while a better one is being worked on?

comment:9 Changed 3 years ago by danchr (Dan Villiom Podlaski Christiansen)

Resolution: fixed
Status: assignedclosed

In 217d8731dcc6247f67004de48d3f4760b07e33db/macports-ports (master):

py-pyobjc: don't use MacPorts libffi on Big Sur

PyObjC requires changes to libffi which Apple has yet to merge into
upstream. The build system incorrectly picked up the headers for the
system libffi, yet linked against MacPorts libffi, generating a binary
that failed with an error on load.

This fixes that by forcing use of the system-provided libffi on Big
Sur, and adjusts patches the sources to use the correct headers
elswehere. As libffi is a dependency of CPython itself, merely
removing it from the list of dependencies doesn't suffice, and we have
to include it by path.

While at it, I've applied some patches to force setuptools so that we
can build in parallel.

Fixes: #62475

Note: See TracTickets for help on using tickets.