X Tutup
Skip to content

Commit 25503bb

Browse files
committed
Update PyInstaller example (cztomczak#135)
1 parent d4db8da commit 25503bb

File tree

2 files changed

+40
-10
lines changed

2 files changed

+40
-10
lines changed

examples/pyinstaller/README-pyinstaller.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ To install required packages type:
1919
pip install --upgrade pyinstaller pycrypto
2020
```
2121

22+
Note that pyinstaller version on PyPI is almost one year old (as of Sep 2017)
23+
and has several bugs, so if you encounter any issues try installing dev
24+
version using this command:
25+
```
26+
pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip
27+
```
28+
2229
To package the example go to the [examples/pyinstaller/](./) directory
2330
and type:
2431
```

examples/pyinstaller/hook-cefpython3.py

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
import glob
1111
import os
1212
import platform
13+
import re
1314
import sys
15+
import PyInstaller
1416
from PyInstaller.utils.hooks import is_module_satisfies
1517
from PyInstaller import log as logging
1618

@@ -19,6 +21,9 @@
1921
PYINSTALLER_MIN_VERSION = "3.2.1"
2022

2123
# Makes assumption that using "python.exe" and not "pyinstaller.exe"
24+
# TODO: use this code to work cross-platform:
25+
# > from PyInstaller.utils.hooks import get_package_paths
26+
# > get_package_paths("cefpython3")
2227
CEFPYTHON3_DIR = os.path.join(
2328
os.path.dirname(sys.executable),
2429
'Lib', 'site-packages', 'cefpython3')
@@ -31,18 +36,31 @@
3136
# Globals
3237
logger = logging.getLogger(__name__)
3338

34-
# Checks: platforms and versions
35-
if platform.system() != "Windows":
36-
raise SystemExit("Error: Currently only Windows platform is "
37-
" supported, see Issue #135.")
3839

39-
if not is_module_satisfies("cefpython3 >= %s" % CEFPYTHON_MIN_VERSION):
40-
raise SystemExit("Error: cefpython3 %s or higher is required"
41-
% CEFPYTHON_MIN_VERSION)
40+
# Functions
41+
def check_platforms():
42+
if platform.system() != "Windows":
43+
raise SystemExit("Error: Currently only Windows platform is "
44+
" supported, see Issue #135.")
4245

43-
if not is_module_satisfies("pyinstaller >= %s" % PYINSTALLER_MIN_VERSION):
44-
raise SystemExit("Error: pyinstaller %s or higher is required"
45-
% PYINSTALLER_MIN_VERSION)
46+
47+
def check_pyinstaller_version():
48+
"""Using is_module_satisfies() for pyinstaller fails when
49+
installed using 'pip install develop.zip' command
50+
(PyInstaller Issue #2802)."""
51+
# Example version string for dev version of pyinstaller:
52+
# > 3.3.dev0+g5dc9557c
53+
version = PyInstaller.__version__
54+
match = re.search(r"^\d+\.\d+", version)
55+
if not (match.group(0) >= PYINSTALLER_MIN_VERSION):
56+
raise SystemExit("Error: pyinstaller %s or higher is required"
57+
% PYINSTALLER_MIN_VERSION)
58+
59+
60+
def check_cefpython3_version():
61+
if not is_module_satisfies("cefpython3 >= %s" % CEFPYTHON_MIN_VERSION):
62+
raise SystemExit("Error: cefpython3 %s or higher is required"
63+
% CEFPYTHON_MIN_VERSION)
4664

4765

4866
def get_cefpython_modules():
@@ -129,6 +147,11 @@ def get_cefpython3_datas():
129147
# Main
130148
# ----------------------------------------------------------------------------
131149

150+
# Checks
151+
check_platforms()
152+
check_pyinstaller_version()
153+
check_cefpython3_version()
154+
132155
# Info
133156
logger.info("CEF Python package directory: %s" % CEFPYTHON3_DIR)
134157

0 commit comments

Comments
 (0)
X Tutup