How to fix setup.py file at py2app - python

I have spent weeks creating a stand-alone application using py2app for my project but nothing works. Actually, I have created a setup.py file and add all packages I am using but the application from dist do not work but using terminal works. For example, I created an app with PyQt5 add all packages and it was working. But in my project, there are a lot of libs and another problem is that I need to add backend and some other modules to stand alone version.
"""
This is a setup.py script generated by py2applet
Usage:
python setup.py py2app
"""
from setuptools import setup
APP = ['__main__.py']
DATA_FILES = []
OPTIONS = {'argv_emulation': True, 'site_packages': True, 'includes':['Brotli', 'certifi', 'chardet', 'click', 'dash', 'dash-core-components', 'dash-html-components', 'dash-renderer', 'dash-table', 'Flask', 'Flask-Compress', 'future', 'idna', 'itsdangerous', 'Jinja2', 'joblib', 'MarkupSafe', 'numpy', 'ordered-set', 'pandas', 'plotly', 'PyLaTeX', 'PyQt5', 'PyQt5-sip', 'python-dateutil', 'pytz', 'requests', 'retrying', 'scikit-learn', 'scipy', 'six', 'sklearn', 'threadpoolctl', 'urllib3', 'Werkzeug', 'xlrd', 'pandas._libs.tslibs.base', ]}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
the full project includes: main.py, dist backend, GUI, logs
what do I need to add to setup.py?

Related

App crashes on launch after compiled by py2app if 'requests' is included

My .app launches if i don't have the requests module imported into my app, but if it's included it crashes when trying to launch the .app compiled by py2app. I've tried to include requests into Setup.py and it still crashes.
i have py2app-0.21 installed.Running Python 3.6.4, MacOs Catalina 10.15.14
error log from console:
(org.pythonmac.unspecified.testapp.2888[62145]): Service exited with abnormal code: 255
Setup.py
from setuptools import setup
APP = ['test.py']
DATA_FILES = []
OPTIONS = {
'argv_emulation': True,
'includes': ['requests'],
'packages': ['requests', 'rumps']
}
setup(
app=APP,
name='TestApp',
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
The unspecified.testapp part of your error log tells me that you need to tell python where your app file actually is (relative path? absolute path? that will depend on your usecase)
Use some pathname manipulation to point to test.py

Setup.py with py2app including pip packages

I built a keylogger in python and I used py2exe (version 0.13) to convert the python file to an exe. It worked perfectly, it included all the packages and everything.
I want my keylogger to come to mac also, so I tried to use py2app. I followed TheBlackBerryChannels tutorial. It was pretty good explaining everything but it didn't show how to install external packages that are installed from pip. Becuase I use the from pynput.keyboard import Key, Listener
import os
import datetime
from pathlib import Path
packages from pip.
In the full setup.py file this is what I have:
from setuptools import setup
APP = ['KeyLoggingMac.py']
OPTIONS = {
# 'iconfile':'logoapp.icns',
'argv_emulation': True,
'packages': ['pynput']
}
setup(
app=APP,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
What am I doing wrong? It doesn't include the pynput package, I figured that it would auto-include the os, datetime, and pathLib modules but why doesn't it include the pynput?
For simplicity sake in your main file import it like this:
from pynput import keyboard
Then in your setup file use 'includes' in OPTIONS, note that I also added the data file test.txt to write the key presses to a file:
from setuptools import setup
APP = ['TEST.py']
DATA_FILES = ['test.txt']
OPTIONS = {'includes': ['pynput']}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
Then from your venv run py2app with the terminal command:
python setup.py py2app
You can also use py2applet to generate setup.py files but I find it never works properly.
py2applet --make-setup FILENAME.py
You will also need to give the app permission to access your global keyboard events. This is done in Preferences > Security & Privacy > Privacy
Up to Mojave you want the Accessibility tab then add your app in there, on Catalina you want Input Monitoring.
This works for me.

Include CefPython library in setup.py

I am working on packaging our Python app and Py2App on Mac is not including CefPython library which forms the basis of our app. From what I can see in the app contents, it includes the entire Python3 library, but not CEFPython. How can I add CefPython in setup.py? Currently, when I am generating the .app file and executing it, I get an error and Mac asks me if I want to open the console. I see nothing in install.log
setup.py :
"""
This is a setup.py script generated by py2applet
Usage:
python setup.py py2app
"""
from setuptools import setup
APP = ['Our_APP.py']
DATA_FILES = []
OPTIONS = {}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
Updated script
This is a setup.py script generated by py2applet
Usage:
python setup.py py2app
from setuptools import setup
APP = ['20notes.py']
DATA_FILES = []
OPTIONS = {'packages':['cefpython3','objc']}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app','cefpython3']
)
Updated error :
Traceback (most recent call last):
File "setup.py", line 18, in <module>
setup_requires=['py2app','cefpython3'],
TypeError: None is not a string
I have tried removing the comma, removing cefpython3 option, nothing works. Any idea. THank you.
Try adding 'cefpython3' package to OPTIONS:
OPTIONS = {
'packages' : ['cefpython3', 'objc'],
}
Also set this:
os.environ['MACOSX_DEPLOYMENT_TARGET'] = "10.9"

Using py2applet directly instead of setup.py py2app

I am trying to create a py2app application on a Mac OS X 10.6 Server. I downloaded and installed py2app, but I can't get it to work (I get a "is a directory error"). The same exact code and setup.py file work perfectly with py2app on Mac OS X 10.9.
After some research I learned that Mac OS X 10.6 ships with py2applet and that's the one that works. I am trying to run py2applet directly to generate the app.
Here is my setup.py file:
from setuptools import setup
APP = ['app.py']
DATA_FILES = ['resource']
OPTIONS = {'argv_emulation': True, 'includes': ['wx', 'wx.wizard', 'wx.lib.mixins.listctrl']}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
Here is the py2applet command that I am running:
It seems to complete, but the app crashes right away, so I feel like my parameters are wrong.
py2applet -i wx -i wx.wizard -i wx.lib.mixins.listctrl resource app.py
Thank you!

Include openssl in app

I am trying to build a standalone version of Bitmessage for OS X. So far, I have managed to include PyQt4 in the build by having the following setup.py:
from setuptools import setup
APP = ['bitmessagemain.py']
DATA_FILES = []
OPTIONS = {'argv_emulation': True,
'iconfile': '/Users/jackson/Desktop/Bitmessagelogo-reduced.icns', 'includes': ['PyQt4']}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
I can't seem to figure out how to bundle openssl in my includes. Does anyone know?
Py2app should detect a dependency on openssl if there is an import statement for an extension that links with openssl (for example the stdlib SSL support or pyOpenSSL).
That said, py2app will not include the copy of openssl from /usr/lib into your application bundle. Files from system locations (such as /usr/lib and /System) are assumed to be operating system files and are never included in bundles created by py2app.

Categories

Resources