-
Notifications
You must be signed in to change notification settings - Fork 467
Description
#533 replaced custom data lookup with __file__, which works only if the resources are exported to a filesystem. See indygreg/PyOxidizer#69 for more info about why, but the tl;dr version is __file__ is an optional attribute and should not be relied upon. It also requires each zip/pack tool to fiddle with __file__.
Here is the current backtrace when __file__ is not provided:
File "babel", line 20, in <module>
from babel.core import UnknownLocaleError, Locale, default_locale, \
File "babel.core", line 14, in <module>
from babel import localedata
File "babel.localedata", line 24, in <module>
_dirname = os.path.join(os.path.dirname(__file__), 'locale-data')
NameError: name '__file__' is not definedThere are stdlib APIs for this type of access, especially the now ancient pkgutil.get_data, and the newer importlib.resources and backport importlib_resources.
Loading of resources from the runtime package should ideally be done using importlib.resources and its backport , however pkgutil could be used to avoid the need for the backport. Using pkgutil doesn't work under PyOxidizer 0.4, however I expect that will be fixed soon.