我有这个python脚本:
#!/usr/bin/python3
import sys
import platform
from PyQt5.QtWidgets import (QWidget, QApplication, QDesktopWidget)
from PyQt5.QtCore import QCoreApplication
class Example(QWidget):
# Constructur
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.setGeometry(300, 300, 300, 200)
self.setWindowTitle('My Qt5 window')
self.center()
self.show()
def center(self):
qr = self.frameGeometry()
cp = QDesktopWidget().availableGeometry().center()
qr.moveCenter(cp)
self.move(qr.topLeft())
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())
当我用py2app打包时,我得到一个240MB大小的应用程序。有没有办法减小尺寸?我不认为有必要打包整个PyQt5模块。
编辑:这是我的setup.py
来自setuptools导入设置
APP = ['pyqt5_test.py']
APP_NAME = "SuperApp"
DATA_FILES = []
OPTIONS = {
'argv_emulation': True,
'iconfile': 'kraken.icns',
'plist': {
'CFBundleName': APP_NAME,
'CFBundleDisplayName': APP_NAME,
'CFBundleGetInfoString': "Making Sandwiches",
'CFBundleIdentifier': "com.metachris.osx.sandwich",
'CFBundleVersion': "0.1.0",
'CFBundleShortVersionString': "0.1.0",
'NSHumanReadableCopyright': u"Copyright © 2017, Someone, All Rights Reserved"
}
}
setup(
app=APP,
name=APP_NAME,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)