I'm making my 1st official project. It's written in Python, is open-sources, and I'd like people to be able to freely and easily fork and modify the code. The project name is "shelf" and the main script/executable is shelf.py.
I'm trying to make everything modular. The main script shelf.py should be the only thing the end-user manually interact with.
My file structure and import hierarchy:
shelf.py
├── src
│ ├── config
│ │ └── configure.py
│ ├── data
│ │ └── database.py
│ ├── downloading
│ │ └── download.py
│ ├── system
│ │ ├── fileio.py
│ │ ├── rw
│ │ │ ├── open.py
│ │ │ └── save.py
│ │ └── reader.py
│ └── ui
│ ├── cli.py
│ ├── gtk.py
│ └── events
│ └── user_input.py
└── tests
Here, shelf.py is in the root of the directory.
"""shelf.py"""
import src.config.configure as configure
import src.data.database as database
import src.downloading.download as download
import src.system.fileio as fileio
import src.system.reader as reader
import src.ui.cli as cli
import src.ui.events as events
...
"""fileio.py"""
import rw.open
import rw.save
# ...
The rule I've made is that a script can only ever import scripts (modules) in a subdirectory. open.py may not import save.py, and vice-versa. Coupling of these modules is all done in the parent module, which is fileio.py for open.py and save.py.
This rule is made to avoid circular dependencies and modularize all the functions as much as possible. Most functions will be pure functions.
Is this rule of "import only modules in a subdirectory" viable for development?