Open
Description
Feature
Mypyc should set __file__
Pitch
Getting installation directory is important when referencing data files included in your package.
Things like this are common:
DATA_FOLDER: Final = Path(__file__).parent / "data"
Currently, mypyc will compile this with no warnings about possible issues and crash with
Traceback (most recent call last):
<unrelated details>
File "src/checkers/game.py", line 108, in <module>
DATA_FOLDER: Final = Path(__file__).parent / "data"
KeyError: '__file__'
There is a workaround for this, doing something like this before hand
if globals().get("__file__") is None:
import inspect
__file__ = inspect.stack()[0].filename
but that's messy