This is likely dependent on what you are building. The article I linked in my comment breaks out different layouts like so:
CLI Layouts:
- One-Off Script
- Installable Single Package
- Application with Internal Packages
Web App Layouts:
- Django
- Flask
While link only answers are discouraged here, I think its counter productive to rehash the whole article but the "Installable Single Package" layout has worked for me and looks like this (borrowed from the same article):
helloworld/
β
βββ helloworld/
β βββ __init__.py
β βββ helloworld.py
β βββ helpers.py
β
βββ tests/
β βββ helloworld_tests.py
β βββ helpers_tests.py
β
βββ .gitignore
βββ LICENSE
βββ README.md
βββ requirements.txt
βββ setup.py
NOTE: If you have a data directory, I would put it at the same level as tests
GitHub
github.com βΊ nedbat βΊ pkgsample
GitHub - nedbat/pkgsample: A simple example of how to structure a Python project Β· GitHub
You should examine the files here, decide which are right for you, and adapt them to your needs. This directory is where you put your code. It should have one subdirectory named for your project, and all of your work goes into that subdirectory.
Starred by 736 users
Forked by 104 users
Languages: Python 56.6% | Dockerfile 43.4%
Starred by 17 users
Forked by 4 users
Languages: Python 100.0% | Python 100.0%
GitHub
gist.github.com βΊ dl6nm βΊ 858504f58b54f9763cd412e93e6a9a44
Python Project Code Structure, App with internal packages, Β· GitHub
Iβve adapted this from Jean-Paul Calderoneβs classic structure post, and his prescriptions for the use of a bin/ directory are still important. The most important point to remember is that your executable shouldnβt have a lot of code, just an import and a call to a main function in your runner script. If you are using pure Python ...
GitHub
gist.github.com βΊ ericmjl βΊ 27e50331f24db3e8f957d1fe7bbbe510
How to organize your Python data science project Β· GitHub
I have a lesson learned from multiple months of working with other people that led me to this somewhat complicated, but hopefully ultimately useful directory structure. Under this folder called projectname/, we put in a lightweight Python package called projectname that has all things that are refactored out of notebooks to keep them clean.
GitHub
github.com βΊ pyscaffold βΊ pyscaffold
GitHub - pyscaffold/pyscaffold: π Python project template generator with batteries included
The project template provides you with following features: All configuration can be done in setup.cfg like changing the description, URL, classifiers, installation requirements and so on as defined by setuptools. That means in most cases it is not necessary to tamper with setup.py. In order to build a source or wheel distribution, just run tox -e build (if you don't use tox, you can also install build and run python -m build).
Author: pyscaffold
GitHub
github.com βΊ topics βΊ project-structure
project-structure Β· GitHub Topics Β· GitHub
All 287 Python 60 TypeScript 44 Go 28 JavaScript 22 Jupyter Notebook 21 Shell 10 HTML 8 C# 7 Java 6 Makefile 5 ... PyTorch Lightning + Hydra. A very user-friendly template for ML experimentation. β‘π₯β‘ Β· config template deep-learning best-practices pytorch hydra reproducibility project-structure ...
Away With Ideas
awaywithideas.com βΊ the-optimal-python-project-structure
The optimal python project structure | Away With Ideas
March 21, 2020 - Some examples of .gitignore files can be found in this github repository. I usually start with a small number of files and build gradually. My basic .gitignore might resemble this: # Pycache and compiled python files. __pycache__/ *py[cod] # Jupyter notebook checkpoints .ipynb_checkpoints #Egg info files produced by pip installation *egg-info Β· A readme is a documentation file often written in markdown. It contains useful information so that others can understand what your project is about.
Goodresearch
goodresearch.dev βΊ setup.html
Set up your project β Good research code
If doing all this for every new project sounds like a lot of work, you can save yourself some time using the true neutral cookiecutter, which creates the project skeleton outlined above automatically. cookiecutter is a Python tool which generates project folders from templates. You can install it in the base conda environment with: ... There are many other interesting cookiecutters. Check out the data science cookiecutter for a more elaborate data science project template. This will create an instance of the true-neutral-cookiecutter project skeleton, which is hosted on my personal github. Follow the prompts and it will create the folder structure above, including the setup file.