@@ -60,6 +60,19 @@ def get_helios_core_path(self) -> Optional[Path]:
6060 """Get the path to the helios-core directory."""
6161 return self ._find_helios_core ()
6262
63+ def _is_wheel_install (self ) -> bool :
64+ """
65+ Detect if we're running from an installed wheel package.
66+
67+ Returns:
68+ True if running from wheel installation, False otherwise
69+ """
70+ package_root = Path (__file__ ).parent
71+ pyhelios_parent = package_root .parent .parent # Go up to site-packages level
72+
73+ # Look for .dist-info directory which indicates wheel installation
74+ return any (pyhelios_parent .glob ('pyhelios-*.dist-info' ))
75+
6376 def _get_helios_build_path (self ) -> Optional [Path ]:
6477 """
6578 Find the HELIOS_BUILD directory containing assets.
@@ -74,18 +87,47 @@ def _get_helios_build_path(self) -> Optional[Path]:
7487 Returns:
7588 Path to build directory, or None if not found
7689 """
77- # PRIORITY 1: For pip-installed PyHelios, check packaged assets first
78- # This ensures pip users always get proper assets even if dev dirs exist
7990 package_root = Path (__file__ ).parent
80- packaged_build = package_root / 'build'
91+ packaged_build = package_root / 'build' # pyhelios/assets/build/
8192
82- # Check for packaged assets structure with comprehensive validation
93+ # Check if we're in a wheel installation
94+ is_wheel_install = self ._is_wheel_install ()
95+
96+ if is_wheel_install :
97+ # WHEEL INSTALL: Only check packaged assets location
98+ if (packaged_build .exists () and
99+ (packaged_build / 'lib' / 'images' ).exists () and
100+ len (list ((packaged_build / 'lib' / 'images' ).glob ('*' ))) > 0 ):
101+ logger .debug (f"Using wheel-installed assets: { packaged_build } " )
102+ return packaged_build
103+ else :
104+ # This is a critical packaging error for wheels
105+ raise RuntimeError (
106+ f"Wheel installation detected but assets not found at { packaged_build } . "
107+ f"This indicates a packaging error. Expected structure:\n "
108+ f" { packaged_build / 'lib' / 'images' } with image files"
109+ )
110+
111+ # DEVELOPMENT INSTALL: Check packaged assets first, then development paths
112+
113+ # PRIORITY 1: Check for packaged assets (even in development)
83114 if (packaged_build .exists () and
84115 (packaged_build / 'lib' / 'images' ).exists () and
85116 len (list ((packaged_build / 'lib' / 'images' ).glob ('*' ))) > 0 ):
86- logger .debug (f"Using pip-installed assets: { packaged_build } " )
117+ logger .debug (f"Using development packaged assets: { packaged_build } " )
87118 return packaged_build
88119
120+ # Log diagnostic information if packaged assets are missing or incomplete
121+ if packaged_build .exists ():
122+ logger .debug (f"Packaged assets directory exists but incomplete: { packaged_build } " )
123+ if not (packaged_build / 'lib' / 'images' ).exists ():
124+ logger .debug (" Missing lib/images directory" )
125+ else :
126+ image_count = len (list ((packaged_build / 'lib' / 'images' ).glob ('*' )))
127+ logger .debug (f" Found { image_count } images (need > 0 for validation)" )
128+ else :
129+ logger .debug (f"Packaged assets directory does not exist: { packaged_build } " )
130+
89131 # PRIORITY 2: For development, look for pyhelios_build/build directory
90132 # Only used if pip-installed assets are not available
91133 helios_core = self .get_helios_core_path ()
0 commit comments