Script To Generate The Plist For Mac
2021年3月1日Download here: http://gg.gg/ohcz5
*What Is A Plist File
*Plist Editor Mac Os
*# Signmeup: A Unix shell script to bind Macs to Apple LDAP and to a Windows domain # # Adapted from www.bombich.com # # As this script contains an admin password, be sure to take appropriate security # precautions # # This script is installed as a system daemon under launchd. With appropriate settings.
*If the script fails to generate a SSDT then please attach the output of:./ssdtPRGen.sh -d 2 and compressed: /Library/ssdtPRGen/ACPI folder. If you are using processor data from Data/User Defined.cfg then I also need to know what that data is.
*Question or issue on macOS: I am developping a simple Python application using a PySide2 GUI. It currently works fine in Windows, Linux and Mac. On Windows, I could use PyInstaller and InnoSetup to build a simple installer. Then I tried to do the same thing on Mac. It soon broke, because the system refused.
Open up your favorite editor on the Mac, I’m going to use Xcode and I’m going to create a script file titled UserCollection.sh. If the typical header information isn’t added automatically by your editor, add it in. Script to generate the plist for Mac OS X 10.7 and higher to maintain a freedns dynamic dns record updated. Once installed, it will ping the freedns service daily as long as the computer can reach the net, whether or not you are logged in as a user on your mac. freedns_plist_creator #!/usr/bin/env bash# Script to generate the plist for Mac OS X 10.7 and higher to maintain a# freedns dynamic dns record updated. Once installed, it will ping the # freedns service daily as long as the computer can reach the net,# whether or not you are logged in as a user on your mac.## You need to edit the variables MY_DOMAIN_NAME and MY_TOKEN with the correct# values you get from the freedns site## Since the plist is stored under /System on your Mac, you must use sudo to# run this script## It uses reverse domain name notation [2] to store a plist on your mac# [2] http://en.wikipedia.org/wiki/Reverse_domain_name_notationMY_DOMAIN_NAME=my.test.comMY_TOKEN=’hthnhn=ddihdt+ddh*idhih’#------------------------------------------------------------------------------# The MIT License (MIT)## Copyright (c) 2013 Juan C. Mendez (jcmendez@alum.mit.edu)## Permission is hereby granted, free of charge, to any person obtaining a copy# of this software and associated documentation files (the ’Software’), to deal# in the Software without restriction, including without limitation the rights# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell# copies of the Software, and to permit persons to whom the Software is# furnished to do so, subject to the following conditions:## The above copyright notice and this permission notice shall be included in# all copies or substantial portions of the Software.## THE SOFTWARE IS PROVIDED ’AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN# THE SOFTWARE.#------------------------------------------------------------------------------PLIST_NAME=`echo ’$MY_DOMAIN_NAME’| awk ’BEGIN{FS=’.’;ORS=’.’} {for (i = NF; i > 0; i--){print $i}}’`cat >’/System/Library/LaunchDaemons/${PLIST_NAME}updater.freedns.plist’<<DOC<?xml version=’1.0’ encoding=’UTF-8’?><!DOCTYPE plist PUBLIC ’-//Apple//DTD PLIST 1.0//EN’ ’http://www.apple.com/DTDs/PropertyList-1.0.dtd’><plist version=’1.0’><dict> <key>KeepAlive</key> <false/> <key>Label</key> <string>${PLIST_NAME}updater</string> <key>ProgramArguments</key> <array> <string>/usr/bin/curl</string> <string>http://freedns.afraid.org/dynamic/update.php?$MY_TOKEN</string> <string>>/dev/null</string> <string>2>&1</string> </array> <key>StartCalendarInterval</key> <dict> <key>Hour</key> <integer>3</integer> <key>Minute</key> <integer>0</integer> </dict></dict></plist>DOCSign up for freeto join this conversation on GitHub. Already have an account? Sign in to commentQuestion or issue on macOS:
I am developping a simple Python application using a PySide2 GUI. It currently works fine in Windows, Linux and Mac. On Windows, I could use PyInstaller and InnoSetup to build a simple installer. Then I tried to do the same thing on Mac. It soon broke, because the system refused to start the command or the app generated by PyInstaller because it was not correctly signed. And as I am not an apple developper, I cannot sign anything…
After some research, I tried py2app. I can go one step further here. With
I can create a runnable app. Which obviously cannot be ported to a different system because it uses my development folders. And if I use python setup.py py2app the generated program cannot start because py2app did not copy all the required Qt stuff. I tried to add one by one the missing libraries, but on the end the system could not find the plugins and I gave up…
Can someone help me with a recipe to convert a python script or package using a Qt GUI into a portable app on Mac? Ideally, the recipe should say how to use a custom application icon, but this is not required.
As my real package is too large for a SO question I trimmed it down to a minimal reproducible example:
And here is the setup.py file used for py2app:What Is A Plist FileHow to solve this problem?Solution no. 1:
Requirements
*works with Python 3.8.5
*macOS 10.15.7 Catalina
*uses PySide2 and py2app
Problems
*PySide2 must be added under OPTIONS to the packages list
*when running the app then still an error occurs: Library not loaded: @rpath/libshiboken2.abi3.5.15.dylib, Reason: image not found
Solution
The slightly modified setup.py could look like this:
Additionally, an icon definition and a few plist entries for some basic information have been added.
The whole build is best triggered with a script that could look like this:
Test
Here the screenshot of a test run:Solution no. 2:
I think what you’re missing is the inclusion of the Python3 Framework in your application bundle. I’ve developed a simple macOS app myself recently, however I wanted to have a little more insight on how to do so, so I did a bit of digging into the actual structure of an application. Basically, you are going to put everything into a normal folder with the name of your application. Call this folder MyApp. Inside this folder we’ll have another called Contents. From my understanding, py2app just takes all of the things that make up your app, and structures them inside of this folder as well as creates an Info.plist file, which also goes inside of Contents. So far, here is what you have:
MyApp
-> Contents
-> -> Info.plist
In addition to the Info.plist file with all of the necessary properties, in your Contents folder you will have a MacOS folder and a Resources folder at minimum. Your issue is that you also need a Frameworks folder, where you would add the required version of Python.
Now, your app hierarchy should look like:
MyApp
-> Contents
-> -> Info.plist
-> -> MacOS
-> -> Resources
-> -> Frameworks
In the Frameworks folder, you can put the full Python 3 framework you’re working with to build the app, as well as any site-packages that you require to run the application, and then you can reflect all of those changes in the executable so that you are pointing to the correct installations.
To my understanding, all that’s necessary to make the application functional on MacOS is to ensure that your main executable is placed in the MacOS folder and points to the Python located in your Frameworks folder, your icon .icns file is placed in the Resources folder, and your Info.plist file is built.
In order for MacOS to recognize it as a full application, I believe you possibly need to use productbuild and include a Developer license certificate, but it’s really only necessary if you want the application to be distributed. Otherwise, I just added the extension .app to MyApp, which converts it into an application.
Without the above-mentioned license/certificate whatever, it probably won’t recognize that it should find your icon file and add it, so if you open it in Preview, select-all, and copy it, you should be able to right-click on the application, press ‘Get Info’, and paste the icon on top of the current icon in the window to make it display correctly.
EDIT: My resources for learning about making macOS apps:Solution no. 3:
I have successfully build apps using fbs.It is intended to build Python+PyQt5 apps (you can also use PySide2) and it should work on Mac OS as well (according to the documentation/tutorial).
Using PyInstaller it failed very often for including PyQt5 dependencies (especially when I was working with pyqtgraph), but with fbs it works great.Solution no. 4:Plist Editor Mac Os
I think the solution to your problem can be found here. First, create a virtual environment and install all modules to the same virtual environment.
Install Qt framework
Then, install the PySide2
After that,
Build, and install PySide2 and make sure to set the path of QMAKE that comes with the Qt installation
Update
First, make sure that you run your code in the same virtual environment, and to convert it to a standard mac OS app you can use py2app or pyinstaller . Also, try to downgrade your py2app if it is not working with your current version after you follow the same process.
Create setup.py
and you have to create a config file or see this example and include any file that you have
To build the application use
To run the app you have to use this way
If it is work with python setup.py py2app -A that means that everything is going ok and you need to use
If any things go wrongs please refer to these references1, 2, and 3. Also, there are alternatives ways to convert your app to os.
After I read your comment, I tried to see what is the problem and I found this and it may solve the problem or you can use alternatives tools such as bbFreeze, pyInstaller or cx_FreezeSolution no. 5:
If you want to package for OSX, you should eitherCreate a Brew Tap
This probably makes the most sense for an open source developer
General Instructions https://docs.brew.sh/How-to-Create-and-Maintain-a-Tap
*host your code in git (does not need to be GitHub)
*create a Formula (Formula Cookbook)
*fork homebrew-core on GitHub
*add your Formula and create a pull request to get it into the main repo
*support your pull request such that it is completedJoin the Apple Developer Program
This probably makes the most sense for a closed source developer
Overview: https://developer.apple.com/programs/how-it-works/
This program costs 99USD annually, but will allow you to sign your package/final binary and distribute it yourself or on their App Store
After creating your account, here’s a guide for packaging and signing for OSX https://developer.apple.com/forums/thread/128166
*structure your code to support signing (add a build step to copy your work into a clean path to avoid frustrating rework)
*% codesign -s <Developer ID Application signing identity> /path/to/code
*pick a storage format (.zip, .dmg, .pkg) and bundle your application as itHope this helps!
Download here: http://gg.gg/ohcz5
https://diarynote.indered.space
*What Is A Plist File
*Plist Editor Mac Os
*# Signmeup: A Unix shell script to bind Macs to Apple LDAP and to a Windows domain # # Adapted from www.bombich.com # # As this script contains an admin password, be sure to take appropriate security # precautions # # This script is installed as a system daemon under launchd. With appropriate settings.
*If the script fails to generate a SSDT then please attach the output of:./ssdtPRGen.sh -d 2 and compressed: /Library/ssdtPRGen/ACPI folder. If you are using processor data from Data/User Defined.cfg then I also need to know what that data is.
*Question or issue on macOS: I am developping a simple Python application using a PySide2 GUI. It currently works fine in Windows, Linux and Mac. On Windows, I could use PyInstaller and InnoSetup to build a simple installer. Then I tried to do the same thing on Mac. It soon broke, because the system refused.
Open up your favorite editor on the Mac, I’m going to use Xcode and I’m going to create a script file titled UserCollection.sh. If the typical header information isn’t added automatically by your editor, add it in. Script to generate the plist for Mac OS X 10.7 and higher to maintain a freedns dynamic dns record updated. Once installed, it will ping the freedns service daily as long as the computer can reach the net, whether or not you are logged in as a user on your mac. freedns_plist_creator #!/usr/bin/env bash# Script to generate the plist for Mac OS X 10.7 and higher to maintain a# freedns dynamic dns record updated. Once installed, it will ping the # freedns service daily as long as the computer can reach the net,# whether or not you are logged in as a user on your mac.## You need to edit the variables MY_DOMAIN_NAME and MY_TOKEN with the correct# values you get from the freedns site## Since the plist is stored under /System on your Mac, you must use sudo to# run this script## It uses reverse domain name notation [2] to store a plist on your mac# [2] http://en.wikipedia.org/wiki/Reverse_domain_name_notationMY_DOMAIN_NAME=my.test.comMY_TOKEN=’hthnhn=ddihdt+ddh*idhih’#------------------------------------------------------------------------------# The MIT License (MIT)## Copyright (c) 2013 Juan C. Mendez (jcmendez@alum.mit.edu)## Permission is hereby granted, free of charge, to any person obtaining a copy# of this software and associated documentation files (the ’Software’), to deal# in the Software without restriction, including without limitation the rights# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell# copies of the Software, and to permit persons to whom the Software is# furnished to do so, subject to the following conditions:## The above copyright notice and this permission notice shall be included in# all copies or substantial portions of the Software.## THE SOFTWARE IS PROVIDED ’AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN# THE SOFTWARE.#------------------------------------------------------------------------------PLIST_NAME=`echo ’$MY_DOMAIN_NAME’| awk ’BEGIN{FS=’.’;ORS=’.’} {for (i = NF; i > 0; i--){print $i}}’`cat >’/System/Library/LaunchDaemons/${PLIST_NAME}updater.freedns.plist’<<DOC<?xml version=’1.0’ encoding=’UTF-8’?><!DOCTYPE plist PUBLIC ’-//Apple//DTD PLIST 1.0//EN’ ’http://www.apple.com/DTDs/PropertyList-1.0.dtd’><plist version=’1.0’><dict> <key>KeepAlive</key> <false/> <key>Label</key> <string>${PLIST_NAME}updater</string> <key>ProgramArguments</key> <array> <string>/usr/bin/curl</string> <string>http://freedns.afraid.org/dynamic/update.php?$MY_TOKEN</string> <string>>/dev/null</string> <string>2>&1</string> </array> <key>StartCalendarInterval</key> <dict> <key>Hour</key> <integer>3</integer> <key>Minute</key> <integer>0</integer> </dict></dict></plist>DOCSign up for freeto join this conversation on GitHub. Already have an account? Sign in to commentQuestion or issue on macOS:
I am developping a simple Python application using a PySide2 GUI. It currently works fine in Windows, Linux and Mac. On Windows, I could use PyInstaller and InnoSetup to build a simple installer. Then I tried to do the same thing on Mac. It soon broke, because the system refused to start the command or the app generated by PyInstaller because it was not correctly signed. And as I am not an apple developper, I cannot sign anything…
After some research, I tried py2app. I can go one step further here. With
I can create a runnable app. Which obviously cannot be ported to a different system because it uses my development folders. And if I use python setup.py py2app the generated program cannot start because py2app did not copy all the required Qt stuff. I tried to add one by one the missing libraries, but on the end the system could not find the plugins and I gave up…
Can someone help me with a recipe to convert a python script or package using a Qt GUI into a portable app on Mac? Ideally, the recipe should say how to use a custom application icon, but this is not required.
As my real package is too large for a SO question I trimmed it down to a minimal reproducible example:
And here is the setup.py file used for py2app:What Is A Plist FileHow to solve this problem?Solution no. 1:
Requirements
*works with Python 3.8.5
*macOS 10.15.7 Catalina
*uses PySide2 and py2app
Problems
*PySide2 must be added under OPTIONS to the packages list
*when running the app then still an error occurs: Library not loaded: @rpath/libshiboken2.abi3.5.15.dylib, Reason: image not found
Solution
The slightly modified setup.py could look like this:
Additionally, an icon definition and a few plist entries for some basic information have been added.
The whole build is best triggered with a script that could look like this:
Test
Here the screenshot of a test run:Solution no. 2:
I think what you’re missing is the inclusion of the Python3 Framework in your application bundle. I’ve developed a simple macOS app myself recently, however I wanted to have a little more insight on how to do so, so I did a bit of digging into the actual structure of an application. Basically, you are going to put everything into a normal folder with the name of your application. Call this folder MyApp. Inside this folder we’ll have another called Contents. From my understanding, py2app just takes all of the things that make up your app, and structures them inside of this folder as well as creates an Info.plist file, which also goes inside of Contents. So far, here is what you have:
MyApp
-> Contents
-> -> Info.plist
In addition to the Info.plist file with all of the necessary properties, in your Contents folder you will have a MacOS folder and a Resources folder at minimum. Your issue is that you also need a Frameworks folder, where you would add the required version of Python.
Now, your app hierarchy should look like:
MyApp
-> Contents
-> -> Info.plist
-> -> MacOS
-> -> Resources
-> -> Frameworks
In the Frameworks folder, you can put the full Python 3 framework you’re working with to build the app, as well as any site-packages that you require to run the application, and then you can reflect all of those changes in the executable so that you are pointing to the correct installations.
To my understanding, all that’s necessary to make the application functional on MacOS is to ensure that your main executable is placed in the MacOS folder and points to the Python located in your Frameworks folder, your icon .icns file is placed in the Resources folder, and your Info.plist file is built.
In order for MacOS to recognize it as a full application, I believe you possibly need to use productbuild and include a Developer license certificate, but it’s really only necessary if you want the application to be distributed. Otherwise, I just added the extension .app to MyApp, which converts it into an application.
Without the above-mentioned license/certificate whatever, it probably won’t recognize that it should find your icon file and add it, so if you open it in Preview, select-all, and copy it, you should be able to right-click on the application, press ‘Get Info’, and paste the icon on top of the current icon in the window to make it display correctly.
EDIT: My resources for learning about making macOS apps:Solution no. 3:
I have successfully build apps using fbs.It is intended to build Python+PyQt5 apps (you can also use PySide2) and it should work on Mac OS as well (according to the documentation/tutorial).
Using PyInstaller it failed very often for including PyQt5 dependencies (especially when I was working with pyqtgraph), but with fbs it works great.Solution no. 4:Plist Editor Mac Os
I think the solution to your problem can be found here. First, create a virtual environment and install all modules to the same virtual environment.
Install Qt framework
Then, install the PySide2
After that,
Build, and install PySide2 and make sure to set the path of QMAKE that comes with the Qt installation
Update
First, make sure that you run your code in the same virtual environment, and to convert it to a standard mac OS app you can use py2app or pyinstaller . Also, try to downgrade your py2app if it is not working with your current version after you follow the same process.
Create setup.py
and you have to create a config file or see this example and include any file that you have
To build the application use
To run the app you have to use this way
If it is work with python setup.py py2app -A that means that everything is going ok and you need to use
If any things go wrongs please refer to these references1, 2, and 3. Also, there are alternatives ways to convert your app to os.
After I read your comment, I tried to see what is the problem and I found this and it may solve the problem or you can use alternatives tools such as bbFreeze, pyInstaller or cx_FreezeSolution no. 5:
If you want to package for OSX, you should eitherCreate a Brew Tap
This probably makes the most sense for an open source developer
General Instructions https://docs.brew.sh/How-to-Create-and-Maintain-a-Tap
*host your code in git (does not need to be GitHub)
*create a Formula (Formula Cookbook)
*fork homebrew-core on GitHub
*add your Formula and create a pull request to get it into the main repo
*support your pull request such that it is completedJoin the Apple Developer Program
This probably makes the most sense for a closed source developer
Overview: https://developer.apple.com/programs/how-it-works/
This program costs 99USD annually, but will allow you to sign your package/final binary and distribute it yourself or on their App Store
After creating your account, here’s a guide for packaging and signing for OSX https://developer.apple.com/forums/thread/128166
*structure your code to support signing (add a build step to copy your work into a clean path to avoid frustrating rework)
*% codesign -s <Developer ID Application signing identity> /path/to/code
*pick a storage format (.zip, .dmg, .pkg) and bundle your application as itHope this helps!
Download here: http://gg.gg/ohcz5
https://diarynote.indered.space
コメント