@@ -73,22 +73,29 @@ def tag_exists(tag_url: str) -> bool:
7373def find_local_support_data () -> Optional [Path ]:
7474 """
7575 Return the path to the local ``supportData`` directory if running
76- from a cloned repo in editable mode , otherwise return ``None``.
76+ from a cloned repo, otherwise return ``None``.
7777
78- Editable installs place modules under ``dist3/Basilisk/``, while the
79- repo's ``supportData`` directory lives at the project root.
78+ Works whether running from source (src/) or from built modules (dist3/Basilisk/).
8079 """
8180 module_path = Path (__file__ ).resolve ()
82- repo_root = module_path .parents [3 ]
83- support_data = repo_root / "supportData"
84- return support_data if support_data .is_dir () else None
81+ # Walk up the directory tree looking for supportData. From src/ it's 4
82+ # levels up, from dist3/Basilisk/ it's 5 levels up.
83+ for parent in list (module_path .parents )[:6 ]:
84+ support_data = parent / "supportData"
85+ if support_data .is_dir ():
86+ return support_data
87+ return None
8588
8689
8790# Compute the base GitHub URL once at import time.
88- # With the caching on `tag_exists` this avoids repeated network calls during
89- # file fetches.
9091LOCAL_SUPPORT = find_local_support_data ()
91- BASE_URL = f"https://raw.githubusercontent.com/AVSLab/basilisk/{ DATA_VERSION } /"
92+
93+ # For remote fetches (wheel installs), check if the version tag exists. Fall
94+ # back to develop if not
95+ _version_tag_url = f"https://github.com/AVSLab/basilisk/releases/tag/{ DATA_VERSION } "
96+ _remote_version = DATA_VERSION if tag_exists (_version_tag_url ) else "develop"
97+ BASE_URL = f"https://raw.githubusercontent.com/AVSLab/basilisk/{ _remote_version } /"
98+
9299POOCH = pooch .create (
93100 path = pooch .os_cache ("bsk_support_data" ),
94101 base_url = BASE_URL ,
@@ -118,13 +125,18 @@ def get_path(file_enum: Enum) -> Path:
118125 if local .exists ():
119126 return local
120127
121- # Fall back to pooch cache or remote source
128+ # When running locally, allow remote fetch for external URLs like the
129+ # large NAIF kernels not included in the repo.
130+ if rel in EXTERNAL_KERNEL_URLS :
131+ return Path (POOCH .fetch (rel ))
132+
133+ raise FileNotFoundError (f"Support data file not found in local repo: { local } " )
134+
135+ # No local repo - fetch from remote (installed from wheel)
122136 try :
123137 return Path (POOCH .fetch (rel ))
124138 except Exception as e :
125- raise FileNotFoundError (
126- f"Support data file not found locally or via pooch: { rel } "
127- ) from e
139+ raise FileNotFoundError (f"Support data file not found via pooch: { rel } " ) from e
128140
129141
130142class DataFile :
@@ -194,6 +206,7 @@ class MagneticFieldData(Enum):
194206 class SkyBrightnessData (Enum ):
195207 skyTemperature408MHz = "haslam408_dsds_Remazeilles2014.fits"
196208
209+
197210CATEGORY_BASE_PATHS = {
198211 "AlbedoData" : ALBEDO_DATA_BASE_PATH ,
199212 "AtmosphereData" : ATMOSPHERE_DATA_BASE_PATH ,
0 commit comments