forked from thonny/thonny
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use binary exacutable for launching Thonny in macOS app bundle.
Allows getting rid of postinstall script, makes the bundle relocatable, prepares way for publishing dmg instead of pkg, thonny#3283, thonny#2296
- Loading branch information
1 parent
50e3581
commit 32bfac3
Showing
5 changed files
with
56 additions
and
43 deletions.
There are no files selected for viewing
Binary file modified
BIN
+56.9 KB
(7600%)
packaging/mac/Thonny.app.initial_template/Contents/MacOS/thonny
Binary file not shown.
22 changes: 22 additions & 0 deletions
22
packaging/mac/Thonny.app.initial_template/Contents/Resources/launch.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# inspired by IDLE.app/Contents/IDLE | ||
|
||
import sys | ||
import os.path | ||
|
||
execdir = os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), "MacOS") | ||
executable = os.path.join(execdir, "Python") | ||
resdir = os.path.join(os.path.dirname(execdir), "Resources") | ||
libdir = os.path.join(os.path.dirname(execdir), "Frameworks/Python.framework/Versions/3.12/lib") | ||
ssl_cert_dir = libdir + "/python3.12/site-packages/certifi" | ||
mainprogram = os.path.join(resdir, "thonnymain.py") | ||
|
||
sys.argv.insert(1, mainprogram) | ||
sys.argv.insert(1, "-I") | ||
|
||
os.environ["PYTHON_SYS_EXECUTABLE"] = executable | ||
os.environ["SSL_CERT_DIR"] = ssl_cert_dir | ||
os.environ["SSL_CERT_FILE"] = ssl_cert_dir + "/cacert.pem" | ||
os.environ["TCL_LIBRARY"] = libdir + "/tcl8.6" | ||
os.environ["TK_LIBRARY"] = libdir + "/tk8.6" | ||
|
||
os.execve(executable, sys.argv, os.environ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/zsh | ||
|
||
swiftc -o ../Thonny.app.initial_template/Contents/MacOS/thonny launcher.swift |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import Foundation | ||
|
||
// Get the main bundle path | ||
let bundlePath = Bundle.main.bundlePath | ||
|
||
// Path to the Python interpreter inside the bundle | ||
let pythonPath = "\(bundlePath)/Contents/Frameworks/Python.framework/Versions/Current/Resources/Python.app/Contents/MacOS/Python" | ||
|
||
// Path to the main Python script inside the bundle | ||
let mainScriptPath = "\(bundlePath)/Contents/Resources/launch.py" | ||
|
||
// Ensure Python interpreter and script exist | ||
let fileManager = FileManager.default | ||
if fileManager.fileExists(atPath: pythonPath) && fileManager.fileExists(atPath: mainScriptPath) { | ||
|
||
// Prepare arguments (execv expects C-style array of arguments) | ||
let arguments = [pythonPath, mainScriptPath] | ||
let args = arguments.map { $0.withCString(strdup) } | ||
|
||
// Append nil to the arguments array | ||
let argv = args + [nil] | ||
|
||
// Use execv to replace the current process with the Python interpreter | ||
execv(argv[0]!, argv) | ||
|
||
// If execv returns, it means there was an error | ||
perror("execv failed") | ||
|
||
} else { | ||
print("Python interpreter or main script not found!") | ||
} |
This file was deleted.
Oops, something went wrong.