|
10 | 10 | import glob |
11 | 11 | import os |
12 | 12 | import platform |
| 13 | +import re |
13 | 14 | import sys |
| 15 | +import PyInstaller |
14 | 16 | from PyInstaller.utils.hooks import is_module_satisfies |
15 | 17 | from PyInstaller import log as logging |
16 | 18 |
|
|
19 | 21 | PYINSTALLER_MIN_VERSION = "3.2.1" |
20 | 22 |
|
21 | 23 | # 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") |
22 | 27 | CEFPYTHON3_DIR = os.path.join( |
23 | 28 | os.path.dirname(sys.executable), |
24 | 29 | 'Lib', 'site-packages', 'cefpython3') |
|
31 | 36 | # Globals |
32 | 37 | logger = logging.getLogger(__name__) |
33 | 38 |
|
34 | | -# Checks: platforms and versions |
35 | | -if platform.system() != "Windows": |
36 | | - raise SystemExit("Error: Currently only Windows platform is " |
37 | | - " supported, see Issue #135.") |
38 | 39 |
|
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.") |
42 | 45 |
|
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) |
46 | 64 |
|
47 | 65 |
|
48 | 66 | def get_cefpython_modules(): |
@@ -129,6 +147,11 @@ def get_cefpython3_datas(): |
129 | 147 | # Main |
130 | 148 | # ---------------------------------------------------------------------------- |
131 | 149 |
|
| 150 | +# Checks |
| 151 | +check_platforms() |
| 152 | +check_pyinstaller_version() |
| 153 | +check_cefpython3_version() |
| 154 | + |
132 | 155 | # Info |
133 | 156 | logger.info("CEF Python package directory: %s" % CEFPYTHON3_DIR) |
134 | 157 |
|
|
0 commit comments