I have a file `package.py` that i am trying to package into `package.pyd`. I have the following statement in `package.py`

```
    CURR = os.path.dirname(os.path.realpath(__file__))

```

which works fine when I run `package.py` but when I import `package.pyd` into another file `wrapper.py` I get the following error message

```
Traceback (most recent call last):
  File "C:\Projects\Wrapper.py", line 1, in <module>
    import package
  File "package.py", line 40, in init package (package.c:4411)
NameError: name '__file__' is not defined

```

How can I get the location of the .pyd file. Also is there a way to check if it is being run as a .pyd or .py.

Thank you!