Skip to content

Commit 795ca5f

Browse files
Add missing freeze setup.py, see pyQode/pyQode#46
1 parent 40d5740 commit 795ca5f

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

examples/pynotepad/freeze_setup.py

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
"""
4+
This setup script build a frozen distribution of the application (with the
5+
python interpreter and 3rd party libraries embedded) for Windows.
6+
7+
Run the following command to freeze the app (the frozen executable can be
8+
found in the bin folder::
9+
10+
python freeze_setup.py build
11+
12+
"""
13+
import os
14+
import sys
15+
from cx_Freeze import setup, Executable
16+
import shutil
17+
from pyqode.core.api.syntax_highlighter import get_all_styles
18+
from pyqode.python.backend import server
19+
from pynotepad import __version__
20+
21+
22+
# automatically build when run without arguments
23+
if len(sys.argv) == 1:
24+
sys.argv.append("build")
25+
26+
# collect pygments styles
27+
pygments_styles = []
28+
for s in get_all_styles():
29+
module = 'pygments.styles.%s' % s.replace('-', '_')
30+
try:
31+
__import__(module)
32+
except ImportError:
33+
pass
34+
else:
35+
pygments_styles.append(module)
36+
print('pygment styles', pygments_styles)
37+
38+
39+
# Build options
40+
options = {
41+
"excludes": ["PyQt5.uic.port_v3", "PySide", "tcltk", "jedi"],
42+
"namespace_packages": ["pyqode.core"],
43+
"include_msvcr": True,
44+
"build_exe": "bin",
45+
"includes": ["pkg_resources"] + pygments_styles
46+
}
47+
48+
49+
# Run the cxFreeze setup
50+
setup(name="Notepad",
51+
version=__version__,
52+
options={"build_exe": options},
53+
executables=[
54+
Executable("pynotepad.py", targetName="PyNotepad.exe",
55+
icon='share/qidle.ico',
56+
base="Win32GUI"),
57+
Executable(server.__file__,
58+
targetName="server.exe")])
59+
60+
61+
# NOTE: if you are using PyQt5, you will have to copy libEGL.dll manually
62+
try:
63+
import PyQt5
64+
except ImportError:
65+
pass # pyqt4 or pyqside
66+
else:
67+
shutil.copy(os.path.join(os.path.dirname(PyQt5.__file__), 'libEGL.dll'), 'bin')
68+
69+
70+
# cx_freeze has some issues embedding the jedi package, let's do it ourself
71+
import jedi
72+
try:
73+
shutil.copytree(os.path.dirname(jedi.__file__), 'bin/jedi')
74+
except FileExistsError:
75+
pass
76+
77+
# also copy server.py in order to be able to run on external interpreters
78+
shutil.copy(server.__file__, 'bin')

0 commit comments

Comments
 (0)