Skip to content

Commit

Permalink
Add 32/64 support for WebBrowserInterop (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman authored Apr 28, 2018
1 parent 2d3894f commit d823562
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 10 deletions.
12 changes: 6 additions & 6 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
environment:
matrix:

#- PYTHON: "C:\\Python27"
# PYTHON_VERSION: "2.7.x"
# PYTHON_ARCH: "32"
- PYTHON: "C:\\Python27"
PYTHON_VERSION: "2.7.x"
PYTHON_ARCH: "32"

- PYTHON: "C:\\Python27-x64"
PYTHON_VERSION: "2.7.x"
PYTHON_ARCH: "64"

#- PYTHON: "C:\\Python36"
# PYTHON_VERSION: "3.6.x"
# PYTHON_ARCH: "32"
- PYTHON: "C:\\Python36"
PYTHON_VERSION: "3.6.x"
PYTHON_ARCH: "32"

- PYTHON: "C:\\Python36-x64"
PYTHON_VERSION: "3.6.x"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
data_files = []

if platform.system() == "Windows":
data_files.append(('webview/lib', ['webview/lib/WebBrowserInterop.dll']))
data_files.append(('webview/lib', ['webview/lib/WebBrowserInterop.x64.dll', 'webview/lib/WebBrowserInterop.x86.dll']))
extras_require = {
'win32': ['pywin32', 'comtypes'],
'winforms': ['pythonnet'],
Expand Down
File renamed without changes.
Binary file added webview/lib/WebBrowserInterop.x64.dll
Binary file not shown.
File renamed without changes.
9 changes: 6 additions & 3 deletions webview/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import os
import re
import sys
import platform

from .js import api, npo

Expand Down Expand Up @@ -120,19 +121,21 @@ def inject_base_uri(content, base_uri):


def interop_dll_path():
dll_name = 'WebBrowserInterop.x64.dll' if platform.architecture()[0] == '64bit' else 'WebBrowserInterop.x86.dll'

# Unfrozen path
dll_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'lib', 'WebBrowserInterop.dll')
dll_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'lib', dll_name)
if os.path.exists(dll_path):
return dll_path

# Frozen path, dll in the same dir as the executable
dll_path = os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), 'WebBrowserInterop.dll')
dll_path = os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), dll_name)
if os.path.exists(dll_path):
return dll_path

try:
# Frozen path packed as onefile
dll_path = os.path.join(sys._MEIPASS, 'WebBrowserInterop.dll')
dll_path = os.path.join(sys._MEIPASS, dll_name)
if os.path.exists(dll_path):
return dll_path
except Exception:
Expand Down

0 comments on commit d823562

Please sign in to comment.