If you're not doing a data science project, but just want a quick and dirty file structure for packaging your code as a Python package, this minimalistic template structure might be useful to you.
For data science projects where you train models, run experiments, that sort of thing, I suggest you take a look at my other template: https://github.com/hviidhenrik/my-sample-data-science-structure
- Create a new repo on GitHub using this as a template.
- Clone your new repo locally.
- Change the names of:
- the
importname
directory which holds your source code to match your project e.g.,numpy
, if this was the numpy package.* packagename
in setup.py - this is the name of your package and used when installing it in other projects.
- the
- Write your code!
*This directory is sometimes called simply src
, but this could cause problems if you have other custom-built
packages using this name as this directory will house your source code and thus be used in imports in other projects.
The template comes predefined with some helpful path definitions. See them in: importname/config/definitions.py
The files were formatted using isort and black. I recommend running isort to sort imports correctly and then format code nicely using black with a line length of 120. Black uses 88 per default, but this sometimes causes too many line breaks in my opinion. Just do what makes you happy!
isort .
black . --line-length=120
├── README.md <- The top-level README for developers using this project.
├── main.py <- Main script to execute program with sample command line functionality
├── requirements.txt <- The requirements file for reproducing the analysis environment, e.g.
│ generated with `pipreqs .`
├── tests <- Units tests and test fixtures - I recommend using pytest
├── setup.py <- makes project pip installable (pip install -e .) so importname can be imported
├── importname <- Source code for use in this project. The name you'll use to import stuff
├── __init__.py <- Makes importname a Python module
├── config <- Directory for defitions of paths and other useful stuff
├── core.py <- Core funtionality goes here
├── utils.py <- Utility functions go here