speechbrain/speechbrain

`speechbrain/__init__.py` is ignored in pip editable installs for scripts out of repo

asumagic opened this issue · 1 comments

Describe the bug

Provided that the following conditions are met:

  • The user has installed SpeechBrain with pip install --editable .
  • AND he script is NOT being run from somewhere within the speechbrain/ directory

... then the root speechbrain __init__.py file is not invoked when importing SpeechBrain. This has the consequence that referring to sb.Brain does not work and prevents us from cleanly doing things like deprecated module redirections.

We probably have never noticed because editable installs mean you're likely editing recipes in-tree (meaning Python will discover the __init__.py files walking up anyway) and usually not running things outside the repo, but this is still a problem and very confusing if you don't realize what's happening.

Other module __init__.py files seem to work fine, only the package-level one seems to cause an issue. This might be a design limitation of editable installs but I have yet to find the end reason for it.

Expected behaviour

speechbrain/__init__.py should be invoked with editable installs.

Thus, the following should not crash when ran from outside the repo:

import speechbrain as sb
print(sb.Brain)

To Reproduce

No response

Environment Details

No response

Relevant Log Output

No response

Additional Context

No response

For a reason I don't understand I no longer can reproduce this at all. I feel like this was some weird issue with caching, but I don't know what prompted it.