@@ -348,9 +348,6 @@ def _find_library_directory() -> str:
348348 current_dir = os .path .dirname (os .path .abspath (__file__ ))
349349 pyhelios_root = os .path .dirname (os .path .dirname (current_dir )) # Go up to PyHelios root
350350
351- # Expected library location after build
352- expected_location = os .path .join (pyhelios_root , 'pyhelios_build' , 'build' , 'lib' )
353-
354351 platform_name = platform .system ()
355352 if platform_name == 'Darwin' : # macOS
356353 library_names = ['libhelios.dylib' , 'libCHelios.dylib' , 'CHelios.dylib' ]
@@ -364,17 +361,26 @@ def _find_library_directory() -> str:
364361 f"Supported platforms: Windows, macOS, Linux"
365362 )
366363
367- # Check the expected build location
368- if os .path .exists (expected_location ):
369- for lib_name in library_names :
370- lib_path = os .path .join (expected_location , lib_name )
371- if os .path .exists (lib_path ):
372- logger .debug (f"Found library at: { lib_path } " )
373- return expected_location
364+ # Try multiple locations in order of priority
365+ search_locations = [
366+ # 1. Packaged wheel location (for pip-installed PyHelios)
367+ current_dir , # This is pyhelios/plugins/ when installed as wheel
368+ # 2. Development location (for local development)
369+ os .path .join (pyhelios_root , 'pyhelios_build' , 'build' , 'lib' )
370+ ]
371+
372+ for location in search_locations :
373+ if os .path .exists (location ):
374+ for lib_name in library_names :
375+ lib_path = os .path .join (location , lib_name )
376+ if os .path .exists (lib_path ):
377+ logger .debug (f"Found library at: { lib_path } " )
378+ return location
374379
375- # Library not found - provide clear error with actionable solution
380+ # Library not found in any location - provide clear error with actionable solution
376381 raise LibraryLoadError (
377- f"Native Helios library not found in expected location: { expected_location } \n "
382+ f"Native Helios library not found in any expected location.\n "
383+ f"Searched locations: { search_locations } \n "
378384 f"Expected library files: { ', ' .join (library_names )} \n \n "
379385 f"To fix this issue:\n "
380386 f"1. Build native libraries: ./build_scripts/build_helios --plugins visualizer\n "
0 commit comments