Skip to content

Commit f94eaa6

Browse files
committed
Add PyInstaller packager example (cztomczak#135)
1 parent 9c567bf commit f94eaa6

File tree

13 files changed

+487
-14
lines changed

13 files changed

+487
-14
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.idea/
22
build/
3+
dist/
34
*.log
45
__pycache__/
56
*.pyc

README.md

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
Table of contents:
44
* [Introduction](#introduction)
55
* [Major sponsors](#major-sponsors)
6-
* [Funding request - v60.0 release](#funding-request---v600-release)
6+
* [Funding for v60.0 release](#funding-for-v600-release)
77
* [Install](#install)
88
* [Tutorial](#tutorial)
99
* [Examples](#examples)
1010
* [Support](#support)
1111
* [Support development](#support-development)
1212
* [Thanks](#thanks)
1313
* [Releases](#releases)
14+
* [Other READMEs](#other-readmes)
1415
* [Quick links](#quick-links)
1516

1617

@@ -23,7 +24,7 @@ projects. The Chromium project focuses mainly on Google Chrome application
2324
development, while CEF focuses on facilitating embedded browser use cases
2425
in third-party applications. Lots of applications use CEF control, there are
2526
more than [100 million CEF instances](http://en.wikipedia.org/wiki/Chromium_Embedded_Framework#Applications_using_CEF)
26-
installed around the world. [Examples of embedding](examples/Examples-README.md)
27+
installed around the world. [Examples of embedding](examples/README-examples.md)
2728
Chrome browser are available for many popular GUI toolkits including:
2829
wxPython, PyGTK, PyQt, PySide, Kivy, Panda3D and PyGame/PyOpenGL.
2930

@@ -60,7 +61,7 @@ See the [Support development](#support-development) section for a list of
6061
all the individuals and companies supporting CEF Python.
6162

6263

63-
## Funding request - v60.0 release
64+
## Funding for v60.0 release
6465

6566
For those interested in sponsoring a v60.0 release please see
6667
[Issue #370](../../issues/370).
@@ -88,13 +89,13 @@ See the [Tutorial.md](docs/Tutorial.md) file.
8889

8990
## Examples
9091

91-
See the [Examples-README.md](examples/Examples-README.md) file.
92+
See the [README-examples.md](examples/README-examples.md) file.
9293

9394

9495
## Support
9596

9697
- Ask questions, report problems and issues on the [Forum](https://groups.google.com/group/cefpython)
97-
- Supported examples are listed in the [Examples-README.md](examples/Examples-README.md) file
98+
- Supported examples are listed in the [README.md](examples/README-examples.md) file
9899
- Documentation is in the [docs/](docs) directory:
99100
- [Build instructions](docs/Build-instructions.md)
100101
- [Contributing code](docs/Contributing-code.md)
@@ -193,6 +194,12 @@ Additional information for v31.2 release:
193194
- API reference is available in revision [169a1b2](../../tree/169a1b20d3cd09879070d41aab28cfa195d2a7d5/docs/api)
194195

195196

197+
## Other READMEs
198+
199+
- [PyInstaller packager](examples/pyinstaller/README-pyinstaller.md)
200+
201+
202+
196203
## Quick links
197204

198205
### Docs
@@ -203,8 +210,8 @@ Additional information for v31.2 release:
203210
- [Tutorial](docs/Tutorial.md)
204211

205212

206-
### API categories
207-
213+
### API categories
214+
208215
#### Modules
209216

210217
* [cefpython](api/cefpython.md#cefpython) module
@@ -259,11 +266,12 @@ Additional information for v31.2 release:
259266
* [StringVisitor](api/StringVisitor.md#stringvisitor-interface) interface
260267
* [WebRequestClient](api/WebRequestClient.md#webrequestclient-interface) interface
261268

262-
263-
### API index
264-
269+
270+
### API index
271+
265272
* [Application settings](api/ApplicationSettings.md#application-settings)
266273
* [accept_language_list](api/ApplicationSettings.md#accept_language_list)
274+
* [app_user_model_id](api/ApplicationSettings.md#app_user_model_id)
267275
* [auto_zooming](api/ApplicationSettings.md#auto_zooming)
268276
* [background_color](api/ApplicationSettings.md#background_color)
269277
* [browser_subprocess_path](api/ApplicationSettings.md#browser_subprocess_path)

api/API-index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
* [Application settings](ApplicationSettings.md#application-settings)
66
* [accept_language_list](ApplicationSettings.md#accept_language_list)
7+
* [app_user_model_id](ApplicationSettings.md#app_user_model_id)
78
* [auto_zooming](ApplicationSettings.md#auto_zooming)
89
* [background_color](ApplicationSettings.md#background_color)
910
* [browser_subprocess_path](ApplicationSettings.md#browser_subprocess_path)

docs/Examples.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Examples
22

33
Examples are available in the examples/ root directory. See
4-
the [Examples-README.md](../examples/Examples-README.md) file.
4+
the [README-examples.md](../examples/README-examples.md) file.

docs/Tutorial.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ basics. This tutorial will discuss the three featured examples:
99
[hello_world.py](../examples/hello_world.py),
1010
[tutorial.py](../examples/tutorial.py)
1111
and [screenshot.py](../examples/screenshot.py). There are many
12-
more examples that you can find in the [Examples-README.md](../examples/Examples-README.md)
12+
more examples that you can find in the [README-examples.md](../examples/README-examples.md)
1313
file, but these examples are out of scope for this tutorial.
1414

1515

@@ -423,7 +423,7 @@ Frame object also has the same methods.
423423
You can also serve requests directly in CEF using for example
424424
[ResourceHandler](../api/ResourceHandler.md) object. You can find
425425
an example usage of this object in one of examples listed in
426-
the [Examples-README.md](../examples/Examples-README.md) file.
426+
the [README-examples.md](../examples/README-examples.md) file.
427427

428428
On a side note, upstream CEF also supports custom scheme handlers,
429429
however these APIs were not yet exposed to CEF Python.
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ maintained. If there are any issues in examples read top comments
2525
in sources to see whether this is a known issue with available
2626
workarounds.
2727

28+
2829
**Featured**
2930

3031
- [hello_world.py](hello_world.py) - Basic example, doesn't require any
@@ -35,6 +36,7 @@ workarounds.
3536
discussed in great details in Tutorial in the [Off-screen rendering](../docs/Tutorial.md#off-screen-rendering)
3637
section.
3738

39+
3840
**Embedding using various GUI frameworks**
3941

4042
- [gtk2.py](gtk2.py): example for [PyGTK](http://www.pygtk.org/)
@@ -49,6 +51,14 @@ workarounds.
4951
- [wxpython.py](wxpython.py): example for [wxPython](https://wxpython.org/)
5052
toolkit
5153

54+
55+
**Build executable using Python packagers**
56+
57+
- [PyInstaller example](pyinstaller/README-pyinstaller.md):
58+
example of packaging app using [PyInstaller](http://www.pyinstaller.org/)
59+
packager
60+
61+
5262
**Unit tests**
5363

5464
There are also available unit tests and its usage of the API can
@@ -58,7 +68,7 @@ be of some use. See [main_test.py](../unittests/main_test.py).
5868
## More examples
5969

6070
There are even more examples available, some of them are externally
61-
maintained.
71+
maintained.
6272

6373
- Kivy framework:
6474
see [Kivy](https://github.com/cztomczak/cefpython/wiki/Kivy) wiki page.
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# PyInstaller example
2+
3+
Table of contents:
4+
* [Package app](#package-app)
5+
* [When it succeeds](#when-it-succeeds)
6+
* [Fatal error](#fatal-error)
7+
* [Debug app](#debug-app)
8+
* [More details](#more-details)
9+
10+
11+
## Package app
12+
13+
This is an example of using [PyInstaller](http://www.pyinstaller.org/)
14+
packager to build executable from one of CEF Python's examples
15+
(wxpython.py). Only Windows platform is currently supported.
16+
17+
To install required packages type:
18+
```
19+
pip install --upgrade pyinstaller pycrypto
20+
```
21+
22+
To package example type:
23+
```
24+
python pyinstaller.py
25+
```
26+
27+
28+
## When it succeeds
29+
30+
If packaging succeeds you should see "dist/cefapp/" directory open
31+
in explorer on Windows. In there you will find "cefapp.exe" executable
32+
that you can launch.
33+
34+
![cefapp directory](screenshots/cefapp_directory.jpg)
35+
36+
37+
## Fatal error
38+
39+
If there is a "Fatal Error!" message box appearing when running app
40+
then see the next section for how to debug app.
41+
42+
![Fatal Error](screenshots/cefapp_fatal_error.jpg)
43+
44+
45+
## Debug app
46+
47+
In case of a fatal error to debug app pass "--debug" flag when
48+
packaging app:
49+
50+
```
51+
python pyinstaller.py --debug
52+
```
53+
54+
After packaging completes on Windows it will open a new CMD window
55+
and run the cefapp.exe inside it. You should see detailed logs
56+
in console like these:
57+
58+
```
59+
[6708] PyInstaller Bootloader 3.x
60+
[6708] LOADER: executable is \examples\pyinstaller\dist\cefapp\cefapp.exe
61+
[6708] LOADER: homepath is \examples\pyinstaller\dist\cefapp
62+
[6708] LOADER: _MEIPASS2 is NULL
63+
[6708] LOADER: archivename is \examples\pyinstaller\dist\cefapp\cefapp.exe
64+
[6708] LOADER: No need to extract files to run; setting extractionpath to homepath
65+
[6708] LOADER: SetDllDirectory(\examples\pyinstaller\dist\cefapp)
66+
[6708] LOADER: Already in the child - running user's code.
67+
[6708] LOADER: Python library: \examples\pyinstaller\dist\cefapp\python27.dll
68+
[6708] LOADER: Loaded functions from Python library.
69+
[6708] LOADER: Manipulating environment (sys.path, sys.prefix)
70+
[6708] LOADER: sys.prefix is C:\github\CEFPYT~2\examples\PYINST~1\dist\cefapp
71+
[6708] LOADER: Setting runtime options
72+
[6708] LOADER: Initializing python
73+
[6708] LOADER: Overriding Python's sys.path
74+
[6708] LOADER: Post-init sys.path is \examples\pyinstaller\dist\cefapp
75+
[6708] LOADER: Setting sys.argv
76+
[6708] LOADER: setting sys._MEIPASS
77+
[6708] LOADER: importing modules from CArchive
78+
[6708] LOADER: extracted pyimod00_crypto_key
79+
[6708] LOADER: callfunction returned...
80+
[6708] LOADER: extracted struct
81+
[6708] LOADER: callfunction returned...
82+
[6708] LOADER: extracted pyimod01_os_path
83+
[6708] LOADER: callfunction returned...
84+
[6708] LOADER: extracted pyimod02_archive
85+
[6708] LOADER: callfunction returned...
86+
[6708] LOADER: extracted pyimod03_importers
87+
[6708] LOADER: callfunction returned...
88+
[6708] LOADER: Installing PYZ archive with Python modules.
89+
[6708] LOADER: PYZ archive: out00-PYZ.pyz
90+
[6708] LOADER: Running pyiboot01_bootstrap.py
91+
[6708] LOADER: Running wxpython.py
92+
Traceback (most recent call last):
93+
File "wxpython.py", line 11, in <module>
94+
File "c:\python27\lib\site-packages\PyInstaller-3.3-py2.7.egg\
95+
PyInstaller\loader\pyimod03_importers.py", line 396,
96+
in load_module exec(bytecode, module.__dict__)
97+
File "site-packages\cefpython3\__init__.py", line 50, in <module>
98+
File "c:\python27\lib\site-packages\PyInstaller-3.3-py2.7.egg\
99+
PyInstaller\loader\pyimod03_importers.py", line 687,
100+
in load_module module = imp.load_module(fullname, fp, filename,
101+
ext_tuple)
102+
File "cefpython_py27.pyx", line 283, in init cefpython_py27
103+
(cefpython_py27.cpp:110881)
104+
ImportError: No module named json
105+
[6708] Failed to execute script wxpython
106+
[6708] LOADER: OK.
107+
[6708] LOADER: Cleaning up Python interpreter.
108+
```
109+
110+
111+
## More details
112+
113+
The corresponding issue in the tracker is [Issue #135](https://github.com/cztomczak/cefpython/issues/135).
114+
115+
See also the [Build executable](https://github.com/cztomczak/cefpython/blob/master/docs/Tutorial.md#build-executable)
116+
section in Tutorial.

0 commit comments

Comments
 (0)