Skip to content

Commit

Permalink
Update PyInstaller example (#135)
Browse files Browse the repository at this point in the history
  • Loading branch information
cztomczak committed Sep 6, 2017
1 parent d4db8da commit 25503bb
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 10 deletions.
7 changes: 7 additions & 0 deletions examples/pyinstaller/README-pyinstaller.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ To install required packages type:
pip install --upgrade pyinstaller pycrypto
```

Note that pyinstaller version on PyPI is almost one year old (as of Sep 2017)
and has several bugs, so if you encounter any issues try installing dev
version using this command:
```
pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip
```

To package the example go to the [examples/pyinstaller/](./) directory
and type:
```
Expand Down
43 changes: 33 additions & 10 deletions examples/pyinstaller/hook-cefpython3.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
import glob
import os
import platform
import re
import sys
import PyInstaller
from PyInstaller.utils.hooks import is_module_satisfies
from PyInstaller import log as logging

Expand All @@ -19,6 +21,9 @@
PYINSTALLER_MIN_VERSION = "3.2.1"

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

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

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

if not is_module_satisfies("pyinstaller >= %s" % PYINSTALLER_MIN_VERSION):
raise SystemExit("Error: pyinstaller %s or higher is required"
% PYINSTALLER_MIN_VERSION)

def check_pyinstaller_version():
"""Using is_module_satisfies() for pyinstaller fails when
installed using 'pip install develop.zip' command
(PyInstaller Issue #2802)."""
# Example version string for dev version of pyinstaller:
# > 3.3.dev0+g5dc9557c
version = PyInstaller.__version__
match = re.search(r"^\d+\.\d+", version)
if not (match.group(0) >= PYINSTALLER_MIN_VERSION):
raise SystemExit("Error: pyinstaller %s or higher is required"
% PYINSTALLER_MIN_VERSION)


def check_cefpython3_version():
if not is_module_satisfies("cefpython3 >= %s" % CEFPYTHON_MIN_VERSION):
raise SystemExit("Error: cefpython3 %s or higher is required"
% CEFPYTHON_MIN_VERSION)


def get_cefpython_modules():
Expand Down Expand Up @@ -129,6 +147,11 @@ def get_cefpython3_datas():
# Main
# ----------------------------------------------------------------------------

# Checks
check_platforms()
check_pyinstaller_version()
check_cefpython3_version()

# Info
logger.info("CEF Python package directory: %s" % CEFPYTHON3_DIR)

Expand Down

0 comments on commit 25503bb

Please sign in to comment.