|
60 | 60 | import re |
61 | 61 | import shutil |
62 | 62 | import subprocess |
63 | | -import tarfile |
| 63 | +# import tarfile # Currently using zip on all platforms |
64 | 64 | import zipfile |
65 | 65 |
|
66 | 66 | # Command line args |
@@ -117,13 +117,13 @@ def main(): |
117 | 117 | pack_prebuilt_cef("32bit") |
118 | 118 | if LINUX: |
119 | 119 | reduce_package_size_issue_262("32bit") |
120 | | - reduce_package_size_issue_321("32bit") |
121 | | - if pythons_64bit is not None: |
| 120 | + remove_unnecessary_package_files("32bit") |
| 121 | + if pythons_64bit: |
122 | 122 | run_automate_prebuilt_cef(pythons_64bit[0]) |
123 | 123 | pack_prebuilt_cef("64bit") |
124 | 124 | if LINUX: |
125 | 125 | reduce_package_size_issue_262("64bit") |
126 | | - reduce_package_size_issue_321("64bit") |
| 126 | + remove_unnecessary_package_files("64bit") |
127 | 127 | if not NO_REBUILD: |
128 | 128 | build_cefpython_modules(pythons_32bit + pythons_64bit) |
129 | 129 | if pythons_32bit: |
@@ -264,19 +264,29 @@ def search_for_pythons(search_arch): |
264 | 264 |
|
265 | 265 |
|
266 | 266 | def check_pythons(pythons_32bit, pythons_64bit): |
| 267 | + check_32bit = True |
| 268 | + check_64bit = True |
| 269 | + if MAC: |
| 270 | + check_32bit = False |
| 271 | + elif LINUX: |
| 272 | + if pythons_64bit: |
| 273 | + check_32bit = False |
| 274 | + elif pythons_32bit: |
| 275 | + check_64bit = False |
| 276 | + |
267 | 277 | pp = pprint.PrettyPrinter(indent=4) |
268 | 278 | if pythons_32bit: |
269 | 279 | print("[build_distrib.py] Pythons 32-bit found:") |
270 | 280 | pp.pprint(pythons_32bit) |
271 | | - if WINDOWS and len(pythons_32bit) != len(SUPPORTED_PYTHON_VERSIONS): |
| 281 | + if check_32bit and len(pythons_32bit) != len(SUPPORTED_PYTHON_VERSIONS): |
272 | 282 | print("[build_distrib.py] ERROR: Couldn't find all supported" |
273 | 283 | " python 32-bit installations. Found: {found}." |
274 | 284 | .format(found=len(pythons_32bit))) |
275 | 285 | sys.exit(1) |
276 | 286 | if pythons_64bit: |
277 | 287 | print("[build_distrib.py] Pythons 64-bit found:") |
278 | 288 | pp.pprint(pythons_64bit) |
279 | | - if len(pythons_64bit) != len(SUPPORTED_PYTHON_VERSIONS): |
| 289 | + if check_64bit and len(pythons_64bit) != len(SUPPORTED_PYTHON_VERSIONS): |
280 | 290 | print("[build_distrib.py] ERROR: Couldn't find all supported" |
281 | 291 | " python 64-bit installations. Found: {found}." |
282 | 292 | .format(found=len(pythons_64bit))) |
@@ -367,15 +377,17 @@ def pack_prebuilt_cef(arch): |
367 | 377 | def pack_directory(path, base_path): |
368 | 378 | if path.endswith(os.path.sep): |
369 | 379 | path = path[:-1] |
370 | | - ext = ".zip" if WINDOWS or MAC else ".tar.gz" |
| 380 | + # ext = ".zip" if WINDOWS or MAC else ".tar.gz" |
| 381 | + ext = ".zip" |
371 | 382 | archive = path + ext |
372 | 383 | if os.path.exists(archive): |
373 | 384 | os.remove(archive) |
374 | 385 | if WINDOWS or MAC: |
375 | 386 | zip_directory(path, base_path=base_path, archive=archive) |
376 | 387 | else: |
377 | | - with tarfile.open(archive, "w:gz") as tar: |
378 | | - tar.add(path, arcname=os.path.basename(path)) |
| 388 | + zip_directory(path, base_path=base_path, archive=archive) |
| 389 | + # with tarfile.open(archive, "w:gz") as tar: |
| 390 | + # tar.add(path, arcname=os.path.basename(path)) |
379 | 391 | assert os.path.isfile(archive), archive |
380 | 392 | return archive |
381 | 393 |
|
@@ -408,43 +420,19 @@ def reduce_package_size_issue_262(arch): |
408 | 420 | .format(libcef_so=os.path.basename(libcef_so))) |
409 | 421 | command = "strip {libcef_so}".format(libcef_so=libcef_so) |
410 | 422 | pcode = subprocess.call(command, shell=True) |
411 | | - assert pcode, "strip command failed" |
| 423 | + assert pcode == 0, "strip command failed" |
412 | 424 |
|
413 | 425 |
|
414 | | -def reduce_package_size_issue_321(arch): |
415 | | - """PyPI has file size limit and must reduce package size. Issue #321.""" |
| 426 | +def remove_unnecessary_package_files(arch): |
| 427 | + """Do not ship sample applications (cefclient etc) with the package. |
| 428 | + They increase size and also are an additional unnecessary factor |
| 429 | + when dealing with false-positives in Anti-Virus software.""" |
416 | 430 | print("[build_distrib.py] Reduce package size for {arch} (Issue #321)" |
417 | 431 | .format(arch=arch)) |
418 | 432 | prebuilt_basename = get_cef_binaries_libraries_basename( |
419 | 433 | get_os_postfix2_for_arch(arch)) |
420 | 434 | bin_dir = os.path.join(prebuilt_basename, "bin") |
421 | | - |
422 | | - # Delete sample applications to reduce package size |
423 | | - sample_apps = ["cefclient", "cefsimple", "ceftests"] |
424 | | - for sample_app_name in sample_apps: |
425 | | - sample_app = os.path.join(bin_dir, sample_app_name + APP_EXT) |
426 | | - # Not on all platforms sample apps may be available |
427 | | - if os.path.exists(sample_app): |
428 | | - print("[build_distrib.py] Delete {sample_app}" |
429 | | - .format(sample_app=os.path.basename(sample_app))) |
430 | | - if os.path.isdir(sample_app): |
431 | | - shutil.rmtree(sample_app) |
432 | | - else: |
433 | | - os.remove(sample_app) |
434 | | - # Also delete subdirs eg. cefclient_files/, ceftests_files/ |
435 | | - files_subdir = os.path.join(bin_dir, sample_app_name + "_files") |
436 | | - if os.path.isdir(files_subdir): |
437 | | - print("[build_distrib.py] Delete directory: {dir}/" |
438 | | - .format(dir=os.path.basename(files_subdir))) |
439 | | - shutil.rmtree(files_subdir) |
440 | | - |
441 | | - # Strip symbols from cefpython .so modules to reduce size |
442 | | - modules = glob.glob(os.path.join(CEFPYTHON_BINARY, "*.so")) |
443 | | - for module in modules: |
444 | | - print("[build_distrib.py] strip {module}" |
445 | | - .format(module=os.path.basename(module))) |
446 | | - command = "strip {module}".format(module=module) |
447 | | - assert os.system(command) == 0, "strip command failed" |
| 435 | + delete_cef_sample_apps(caller_script=__file__, bin_dir=bin_dir) |
448 | 436 |
|
449 | 437 |
|
450 | 438 | def build_cefpython_modules(pythons): |
|
0 commit comments