我試圖使用py2app建立一個應用程序捆綁有PyQt5並排除不必要的modole,但是,我仍然可以在我的應用程序,它是超過200MB整個PyQt5包py2app不能排除模塊正確
from setuptools import setup
APP = ['browser.py']
DATA_FILES = []
OPTIONS = {'argv_emulation': True, 'includes': ['PyQt5.QtCore', 'PyQt5.QtGui', 'PyQt5.QtWidgets'],
'excludes': ['PyQt5.QtDesigner', 'PyQt5.QtNetwork', 'PyQt5.QtOpenGL', 'PyQt5.QtScript', 'PyQt5.QtSql', 'PyQt5.QtTest','PyQt5.QtXml', 'PyQt5.QtHelp','QtHelp','QtSerialPort','QtHelp.so','PyQt5.QtHelp.so']}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
,這裏是browser.py
from PyQt5.QtCore import QUrl
from PyQt5.QtWidgets import QMainWindow,QApplication
from PyQt5.QtGui import QIcon
from PyQt5.QtWebEngineWidgets import QWebEngineView
import sys
class MainWindow(QMainWindow):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.setWindowTitle('My Browser')
self.setWindowIcon(QIcon('icons/penguin.png'))
self.show()
self.browser = QWebEngineView()
url = 'https://www.google.com/'
self.browser.setUrl(QUrl(url))
self.setCentralWidget(self.browser)
app = QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec_()
謝謝!