Skip to content

Commit

Permalink
Use VS2008 to build subprocess.exe to avoid false positives by AVs (#342
Browse files Browse the repository at this point in the history
)
  • Loading branch information
cztomczak committed Apr 14, 2017
1 parent f7398c2 commit 5caa061
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 15 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ See the [Examples-README.md](examples/Examples-README.md) file.
- Supported examples are listed in the [Examples-README.md](examples/Examples-README.md) file
- Documentation is in the [docs/](docs) directory:
- [Build instructions](docs/Build-instructions.md)
- [Knowledge base](docs/Knowledge-Base.md)
- [Knowledge Base](docs/Knowledge-Base.md)
- [Migration guide](docs/Migration-guide.md)
- [Tutorial](docs/Tutorial.md)
- API reference is in the [api/](api) directory:
Expand Down Expand Up @@ -155,8 +155,8 @@ directly.
- [Tutorial](docs/Tutorial.md)


### API categories

### API categories

#### Modules

* [cefpython](api/cefpython.md#cefpython) module
Expand Down Expand Up @@ -211,9 +211,9 @@ directly.
* [StringVisitor](api/StringVisitor.md#stringvisitor-interface) interface
* [WebRequestClient](api/WebRequestClient.md#webrequestclient-interface) interface


### API index


### API index

* [Application settings](api/ApplicationSettings.md#application-settings)
* [accept_language_list](api/ApplicationSettings.md#accept_language_list)
* [auto_zooming](api/ApplicationSettings.md#auto_zooming)
Expand Down
4 changes: 2 additions & 2 deletions src/compile_time_constants.pxi
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This file was generated by setup.py
DEF UNAME_SYSNAME = "Linux"
DEF PY_MAJOR_VERSION = 2
DEF UNAME_SYSNAME = "Windows"
DEF PY_MAJOR_VERSION = 3
7 changes: 6 additions & 1 deletion tools/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,12 @@ def delete_directory_reliably(adir):
print("[build.py] Delete directory: {dir}"
.format(dir=adir.replace(ROOT_DIR, "")))
if WINDOWS:
shutil.rmtree(adir)
# rmtree is vulnerable to race conditions. Sometimes
# deleting directory fails with error:
# >> OSError: [WinError 145] The directory is not empty:
# >> 'C:\\github\\cefpython\\build\\cefpython3_56.2_win64\\build\\
# >> lib\\cefpython3'
shutil.rmtree(adir, ignore_errors=True)
else:
# On Linux sudo might be required to delete directory, as this
# might be a setup installer directory with package installed
Expand Down
62 changes: 56 additions & 6 deletions tools/build_distrib.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
7. Reduce packages size (Issue #321). After packing prebuilt binaries,
reduce its size so that packages will use the reduced prebuilt binaries.
8. Build cefpython modules for all supported Python versions on both
32-bit and 64-bit
32-bit and 64-bit. Backup and restore subprocess executable on Windows
built with Python 2.7 (Issue #342).
9. Make setup installers and pack them to zip (Win/Mac) or .tar.gz (Linux)
10. Make wheel packages
11. Move setup and wheel packages to the build/distrib/ directory
Expand Down Expand Up @@ -129,7 +130,8 @@ def main():
reduce_package_size_issue_262("64bit")
remove_unnecessary_package_files("64bit")
if not NO_REBUILD:
build_cefpython_modules(pythons_32bit + pythons_64bit)
build_cefpython_modules(pythons_32bit, "32bit")
build_cefpython_modules(pythons_64bit, "64bit")
if pythons_32bit:
make_packages(pythons_32bit[0], "32bit")
if pythons_64bit:
Expand Down Expand Up @@ -439,7 +441,7 @@ def remove_unnecessary_package_files(arch):
delete_cef_sample_apps(caller_script=__file__, bin_dir=bin_dir)


def build_cefpython_modules(pythons):
def build_cefpython_modules(pythons, arch):
for python in pythons:
print("[build_distrib.py] Build cefpython module for {python_name}"
.format(python_name=python["name"]))
Expand All @@ -461,14 +463,62 @@ def build_cefpython_modules(pythons):
sys.exit(1)
print("[build_distrib.py] Built successfully cefpython module for"
" {python_name}".format(python_name=python["name"]))
print("[build_distrib.py] Successfully built cefpython modules for"
" all Python versions")
# Issue #342
backup_subprocess_executable_issue342(python)

# Issue #342
restore_subprocess_executable_issue342(arch)

print("[build_distrib.py] Successfully built cefpython modules for {arch}"
.format(arch=arch))


def backup_subprocess_executable_issue342(python):
"""Use subprocess executable build by Python 2.7 to avoid
false-positives by AVs when building subprocess with Python 3.
Windows-only issue."""
if not WINDOWS:
return
if python["version2"] == (2, 7):
print("[build_distrib.py] Backup subprocess executable built"
" with Python 2.7 (Issue #342)")
cefpython_binary_basename = get_cefpython_binary_basename(
get_os_postfix2_for_arch(python["arch"]))
cefpython_binary = os.path.join(BUILD_DIR, cefpython_binary_basename)
assert os.path.isdir(cefpython_binary)
src = os.path.join(cefpython_binary, "subprocess.exe")
dst = os.path.join(BUILD_CEFPYTHON,
"subprocess_py27_{arch}_issue342.exe"
.format(arch=python["arch"]))
shutil.copy(src, dst)


def restore_subprocess_executable_issue342(arch):
"""Use subprocess executable build by Python 2.7 to avoid
false-positives by AVs when building subprocess with Python 3.
Windows-only issue."""
if not WINDOWS:
return
print("[build_distrib.py] Restore subprocess executable built"
" with Python 2.7 (Issue #342)")
cefpython_binary_basename = get_cefpython_binary_basename(
get_os_postfix2_for_arch(arch))
cefpython_binary = os.path.join(BUILD_DIR, cefpython_binary_basename)
assert os.path.isdir(cefpython_binary)
src = os.path.join(BUILD_CEFPYTHON,
"subprocess_py27_{arch}_issue342.exe"
.format(arch=arch))
assert os.path.isfile(src)
dst = os.path.join(cefpython_binary, "subprocess.exe")
shutil.copy(src, dst)


def make_packages(python, arch):
# Make setup package
"""Make setup and wheel packages."""
print("[build_distrib.py] Make setup package for {arch}..."
.format(arch=arch))

# Call make_installer.py
make_installer_py = os.path.join(TOOLS_DIR, "make_installer.py")
installer_command = ("\"{python}\" {make_installer_py} {version}"
.format(python=python["executable"],
Expand Down
1 change: 1 addition & 0 deletions tools/run_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def main():
packages = check_installed_packages()
examples = list()
examples.append("hello_world.py")
examples.append("tutorial.py")
succeeded = list()
failed = list()
passed = list()
Expand Down

0 comments on commit 5caa061

Please sign in to comment.