Reputation: 2676
I have been looking up how to convert a .py script into an .app application so the users know how to run it. So far I have only found using py2app or pyinstaller. Is there a significant disadvantage using an application generated by exporting the following script into application and putting my python script into the application's resource folder? (My python script has a GUI and only uses a built-in library in python 2.7.)
tell application "Finder"
if exists POSIX file "/Applications/app.app/Contents/Resources/appname.py" then
tell application "Terminal"
do script "python /Applications/app.app/Contents/Resources/appname.py"
end tell
else if exists POSIX file "/Volumes/appname/appname.py" then
tell application "Terminal"
do script "python /Volumes/appname/appname.py"
end tell
else
display dialog "Please copy the file to the Application folder, or mount the installation diskimage"
end if
end tell
tell application "Terminal"
close
end tell
It works fine on my computer, so I am just curious why I couldn't find it on the Internet.
Upvotes: 0
Views: 632
Reputation: 3444
There are two things I would advise.
path to current application
so that you have the path no matter
where the app is.What may be "cleaner" is, instead of using the Terminal, use do shell script
like:
do shell script "/path/to/my/script/script.py"
as long as the script is "chmod"-ed to be executable (I also like using a utility called "Kilometre" for this)
Apart from that, there's nothing dangerous or wrong about what you're trying to do.
Upvotes: 2