Skip to content

Swift Package to embed Python into a macOS app

Notifications You must be signed in to change notification settings

r0ml/Caerbannog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Caerbannog

This has been superseded by SwiftyPython

This package embeds a Python interpreter into a macOS app. It also provides the support to allow a Python module to be written in Swift and be imported and called from the Python code.

To build a macOS app that embeds Python and allows calling into or migrating code into Swift, one adds this package as a dependency. Then, create a python virtual environment containing the required Python dependencies and sources. Embed the virtual environment as the Resource folder 'venv'.

A sample application using Caerbannog is in the github repository r0ml/CaerbannogSample

============================

  1. I need to embed the Python3.framework from XCode-beta in the application that uses Caerbannog because I can't embed it in the package
  2. I need to set the Framework search path in the application to include /Applications/Xcode-beta.app/Contents/Developer/Library/Frameworks/ because the Xcode-beta library path for included frameworks is not searched by default
  3. the "code sign after copy" option on the Python3.framework needs to be disabled (because the codesign fails)
  4. need to "disable library validation" on the 'signing and capabilities' tab because codesigning was disabled on the embedded framework.
  5. Create a virtual environment in the app, and pip install the necessary frameworks. Change directory to the root directory of the application and run 'python3 -m venv venv' followed by '. venv/bin/activate'

========================================================

  1. Also see: Beeware (https://beeware.org) , Pyto (https://pyto.app)

About

Swift Package to embed Python into a macOS app

Resources

Stars

Watchers

Forks

Packages

No packages published