I'm using python3.10 installed via homebrew. I just tried with /usr/bin/python3—I believe that's the one that comes with Xcode—but it also doesn't have any entitlements nor show data for the CoreML instrument.
Post
Replies
Boosts
Views
Activity
I get this:
❯ codesign -d -vvv --entitlements - /path/to/my/python
Executable=/opt/homebrew/Cellar/python@3.10/3.10.12_1/Frameworks/Python.framework/Versions/3.10/bin/python3.10
Identifier=python3-555549447295e55955d43aca9820d95d1f4ae151
Format=Mach-O thin (arm64)
CodeDirectory v=20400 size=489 flags=0x2(adhoc) hashes=9+2 location=embedded
Hash type=sha256 size=32
CandidateCDHash sha256=f8edaad9c426fe4e51e0f52ffd1e2b2f7fa6126d
CandidateCDHashFull sha256=f8edaad9c426fe4e51e0f52ffd1e2b2f7fa6126d980124e04a63adbbac49d34e
Hash choices=sha256
CMSDigest=f8edaad9c426fe4e51e0f52ffd1e2b2f7fa6126d980124e04a63adbbac49d34e
CMSDigestType=2
Launch Constraints:
None
CDHash=f8edaad9c426fe4e51e0f52ffd1e2b2f7fa6126d
Signature=adhoc
Info.plist=not bound
TeamIdentifier=not set
Sealed Resources=none
Internal requirements count=0 size=12
Not entirely sure what should happen, but I get this:
❯ lldb env/bin/python
(lldb) target create "env/bin/python"
Current executable set to '/path/to/env/bin/python' (arm64).
(lldb) r
Process 33134 launched: '/path/to/env/bin/python' (arm64)
Process 33134 stopped
* thread #2, stop reason = exec
frame #0: 0x0000000100014a40 dyld`_dyld_start
dyld`:
-> 0x100014a40 <+0>: mov x0, sp
0x100014a44 <+4>: and sp, x0, #0xfffffffffffffff0
0x100014a48 <+8>: mov x29, #0x0
0x100014a4c <+12>: mov x30, #0x0
Target 0: (Python) stopped.
(lldb)
Separately, I tried signing my python binary like this:
❯ cat entitlements.xml
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.get-task-allow</key>
<true/>
</dict>
</plist>
❯ codesign -f -s - env/bin/python --entitlements entitlements.xml
env/bin/python: replacing existing signature
❯ codesign -d -vv env/bin/python --entitlements -
Executable=/opt/homebrew/Cellar/python@3.10/3.10.12_1/Frameworks/Python.framework/Versions/3.10/bin/python3.10
Identifier=python3-555549447295e55955d43aca9820d95d1f4ae151
Format=Mach-O thin (arm64)
CodeDirectory v=20400 size=649 flags=0x2(adhoc) hashes=9+7 location=embedded
Signature=adhoc
Info.plist=not bound
TeamIdentifier=not set
Sealed Resources=none
Internal requirements count=0 size=12
[Dict]
[Key] com.apple.security.get-task-allow
[Value]
[Bool] true
When I signed my C++ program this way, the CoreML instrument did work. However after signing python like this, it still does not work.
Also, signing python this way doesn't change the lldb output I get the same results as before signing for both lldb env/bin/python and lldb /opt/homebrew/Cellar/python@3.10/3.10.12_1/Frameworks/Python.framework/Versions/3.10/bin/python3.10.
Ahh that's interesting. I tried with my homebrew binary:
codesign -f -s - /opt/homebrew/Cellar/python@3.10/3.10.12_1/Frameworks/Python.framework/Versions/3.10/Resources/Python.app/Contents/MacOS/Python --entitlements entitlements.xml
I get the same results in lldb. I was also able to test the CoreML Instrument and it does work after re-signing like this. Thank you!
This is probably because the prior op (img1_1_cast_fp16) could not run on the Neural Engine. As I understand it, switching between compute units incurs overhead and CoreML will decide to not switch back sometimes to avoid incurring that overhead.
Per the WWDC session video, hovering should tell you why it’s not supported. Maybe that is broken?