Skip to content

Commit 5caa061

Browse files
committed
Use VS2008 to build subprocess.exe to avoid false positives by AVs (cztomczak#342)
1 parent f7398c2 commit 5caa061

File tree

5 files changed

+71
-15
lines changed

5 files changed

+71
-15
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ See the [Examples-README.md](examples/Examples-README.md) file.
6262
- Supported examples are listed in the [Examples-README.md](examples/Examples-README.md) file
6363
- Documentation is in the [docs/](docs) directory:
6464
- [Build instructions](docs/Build-instructions.md)
65-
- [Knowledge base](docs/Knowledge-Base.md)
65+
- [Knowledge Base](docs/Knowledge-Base.md)
6666
- [Migration guide](docs/Migration-guide.md)
6767
- [Tutorial](docs/Tutorial.md)
6868
- API reference is in the [api/](api) directory:
@@ -155,8 +155,8 @@ directly.
155155
- [Tutorial](docs/Tutorial.md)
156156

157157

158-
### API categories
159-
158+
### API categories
159+
160160
#### Modules
161161

162162
* [cefpython](api/cefpython.md#cefpython) module
@@ -211,9 +211,9 @@ directly.
211211
* [StringVisitor](api/StringVisitor.md#stringvisitor-interface) interface
212212
* [WebRequestClient](api/WebRequestClient.md#webrequestclient-interface) interface
213213

214-
215-
### API index
216-
214+
215+
### API index
216+
217217
* [Application settings](api/ApplicationSettings.md#application-settings)
218218
* [accept_language_list](api/ApplicationSettings.md#accept_language_list)
219219
* [auto_zooming](api/ApplicationSettings.md#auto_zooming)

src/compile_time_constants.pxi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# This file was generated by setup.py
2-
DEF UNAME_SYSNAME = "Linux"
3-
DEF PY_MAJOR_VERSION = 2
2+
DEF UNAME_SYSNAME = "Windows"
3+
DEF PY_MAJOR_VERSION = 3

tools/build.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,12 @@ def delete_directory_reliably(adir):
879879
print("[build.py] Delete directory: {dir}"
880880
.format(dir=adir.replace(ROOT_DIR, "")))
881881
if WINDOWS:
882-
shutil.rmtree(adir)
882+
# rmtree is vulnerable to race conditions. Sometimes
883+
# deleting directory fails with error:
884+
# >> OSError: [WinError 145] The directory is not empty:
885+
# >> 'C:\\github\\cefpython\\build\\cefpython3_56.2_win64\\build\\
886+
# >> lib\\cefpython3'
887+
shutil.rmtree(adir, ignore_errors=True)
883888
else:
884889
# On Linux sudo might be required to delete directory, as this
885890
# might be a setup installer directory with package installed

tools/build_distrib.py

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
7. Reduce packages size (Issue #321). After packing prebuilt binaries,
4545
reduce its size so that packages will use the reduced prebuilt binaries.
4646
8. Build cefpython modules for all supported Python versions on both
47-
32-bit and 64-bit
47+
32-bit and 64-bit. Backup and restore subprocess executable on Windows
48+
built with Python 2.7 (Issue #342).
4849
9. Make setup installers and pack them to zip (Win/Mac) or .tar.gz (Linux)
4950
10. Make wheel packages
5051
11. Move setup and wheel packages to the build/distrib/ directory
@@ -129,7 +130,8 @@ def main():
129130
reduce_package_size_issue_262("64bit")
130131
remove_unnecessary_package_files("64bit")
131132
if not NO_REBUILD:
132-
build_cefpython_modules(pythons_32bit + pythons_64bit)
133+
build_cefpython_modules(pythons_32bit, "32bit")
134+
build_cefpython_modules(pythons_64bit, "64bit")
133135
if pythons_32bit:
134136
make_packages(pythons_32bit[0], "32bit")
135137
if pythons_64bit:
@@ -439,7 +441,7 @@ def remove_unnecessary_package_files(arch):
439441
delete_cef_sample_apps(caller_script=__file__, bin_dir=bin_dir)
440442

441443

442-
def build_cefpython_modules(pythons):
444+
def build_cefpython_modules(pythons, arch):
443445
for python in pythons:
444446
print("[build_distrib.py] Build cefpython module for {python_name}"
445447
.format(python_name=python["name"]))
@@ -461,14 +463,62 @@ def build_cefpython_modules(pythons):
461463
sys.exit(1)
462464
print("[build_distrib.py] Built successfully cefpython module for"
463465
" {python_name}".format(python_name=python["name"]))
464-
print("[build_distrib.py] Successfully built cefpython modules for"
465-
" all Python versions")
466+
# Issue #342
467+
backup_subprocess_executable_issue342(python)
468+
469+
# Issue #342
470+
restore_subprocess_executable_issue342(arch)
471+
472+
print("[build_distrib.py] Successfully built cefpython modules for {arch}"
473+
.format(arch=arch))
474+
475+
476+
def backup_subprocess_executable_issue342(python):
477+
"""Use subprocess executable build by Python 2.7 to avoid
478+
false-positives by AVs when building subprocess with Python 3.
479+
Windows-only issue."""
480+
if not WINDOWS:
481+
return
482+
if python["version2"] == (2, 7):
483+
print("[build_distrib.py] Backup subprocess executable built"
484+
" with Python 2.7 (Issue #342)")
485+
cefpython_binary_basename = get_cefpython_binary_basename(
486+
get_os_postfix2_for_arch(python["arch"]))
487+
cefpython_binary = os.path.join(BUILD_DIR, cefpython_binary_basename)
488+
assert os.path.isdir(cefpython_binary)
489+
src = os.path.join(cefpython_binary, "subprocess.exe")
490+
dst = os.path.join(BUILD_CEFPYTHON,
491+
"subprocess_py27_{arch}_issue342.exe"
492+
.format(arch=python["arch"]))
493+
shutil.copy(src, dst)
494+
495+
496+
def restore_subprocess_executable_issue342(arch):
497+
"""Use subprocess executable build by Python 2.7 to avoid
498+
false-positives by AVs when building subprocess with Python 3.
499+
Windows-only issue."""
500+
if not WINDOWS:
501+
return
502+
print("[build_distrib.py] Restore subprocess executable built"
503+
" with Python 2.7 (Issue #342)")
504+
cefpython_binary_basename = get_cefpython_binary_basename(
505+
get_os_postfix2_for_arch(arch))
506+
cefpython_binary = os.path.join(BUILD_DIR, cefpython_binary_basename)
507+
assert os.path.isdir(cefpython_binary)
508+
src = os.path.join(BUILD_CEFPYTHON,
509+
"subprocess_py27_{arch}_issue342.exe"
510+
.format(arch=arch))
511+
assert os.path.isfile(src)
512+
dst = os.path.join(cefpython_binary, "subprocess.exe")
513+
shutil.copy(src, dst)
466514

467515

468516
def make_packages(python, arch):
469-
# Make setup package
517+
"""Make setup and wheel packages."""
470518
print("[build_distrib.py] Make setup package for {arch}..."
471519
.format(arch=arch))
520+
521+
# Call make_installer.py
472522
make_installer_py = os.path.join(TOOLS_DIR, "make_installer.py")
473523
installer_command = ("\"{python}\" {make_installer_py} {version}"
474524
.format(python=python["executable"],

tools/run_examples.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def main():
3636
packages = check_installed_packages()
3737
examples = list()
3838
examples.append("hello_world.py")
39+
examples.append("tutorial.py")
3940
succeeded = list()
4041
failed = list()
4142
passed = list()

0 commit comments

Comments
 (0)