diff --git a/examples/pyinstaller/README-pyinstaller.md b/examples/pyinstaller/README-pyinstaller.md index caf3ff81..f148bbce 100644 --- a/examples/pyinstaller/README-pyinstaller.md +++ b/examples/pyinstaller/README-pyinstaller.md @@ -12,10 +12,8 @@ Table of contents: This is an example of using [PyInstaller](http://www.pyinstaller.org/) packager to build executable from one of CEF Python's examples -(wxpython.py). Although this pyinstaller example supports only packaging -on Windows, CEF can be packaged on all platforms without problems, but -this specific packaging example just wasn't tested on other platforms. -Pull requests are welcome. +(wxpython.py). This pyinstaller example supports packaging +on Windows, Linux and Darwin but was mainly tested on Windows platform. To install required packages type: ``` diff --git a/examples/pyinstaller/hook-cefpython3.py b/examples/pyinstaller/hook-cefpython3.py index a0da7156..7522b7be 100644 --- a/examples/pyinstaller/hook-cefpython3.py +++ b/examples/pyinstaller/hook-cefpython3.py @@ -36,8 +36,8 @@ # Functions def check_platforms(): - if not is_win and not is_darwin: - raise SystemExit("Error: Currently only Windows and Darwin " + if not is_win and not is_darwin and not is_linux: + raise SystemExit("Error: Currently only Windows, Linux and Darwin " "platforms are supported, see Issue #135.") @@ -121,7 +121,7 @@ def get_cefpython3_datas(): if is_win: cefdatadir = "." - elif is_darwin: + elif is_darwin or is_linux: cefdatadir = "." else: assert False, "Unsupported system {}".format(platform.system()) @@ -156,7 +156,7 @@ def get_cefpython3_datas(): dest_path = os.path.relpath(path, CEFPYTHON3_DIR) ret.append((absolute_file_path, dest_path)) logger.info("Include cefpython3 data: {}".format(dest_path)) - elif is_win: + elif is_win or is_linux: # The .pak files in cefpython3/locales/ directory locales_dir = os.path.join(CEFPYTHON3_DIR, "locales") assert os.path.exists(locales_dir), \ @@ -166,6 +166,15 @@ def get_cefpython3_datas(): os.path.basename(locales_dir), filename)) ret.append((os.path.join(locales_dir, filename), os.path.join(cefdatadir, "locales"))) + + # Optional .so/.dll files in cefpython3/swiftshader/ directory + swiftshader_dir = os.path.join(CEFPYTHON3_DIR, "swiftshader") + if os.path.isdir(swiftshader_dir): + for filename in os.listdir(swiftshader_dir): + logger.info("Include cefpython3 data: {}/{}".format( + os.path.basename(swiftshader_dir), filename)) + ret.append((os.path.join(swiftshader_dir, filename), + os.path.join(cefdatadir, "swiftshader"))) return ret @@ -213,7 +222,7 @@ def get_cefpython3_datas(): excludedimports = get_excluded_cefpython_modules() # Include binaries requiring to collect its dependencies -if is_darwin: +if is_darwin or is_linux: binaries = [(os.path.join(CEFPYTHON3_DIR, "subprocess"), ".")] elif is_win: binaries = [(os.path.join(CEFPYTHON3_DIR, "subprocess.exe"), ".")] diff --git a/examples/pyinstaller/pyinstaller.py b/examples/pyinstaller/pyinstaller.py index d9433aa1..67bb8934 100644 --- a/examples/pyinstaller/pyinstaller.py +++ b/examples/pyinstaller/pyinstaller.py @@ -25,12 +25,14 @@ EXE_EXT = ".exe" elif platform.system() == "Darwin": EXE_EXT = ".app" +elif platform.system() == "Linux": + EXE_EXT = "" def main(): # Platforms supported - if platform.system() not in ["Windows", "Darwin"]: - raise SystemExit("Error: Only Windows and Darwin platforms are " + if platform.system() not in ["Windows", "Darwin", "Linux"]: + raise SystemExit("Error: Only Windows, Linux and Darwin platforms are " "currently supported. See Issue #135 for details.") # Make sure nothing is cached from previous build.