With python setup.py py2app -AThis post explains how to run Python apps on PC, Mac, Linux, Android, iOS. I can go one step further here. Script Mode After some research, I tried py2app. To quit the Python shell in Windows hit Ctrl+Z followed by the Enter Key, On Linux or Mac hit Ctrl+D followed by Enter key. A program usually consists of sequence of statements. Statements are of different types as we will see.Which obviously cannot be ported to a different system because it uses my development folders. Finally after compilation and installation when I run console form folder of SIP (locally) I can import sipconfig, but when Im in other folder I cant - there is no module called sipconfig.I can create a runnable app. Compatibility: Windows, Linux, Mac OS, IOS, Android, UNIX, AmigaOS, and MorphOS.I'm fighting with installation SIP for Python on Mac OS X. It’s a huge step ahead of the initial Vi, with more powerful features. It is a modal editor that splits file viewing from file editing. Vim is amongst the top 5 in our list of the best text editors for Python.PySide2 must be added under OPTIONS to the packages list References:As my real package is too large for a SO question I trimmed it down to a minimal reproducible example: from PySide3.QtWidgets import *And here is the setup.py file used for py2app: from setuptools import setup Question: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. 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.
![]() ![]() Basically, you are going to put everything into a normal folder with the name of your application. 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. /dist/app.app/Contents/Resources/lib/python3.8/lib-dynload/shiboken2I think what you're missing is the inclusion of the Python3 Framework in your application bundle. /venv/lib/python3.8/site-packages/shiboken2/libshiboken2.abi3.5.15.dylib. Do i need to install drivers for my mouse on macIcns 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. 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: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. So far, here is what you have: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. 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. To Call Help For Python Code In TheAlso, try to downgrade your py2app if it is not working with your current version after you follow the same process. Mkvirtualenv -python="PATH/TO/PYTHON3.6.5/python.exe" venvInstall Qt framework # Install qt via homebrewThen, install the PySide2 git clone -recursive After that, cd pyside-setup & git checkout 5.11Build, and install PySide2 and make sure to set the path of QMAKE that comes with the Qt installation #To get the path# Make sure that your virtual environment is activatedPython setup.py install -qmake= -build-tests -ignore-git -jobs=8Python setup.py build -qmake=/path/to/qmake -build-tests -ignore-git -jobs=8First, 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. First, create a virtual environment and install all modules to the same virtual environment. 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:After fiddling around a lot with the different options to build a macOS bundle for a PySide2 application I found the following steps to work pretty much out of the box.This recipe using pyinstaller to create a macOS app bundle was tested with Python 3.9.1, PySide2 5.15.2, pyinstaller 4.2 on macOS Catalina 10.15.7.Install pyenv and latest Python with Framework support (see Pyenv, How to manage multiple Python versions and virtual environments for a general introduction into how pyenv works): brew install pyenvPYTHON_CONFIGURE_OPTS="-enable-framework" pyenv install 3.9.1Create a folder for the example, create an example pyside application: mkdir hello & cd helloSelf.button = QPushButton("Click say_hello(self, url):Create a venv for the project, install python packages: pyenv local 3.9.1Pip install pip pyside2 pyinstaller -upgradeTry running the app using the python interpreter: python3 hello.pyCreate a macos app bundle: pyinstaller -windowed hello.pyRun the app using the app bundle: open dist/hello.appCheck out the generated hello.spec for the build configuration, re-build the app with pyinstaller hello.spec.I think the solution to your problem can be found here. Also, there are alternatives ways to convert your app to os. /dist/app.app/Contents/MacOS/appIf it is work with python setup.py py2app -A that means that everything is going ok and you need to use rm -rf build distIf any things go wrongs please refer to these references 1, 2, and 3.
0 Comments
Leave a Reply. |
AuthorMissy ArchivesCategories |