Skip to content

Commit 462827e

Browse files
author
arman-bd
committed
fix: add DLL directories using os.add_dll_directory on Windows
1 parent 263df26 commit 462827e

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/httpmorph/_client_c.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,36 @@
55
import base64
66
import io
77
import json as _json
8+
import os
9+
import sys
810
import uuid
911
from datetime import timedelta
1012
from http.client import responses as http_responses
13+
from pathlib import Path
1114
from urllib.parse import parse_qs, urlencode, urlparse, urlunparse
1215

16+
# On Windows, add DLL search paths for dependencies
17+
if sys.platform == "win32" and hasattr(os, "add_dll_directory"):
18+
# Add vcpkg DLL directory
19+
vcpkg_bin = Path("C:/vcpkg/installed/x64-windows/bin")
20+
if vcpkg_bin.exists():
21+
os.add_dll_directory(str(vcpkg_bin))
22+
23+
# Add vendor DLL directories if they exist
24+
try:
25+
# Get the project root (3 levels up from this file)
26+
project_root = Path(__file__).parent.parent.parent
27+
boringssl_dll = project_root / "vendor" / "boringssl" / "build" / "Release"
28+
if boringssl_dll.exists():
29+
os.add_dll_directory(str(boringssl_dll))
30+
except Exception:
31+
pass # Silently ignore if we can't determine paths
32+
1333
try:
1434
from httpmorph import _httpmorph
1535

1636
HAS_C_EXTENSION = True
1737
except ImportError as e:
18-
import sys
1938
print(f"WARNING: Failed to import _httpmorph: {e}", file=sys.stderr)
2039
import traceback
2140
traceback.print_exc()

0 commit comments

Comments
 (0)