0

I have a project with the current structure

src/
  main.py
  frames/
    __init__.py
    base_frame.py
    control_frame.py

This is how my __init__.py file looks like:

from os.path import dirname, basename, isfile, join
import glob
modules = glob.glob(join(dirname(__file__), "*.py"))

ignore = ['__init__.py']
__all__ = [ basename(f)[:-3] for f in modules if isfile(f) and not basename(f) in ignore]

My baseframe.py includes a couple of @abstractmethod that needs to be included by my other frames. How I'm currently including my baseframe to the other frames is by doing from frames.base_frame import BaseFrame. This works perfect when including from main.py

Now I want to write a couple of tests and I don't want to have these cluttering the src folder, so I would either want them like

src/
  frames/
  tests/
    test.py

or

src/
  frames/
  ...
tests/
  test.py

but from here I can't really import frames. It just throws ModuleNotFoundError: No module named 'frames'

How can I make my frames module available to other directories?

Kvixen
  • 57
  • 6

0 Answers0