netaddr / netaddr

A network address manipulation library for Python

Home Page:https://netaddr.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Avoid use of __file__

jayvdb opened this issue · comments

It appears the use of __file__ here is mostly unnecessary, and can easily be replaced with importlib.resources/pkgutil. 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.

Currently the backtrace looks like:

    from netaddr.eui.ieee import OUIIndexParser, IABIndexParser, FileIndexer
netaddr.eui.ieee:43: in <module>
    ???
E   NameError: name '__file__' is not defined

Loading of resources from the runtime package should ideally be done using importlib.resources and backport importlib_resources, 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.

I believe this is fixed in 0.7.20, please reopen if there are still issues related to this.