-
Notifications
You must be signed in to change notification settings - Fork 25
/
freeze.py
executable file
·152 lines (115 loc) · 3.16 KB
/
freeze.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
application_title = "zhihu-rss"
main_python_file = "entry.py"
import sys
import os
import shutil
from distutils.sysconfig import get_python_lib
from cx_Freeze import setup, Executable
shutil.rmtree("build", ignore_errors=True)
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.exit(0)
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':
QML_DIR = '/usr/lib/x86_64-linux-gnu/qt5/qml'
print('check QML dir: {0}'.format(QML_DIR), '...')
if not os.path.exists(QML_DIR):
print("Can't find PyQt5's QML dir automatically, Please set it in freeze.py")
sys.exit(0)
print('Done.')
# ===== 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':
qt_files_list = []
elif platform == 'linux':
qt_files_list = []
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':
qml_dirs_list = [
"QtQuick",
"QtQuick.2",
"QtWebKit"
]
qml_dirs = [(os.path.join(QML_DIR, dirname), dirname)
for dirname in qml_dirs_list]
# ----- res files -----
res_files = [
("zhihurss/res/qml/", "qml"),
('zhihurss/config/', 'config')
]
# ----- 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
targetName = 'zhihurss'
if platform == "win32":
base = "Win32GUI"
targetName += '.exe'
with open('README.md', 'rb') as f:
readme = f.read().decode('utf-8')
# ===== setup for build =====
setup(
name=application_title,
version="1.0.0",
url='https://github.com/SimplyY',
author='SimplyY',
description="zhihu-rss",
long_description=readme,
options={
"build_exe": {
"packages": packages,
"include_files": include_files,
"include_msvcr": True if sys.platform == 'win32' else False
}
},
executables=[Executable(main_python_file, base=base, targetName=targetName)]
)