From 1af02b06dc5d0c047573adfc3dd195c450d19fd8 Mon Sep 17 00:00:00 2001 From: nobodyguy <4577368+nobodyguy@users.noreply.github.com> Date: Mon, 15 Apr 2019 09:14:11 +0200 Subject: [PATCH 1/2] Linux support in PyInstaller example --- examples/pyinstaller/README-pyinstaller.md | 6 ++---- examples/pyinstaller/hook-cefpython3.py | 19 ++++++++++++++----- examples/pyinstaller/pyinstaller.py | 6 ++++-- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/examples/pyinstaller/README-pyinstaller.md b/examples/pyinstaller/README-pyinstaller.md index caf3ff81e..f148bbceb 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 a0da71569..7522b7be1 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 d9433aa1a..068537b90 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. From e450ca888df6a5a93070bc734be7199ec61667c8 Mon Sep 17 00:00:00 2001 From: Czarek Tomczak Date: Mon, 15 Apr 2019 13:23:11 +0200 Subject: [PATCH 2/2] Fix styling issue in pyinstaller.py --- examples/pyinstaller/pyinstaller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/pyinstaller/pyinstaller.py b/examples/pyinstaller/pyinstaller.py index 068537b90..67bb8934a 100644 --- a/examples/pyinstaller/pyinstaller.py +++ b/examples/pyinstaller/pyinstaller.py @@ -26,7 +26,7 @@ elif platform.system() == "Darwin": EXE_EXT = ".app" elif platform.system() == "Linux": - EXE_EXT = "" + EXE_EXT = "" def main():