classification
Title: Relocatable framework for macOS
Type: enhancement Stage:
Components: macOS Versions: Python 3.10, Python 3.9, Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: gregneagle, ned.deily, ronaldoussoren, tomgoddard
Priority: normal Keywords:

Created on 2020-11-30 18:28 by gregneagle, last changed 2021-01-21 18:23 by tomgoddard.

Messages (3)
msg382171 - (view) Author: Greg Neagle (gregneagle) Date: 2020-11-30 18:28
The current Python.framework installed by the macOS packages is hard-coded to /Library/Frameworks/Python.framework and breaks if renamed or moved.

A relocatable framework would allow users/admins/developers to install a specific framework to an alternate location, or include it inside an application bundle, or access it from a mounted disk image.

Currently it is possible to use `otool` and `install_name_tool` to convert the current framework into one that can be relocated, but doing so breaks any code signing. With Apple Silicon, all executable code and libraries must be code signed, so the effort of relocating the Python framework becomes that more difficult.

Ideally the official macOS framework would be built as relocatable, eliminating the need to modify it and re-sign it to use it anywhere other than  /Library/Frameworks/Python.framework.
msg382173 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2020-11-30 18:55
There's also macholib (which is used by py2app for rewriting mach-o headers). 

Note that resigning for arm64 is possible using the following command:

$ codesign -s - --preserve-metadata=identifier,entitlements,flags,runtime -f <path to mach-O>.

This was mentioned in the Xcode 12 release notes.

BTW. My hobby horse w.r.t. a relocatable Python installation is to turn the current framework inside out: have a "Python.app" or "Python 3.10.app" that contains the framework and presents a GUI when double clicked (probably IDLE with some additional menu items). This would simplify the installation experience (no installer, just drop Python.app somewhere convenient).   

I have no idea if I'll ever get around to implementing this.
msg382180 - (view) Author: Greg Neagle (gregneagle) Date: 2020-11-30 19:19
A Python.app you could drop somewhere convenient would by definition need a relocatable Python.framework within. :-)
History
Date User Action Args
2021-01-21 18:23:07tomgoddardsetnosy: + tomgoddard
2020-11-30 19:19:54gregneaglesetmessages: + msg382180
2020-11-30 18:55:47ronaldoussorensetmessages: + msg382173
2020-11-30 18:28:37gregneaglecreate