Skip to content

Commit 15102ee

Browse files
nobodyguycztomczak
authored andcommitted
Linux support in PyInstaller example (cztomczak#522)
1 parent c66bc7b commit 15102ee

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

examples/pyinstaller/README-pyinstaller.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ Table of contents:
1212

1313
This is an example of using [PyInstaller](http://www.pyinstaller.org/)
1414
packager to build executable from one of CEF Python's examples
15-
(wxpython.py). Although this pyinstaller example supports only packaging
16-
on Windows, CEF can be packaged on all platforms without problems, but
17-
this specific packaging example just wasn't tested on other platforms.
18-
Pull requests are welcome.
15+
(wxpython.py). This pyinstaller example supports packaging
16+
on Windows, Linux and Darwin but was mainly tested on Windows platform.
1917

2018
To install required packages type:
2119
```

examples/pyinstaller/hook-cefpython3.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636

3737
# Functions
3838
def check_platforms():
39-
if not is_win and not is_darwin:
40-
raise SystemExit("Error: Currently only Windows and Darwin "
39+
if not is_win and not is_darwin and not is_linux:
40+
raise SystemExit("Error: Currently only Windows, Linux and Darwin "
4141
"platforms are supported, see Issue #135.")
4242

4343

@@ -121,7 +121,7 @@ def get_cefpython3_datas():
121121

122122
if is_win:
123123
cefdatadir = "."
124-
elif is_darwin:
124+
elif is_darwin or is_linux:
125125
cefdatadir = "."
126126
else:
127127
assert False, "Unsupported system {}".format(platform.system())
@@ -156,7 +156,7 @@ def get_cefpython3_datas():
156156
dest_path = os.path.relpath(path, CEFPYTHON3_DIR)
157157
ret.append((absolute_file_path, dest_path))
158158
logger.info("Include cefpython3 data: {}".format(dest_path))
159-
elif is_win:
159+
elif is_win or is_linux:
160160
# The .pak files in cefpython3/locales/ directory
161161
locales_dir = os.path.join(CEFPYTHON3_DIR, "locales")
162162
assert os.path.exists(locales_dir), \
@@ -166,6 +166,15 @@ def get_cefpython3_datas():
166166
os.path.basename(locales_dir), filename))
167167
ret.append((os.path.join(locales_dir, filename),
168168
os.path.join(cefdatadir, "locales")))
169+
170+
# Optional .so/.dll files in cefpython3/swiftshader/ directory
171+
swiftshader_dir = os.path.join(CEFPYTHON3_DIR, "swiftshader")
172+
if os.path.isdir(swiftshader_dir):
173+
for filename in os.listdir(swiftshader_dir):
174+
logger.info("Include cefpython3 data: {}/{}".format(
175+
os.path.basename(swiftshader_dir), filename))
176+
ret.append((os.path.join(swiftshader_dir, filename),
177+
os.path.join(cefdatadir, "swiftshader")))
169178
return ret
170179

171180

@@ -213,7 +222,7 @@ def get_cefpython3_datas():
213222
excludedimports = get_excluded_cefpython_modules()
214223

215224
# Include binaries requiring to collect its dependencies
216-
if is_darwin:
225+
if is_darwin or is_linux:
217226
binaries = [(os.path.join(CEFPYTHON3_DIR, "subprocess"), ".")]
218227
elif is_win:
219228
binaries = [(os.path.join(CEFPYTHON3_DIR, "subprocess.exe"), ".")]

examples/pyinstaller/pyinstaller.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@
2525
EXE_EXT = ".exe"
2626
elif platform.system() == "Darwin":
2727
EXE_EXT = ".app"
28+
elif platform.system() == "Linux":
29+
EXE_EXT = ""
2830

2931

3032
def main():
3133
# Platforms supported
32-
if platform.system() not in ["Windows", "Darwin"]:
33-
raise SystemExit("Error: Only Windows and Darwin platforms are "
34+
if platform.system() not in ["Windows", "Darwin", "Linux"]:
35+
raise SystemExit("Error: Only Windows, Linux and Darwin platforms are "
3436
"currently supported. See Issue #135 for details.")
3537

3638
# Make sure nothing is cached from previous build.

0 commit comments

Comments
 (0)