[chirp_devel] [PATCH] Try harder to find resources. #4487
Shared resources are not located if chirp is installed to a virtualenv. Platform.executable_path() is searched for shared resources but, in a virtualenv, this returns the site-packages directory. The shared resources are located in (venv root)/share, which is a not a child of the site-packages directory.
This patch searches sys.prefix for data_files for compatibility with virtualenv installations and consolidates some of the resource-finding logic.
Thanks, Tim
- def find_resource(self, filename):
"""Searches for files installed to a share/ prefix."""
execpath = self.executable_path()
share_candidates = [
os.path.join(execpath, "share"),
os.path.join(sys.prefix, "share"),
"/usr/local/share",
"/usr/share",
]
I'd have to go check, but I think that some of the stuff ends up flattened in the windows build (for better or worse).
Any reason you can't just leave execpath in the list so we don't need to argue? (i.e. compatibility with what is there now just in case).
Otherwise looks cool to me.
--Dan
- def find_resource(self, filename):
"""Searches for files installed to a share/ prefix."""
execpath = self.executable_path()
share_candidates = [
os.path.join(execpath, "share"),
os.path.join(sys.prefix, "share"),
"/usr/local/share",
"/usr/share",
]
I'd have to go check, but I think that some of the stuff ends up flattened in the windows build (for better or worse).
Any reason you can't just leave execpath in the list so we don't need to argue? (i.e. compatibility with what is there now just in case).
I snipped too early:
pkgshare_candidates = [os.path.join(i, "chirp") for i in share_candidates]
search_paths = [execpath] + pkgshare_candidates + share_candidates
execpath is in there ^.
So, uh, nevermind, applied. Thanks!
--Dan
participants (2)
-
Dan Smith
-
Tim Smith