• Stars
    star
    155
  • Rank 240,864 (Top 5 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created over 6 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A tool for building standalone relocatable Python.framework bundles
This is a tool to make a relocatable Python framework containing PyObjC.

NOTE: while the resulting frameworks (and interpreters) have been successfully used in several projects (among them Imagr, Munki, and AutoPkg) there is no guarantee it is suitable as a general-purpose Python installation.

A relocatable Python.framework is ideal for embedding into an application's Frameworks directory, and can even be used to get PyObjC-based apps and tools running in the macOS Recovery environment, which does not include Python.

The Python version defaults to 2.7.15, and minimum (or target) macOS version is 10.9. No modules are automatically installed. Previously, the highest supported versions of pip and PyObjC are installed, as is xattr 0.6.4 (this is the version included with macOS High Sierra -- the current version has issues running in Recovery boot). To install these, use --pip-requirements=requirements_python2_recommended.txt to mimic old behavior. In previous versions of this tool on Python versions 3.x and higher, certain modules (xattr, cffi, six and pyobjc) were installed. These can be installed via --pip-requirements=requirements_python3_recommended.txt.

Currently tested versions:
    Python version 2.7.15 with macOS deployment target 10.9+
    Python version 3.7.4 with macOS deployment target 10.9+

Requires at least the command-line developer tools; might require a full Xcode install.

Basic use -- make a Python.framework in the current working directory:
./make_relocatable_python_framework.py

Specifying a target destination for the framework:
./make_relocatable_python_framework.py --destination ~/Desktop

Specifying a different Python version:
./make_relocatable_python_framework.py --python-version 3.7.4

More options:
./make_relocatable_python_framework.py --help

NOTES: 

- As of this commit: https://github.com/gregneagle/relocatable-python/commit/0184e8b43f1ecde050b07feb1761fac2f7ce0c5c, make_relocatable_python_framework.py now uses Apple's Python 3 that is included with Xcode and the Command line development tools. Python 2 was removed from macOS with the release of macOS 12.3. make_relocatable_python_framework.py requires other tools that are included with Xcode/Command Line development tools, so using Xcode's python3 is unlikely to break anyone except perhaps those using the tool on something prior to macOS Catalina + Xcode 11.

- As of this commit: https://github.com/gregneagle/relocatable-python/commit/f4c4110f36ac1cb60b8253c2e04eaf34804f7303, any signed binaries or libraries within the framework will have their signatures removed. The "relocatablizing" process modifies these files, making any signature invalid. Rather than leave an invalid signature, which might seem like potential malware (and which currently causes at least one well-known security tool to _crash_), it's better to remove the invalid signature all together.

- As of this commit: https://github.com/gregneagle/relocatable-python/commit/903c708a01d1a2444ea5648114f3acf6e7f94fd7, instead of removing the signature, we replace it with an ad-hoc signature. This is required for the code to actually run on Apple silicon.

UNIVERSAL PYTHON

As of Python 3.9.11 (Mar 16, 2022), Python.org offers a Universal Python build. If you want to test if your framework is also fully universal, you can use the included "python_universal_tester.sh" script. It takes your version of Python as an argument:
```
% ./python_universal_tester.sh 3.10
Using Python 3.10
All files are universal!
% echo $?
0
```

The script must be run from the same directory as the built Python.framework. If any files are not universal, it will list them and exit 1.

More Repositories

1

pycreateuserpkg

Python tool to create macOS packages that create user accounts
Python
291
star
2

profiles

OS X configuration profiles
167
star
3

Xcode4CocoaPythonTemplates

Templates for Cocoa-Python development with Xcode 4
Python
106
star
4

tile_lock

A riff on @frogor's PSU Mac 2017 hack-a-thon project, using the Tile Mate
Python
31
star
5

psumac2017

Example code for Penn State MacAdmins 2017 presentation: "Turbocharge your scripting with PyObjC"
Python
28
star
6

Xcode6CocoaPythonTemplates

Xcode 6 templates for Cocoa-Python (PyObjC) development
Python
27
star
7

autopkg-packaging-demo

Repo demonstratng the use of autopkg for 'generic' package creation
Shell
21
star
8

PlistEditor

JavaScript
20
star
9

Xcode5CocoaPythonTemplates

A set of Xcode 5 project and file templates for development using Cocoa and Python.
Python
19
star
10

macaduk2017

Example code for MacADUK 2017 presentation: "Introduction to PyObjC"
Python
18
star
11

psumac2014_python

Code snippets and examples for PSU Mac Admins 2014 Conference "Python for Systems Administrators" workshop
Python
18
star
12

makereserializationpkg

Python tool for creating installation packages to reserialize Adobe CS6 products.
Python
16
star
13

mtc2013_python

Code snippets and examples for MacTech Conference 2013 "Python for Systems Administrators" workshop
Python
8
star
14

mactech-cocoa-python-demo

Code corresponding to my MacTech Cocoa-Python demo
Python
4
star
15

pyobjc-helloworld-app

Hello World app in PyObjC
Objective-C
3
star
16

mactechconference2017

Files shared from MacTech Conference 2017
2
star
17

msa2023-chatbot

Resources for MacSysAdmin 2023
Python
2
star