Skip to content

Commit

Permalink
Merge branch 'master' of github.com:SimplyY/zhihu_pyqt
Browse files Browse the repository at this point in the history
  • Loading branch information
SimplyY authored and SimplyY committed Aug 1, 2015
2 parents 357dc26 + c95d587 commit 9c491c3
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 28 deletions.
8 changes: 0 additions & 8 deletions entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,4 @@
if hasattr(sys, 'frozen') is False:
path = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, os.path.join(path, "zhihurss"))
elif sys.platform == 'win32':
import win32api
ASADMIN = 'asadmin'

if sys.argv[-1] != ASADMIN:
params = ' '.join(sys.argv[1:] + [ASADMIN])
win32api.ShellExecute(0, 'runas', sys.executable, params, os.path.abspath(os.curdir), 1)
sys.exit(0)
run()
116 changes: 96 additions & 20 deletions freeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,116 @@

shutil.rmtree("build", ignore_errors=True)

packages = [
"zhihu",
"lxml",
"PyQt5.QtQuick",
"PyQt5.QtCore",
"PyQt5.QtWidgets",
"PyQt5.QtQml",
"PyQt5.QtNetwork"
]
platform = sys.platform

# ===== set PyQt5 dir =====

if platform == 'win32':
PYQT5_DIR = os.path.join(get_python_lib(), "PyQt5")
elif platform == 'darwin':
# TODO
PYQT5_DIR = os.path.join(get_python_lib(), "PyQt5")
elif platform == 'linux':
# TODO
PYQT5_DIR = os.path.join(get_python_lib(), "PyQt5")

print('check PyQt5 dir: {0}'.format(PYQT5_DIR), '...')

if not os.path.exists(PYQT5_DIR):
print("Can't find PyQt5's dir automatically, Please set it in freeze.py")
sys.exist(0)

QML_DIR = os.path.join(get_python_lib(), "PyQt5", 'qml')
print('Done.')

# ===== set qml dir =====

if platform == 'win32':
QML_DIR = os.path.join(PYQT5_DIR, 'qml')
elif platform == 'darwin':
# TODO
QML_DIR = ''
elif platform == 'linux':
# TODO
QML_DIR = ''

print('check QML dir: {0}'.format(QML_DIR), '...')

if os.path.exists(QML_DIR) is False:
print("Can't find PyQt5's QML dir automatically, Please set it dir in freeze.py")
if not os.path.exists(QML_DIR):
print("Can't find PyQt5's QML dir automatically, Please set it in freeze.py")
sys.exist(0)

print('Done.')

include_files = [
("zhihurss/res/qml/", "qml"),
(os.path.join(QML_DIR, "QtQuick"), "QtQuick"),
(os.path.join(QML_DIR, "QtQuick.2"), "QtQuick.2"),
(os.path.join(QML_DIR, "QtWebKit"), "QtWebKit")
# ===== setup include files =====

# ----- qt files -----

if platform == 'win32':
qt_files_list = [
'libEGL.dll',
'libGLESv2.dll',
'QtWebProcess.exe',
'Qt5WebKitWidgets.dll',
'Qt5MultimediaWidgets.dll',
'Qt5OpenGL.dll',
'Qt5PrintSupport.dll'
]
elif platform == 'darwin':
pass
elif platform == 'linux':
pass

qt_files = [os.path.join(PYQT5_DIR, filename) for filename in qt_files_list]

# ----- qml dirs -----

if platform == 'win32':
qml_dirs_list = [
"QtQuick",
"QtQuick.2",
"QtWebKit"
]
elif platform == 'darwin':
# TODO
qml_dirs_list = []
elif platform == 'linux':
# TODO
qml_dirs_list = []

qml_dirs = [(os.path.join(QML_DIR, dirname), dirname) for dirname in qml_dirs_list]

# ----- res files -----

res_files = [("zhihurss/res/qml/", "qml")]

# ----- platfrom extra files -----

if platform == 'win32':
extra_files = []
elif platform == 'darwin':
extra_files = []
elif platform == 'linux':
extra_files = []

# ----- complete include files -----

include_files = qt_files + qml_dirs + res_files + extra_files

# ===== others =====

packages = [
'lxml'
]

base = None

if sys.platform == "win32":
if platform == "win32":
base = "Win32GUI"

with open('README.md', 'rb') as f:
readme = f.read().decode('utf-8')

# ===== setup for build =====

setup(
name=application_title,
version="1.0.0",
Expand All @@ -58,7 +133,8 @@
options={
"build_exe": {
"packages": packages,
"include_files": include_files
"include_files": include_files,
"include_msvcr": True if sys.platform == 'win32' else False
}
},
executables=[Executable(main_python_file, base=base, targetName=application_title+'.exe')],
Expand Down
1 change: 1 addition & 0 deletions zhihurss/util/my_pyqt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import sys

from PyQt5 import QtWebKit
from PyQt5.QtCore import QUrl, QObject, QVariant, QMetaObject, Q_ARG, Qt
from PyQt5.QtWidgets import QApplication
from PyQt5.QtQuick import QQuickView
Expand Down

0 comments on commit 9c491c3

Please sign in to comment.