A Lean template for a Python project with several quality-of-life improvements.
- Contains a custom logger that uses LoggerAdapters instead of creating new loggers for every file.
- Makes it easy to import from different folders within the project.
- Centralizes configuration.
- Automatically reads secrets from a .env file placed at the root of the project and places them into the environment for the duration of the execution.
- Uncomment .env from .gitignore when using it for actual secrets.
- Add your project configurations to config.py. Examples are provided within the file.
- In subfolders, be sure to
import __initpkg__.pyin all your files (okay, it is possible not every file will need to).from __initpkg__ import CONFIGmakes sure the configurations in config.py take place, and all project folders get inserted into PYTHONPATH. Also, the configurations in the CONFIG variable will now be accessible.
python -m venv venv- Win:
source ./venv/Scripts/activateLinux:source ./venv/bin/activate pip install -r requirements.txtpython examples/example.py
- If anyone finds the template useful, I'd be glad to know!
- https://github.com/iamarxs/PythonLeanTemplate