Skip to content

Commit 36eedc3

Browse files
committed
add log to easy debug
1 parent da95197 commit 36eedc3

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,7 @@ develop-eggs
9393
lib
9494
lib64
9595
*.c
96+
97+
webview.dll
98+
WebView2Loader.dll
99+

src/webview/_webview_ffi.py

+18-11
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from ctypes import c_int, c_char_p, c_void_p, CFUNCTYPE
88
import ctypes.util
99
import shutil
10-
10+
import logging
1111
def _encode_c_string(s: str) -> bytes:
1212
return s.encode("utf-8")
1313

@@ -70,33 +70,39 @@ def _get_download_urls():
7070
def _be_sure_libraries():
7171
"""Ensure libraries exist and return paths."""
7272
if getattr(sys, 'frozen', False):
73-
if hasattr(sys, '_MEIPASS'):
74-
base_dir = Path(sys._MEIPASS)
75-
else:
76-
base_dir = Path(sys.executable).parent / '_internal'
73+
# if hasattr(sys, '_MEIPASS'):
74+
# base_dir = Path(sys._MEIPASS)
75+
# else:
76+
# base_dir = Path(sys.executable).parent / '_internal'/'webview'
77+
base_dir = Path(sys.executable).parent / '_internal'/'webview'
7778
else:
7879
base_dir = Path(__file__).parent
7980

80-
lib_dir = base_dir / "lib"
81+
#lib_dir = base_dir / "lib"
82+
lib_dir = base_dir
83+
logging.info(f"webview lib_dir: {lib_dir}")
8184
lib_names = _get_lib_names()
85+
logging.info(f"webview lib_names: {lib_names}")
8286
lib_paths = [lib_dir / lib_name for lib_name in lib_names]
83-
87+
logging.info(f"webview lib_paths: {lib_paths}")
8488
# Check if any library is missing
8589
missing_libs = [path for path in lib_paths if not path.exists()]
8690
if not missing_libs:
8791
return lib_paths
88-
92+
else:
93+
logging.warning(f"Missing libraries: {missing_libs}")
8994
# Download or copy missing libraries
9095
download_urls = _get_download_urls()
91-
system = platform.system().lower()
9296

9397
lib_dir.mkdir(parents=True, exist_ok=True)
9498

9599
for url, lib_path in zip(download_urls, lib_paths):
96100
if lib_path.exists():
97101
continue
98102

99-
print(f"Getting library from {url}")
103+
print(f"Getting library from {url}, writing to {lib_path}")
104+
logging.warning(f"Getting library from {url}, writing to {lib_path}")
105+
100106
try:
101107
# Handle different URL types
102108
if url.startswith(("http://", "https://")):
@@ -130,7 +136,8 @@ def __init__(self):
130136
library_path = ctypes.util.find_library(lib_names[0])
131137
if not library_path:
132138
library_paths = _be_sure_libraries()
133-
self.lib = ctypes.cdll.LoadLibrary(str(library_paths[0]))
139+
library_path = library_paths[0]
140+
self.lib = ctypes.cdll.LoadLibrary(str(library_path))
134141
except Exception as e:
135142
print(f"Failed to load webview library: {e}")
136143
raise

0 commit comments

Comments
 (0)