Not entirely sure what should happen, but I get this:
I was hoping that it’d actually run Python, but it does not. Rather, it’s stopping in some non-obvious way.
Notably, it actually works if you run bin/python
from Terminal.
I ran some more tests in my office and worked out what’s going on. bin/python
is not actually Python. Rather, it’s a trampoline that bounces over to Resources/Python.app/Contents/MacOS/Python
. When you re-sign bin/python
, it only resigns that tool. However, that tool simply execs Resources/Python.app/Contents/MacOS/Python
. What happens there depends on your exact setup:
-
In my case Python.app
had incompatible code signing, so things failed and I got a crash report.
-
In your case I think you’re just stopping after the exec.
Either way, it suggests a path forward. Rather than re-signing bin/python
, re-sign Resources/Python.app
. For example:
% cat tmp.entitlements
<?xml version="1.0" encoding="UTF-8"?>
<!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 -s - -f --entitlements tmp.entitlements Python.app
Python.app: replacing existing signature
And you can now run Python under the debugger:
% lldb Python.app/Contents/MacOS/Python
(lldb) target create "Python.app/Contents/MacOS/Python"
Current executable set to '/Users/quinn/Python3.framework/Versions/3.8/Resources/Python.app/Contents/MacOS/Python' (arm64).
(lldb) r
Process 19846 launched: '/Users/quinn/Python3.framework/Versions/3.8/Resources/Python.app/Contents/MacOS/Python' (arm64)
Python 3.8.9 (default, Apr 13 2022, 08:48:06)
[Clang 13.1.6 (clang-1316.0.21.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
I’m hoping that’s enough to make Instruments happy, but I wasn’t able to test that far.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"