@@ -141,28 +141,40 @@ def get_library_paths():
141141
142142 elif IS_LINUX :
143143 # Use vendor dependencies if available, otherwise system paths
144- vendor_dir = Path ("vendor" )
144+ vendor_dir = Path ("vendor" ). resolve ()
145145
146146 # Check if vendor nghttp2 exists
147147 vendor_nghttp2 = vendor_dir / "nghttp2" / "install"
148- if vendor_nghttp2 .exists ():
148+ if vendor_nghttp2 .exists () and ( vendor_nghttp2 / "include" ). exists () :
149149 nghttp2_include = str (vendor_nghttp2 / "include" )
150150 nghttp2_lib = str (vendor_nghttp2 / "lib" )
151+ print (f"Using vendor nghttp2 from: { vendor_nghttp2 } " )
151152 else :
152153 # Try pkg-config for nghttp2
154+ nghttp2_include = None
155+ nghttp2_lib = None
153156 try :
154157 import subprocess
155- nghttp2_include = subprocess .check_output (
158+ include_output = subprocess .check_output (
156159 ["pkg-config" , "--cflags-only-I" , "libnghttp2" ],
157160 stderr = subprocess .DEVNULL
158- ).decode ().strip ().replace ("-I" , "" )
159- nghttp2_lib = subprocess .check_output (
161+ ).decode ().strip ()
162+ if include_output :
163+ nghttp2_include = include_output .replace ("-I" , "" ).strip ()
164+
165+ lib_output = subprocess .check_output (
160166 ["pkg-config" , "--libs-only-L" , "libnghttp2" ],
161167 stderr = subprocess .DEVNULL
162- ).decode ().strip ().replace ("-L" , "" )
168+ ).decode ().strip ()
169+ if lib_output :
170+ nghttp2_lib = lib_output .replace ("-L" , "" ).strip ()
163171 except (subprocess .CalledProcessError , FileNotFoundError ):
164- # Fall back to common system paths
172+ pass
173+
174+ # Fall back to common system paths if pkg-config didn't work
175+ if not nghttp2_include :
165176 nghttp2_include = "/usr/include"
177+ if not nghttp2_lib :
166178 nghttp2_lib = "/usr/lib/x86_64-linux-gnu"
167179 # Also check alternative paths
168180 if not Path (nghttp2_lib ).exists ():
@@ -172,26 +184,47 @@ def get_library_paths():
172184 break
173185
174186 # Try pkg-config for OpenSSL
187+ openssl_include = None
188+ openssl_lib = None
175189 try :
176190 import subprocess
177- openssl_include = subprocess .check_output (
191+ include_output = subprocess .check_output (
178192 ["pkg-config" , "--cflags-only-I" , "openssl" ],
179193 stderr = subprocess .DEVNULL
180- ).decode ().strip ().replace ("-I" , "" )
181- openssl_lib = subprocess .check_output (
194+ ).decode ().strip ()
195+ if include_output :
196+ openssl_include = include_output .replace ("-I" , "" ).strip ()
197+
198+ lib_output = subprocess .check_output (
182199 ["pkg-config" , "--libs-only-L" , "openssl" ],
183200 stderr = subprocess .DEVNULL
184- ).decode ().strip ().replace ("-L" , "" )
201+ ).decode ().strip ()
202+ if lib_output :
203+ openssl_lib = lib_output .replace ("-L" , "" ).strip ()
185204 except (subprocess .CalledProcessError , FileNotFoundError ):
186- # Use system OpenSSL on Linux
205+ pass
206+
207+ # Use system OpenSSL on Linux if pkg-config didn't work
208+ if not openssl_include :
187209 openssl_include = "/usr/include"
210+ if not openssl_lib :
188211 openssl_lib = "/usr/lib/x86_64-linux-gnu"
189212 if not Path (openssl_lib ).exists ():
190213 for alt_path in ["/usr/lib64" , "/usr/lib" ]:
191214 if Path (alt_path ).exists ():
192215 openssl_lib = alt_path
193216 break
194217
218+ # Validate paths before returning
219+ if not openssl_include or not openssl_include .strip ():
220+ openssl_include = "/usr/include"
221+ if not openssl_lib or not openssl_lib .strip ():
222+ openssl_lib = "/usr/lib/x86_64-linux-gnu"
223+ if not nghttp2_include or not nghttp2_include .strip ():
224+ nghttp2_include = "/usr/include"
225+ if not nghttp2_lib or not nghttp2_lib .strip ():
226+ nghttp2_lib = "/usr/lib/x86_64-linux-gnu"
227+
195228 return {
196229 "openssl_include" : openssl_include ,
197230 "openssl_lib" : openssl_lib ,
@@ -210,6 +243,14 @@ def get_library_paths():
210243
211244LIB_PATHS = get_library_paths ()
212245
246+ # Debug output
247+ print ("\n Library paths detected:" )
248+ print (f" OpenSSL include: { LIB_PATHS ['openssl_include' ]} " )
249+ print (f" OpenSSL lib: { LIB_PATHS ['openssl_lib' ]} " )
250+ print (f" nghttp2 include: { LIB_PATHS ['nghttp2_include' ]} " )
251+ print (f" nghttp2 lib: { LIB_PATHS ['nghttp2_lib' ]} " )
252+ print ()
253+
213254# Define C extension modules
214255extensions = [
215256 # Main httpmorph C extension
0 commit comments