This is an example starter python project that can be used to kickstart various types of python projects.
The main branch is for a simple Python app and can be used as the starting point for other types of applications.
There are also branches for:
- FastAPI (
fastapi) - FastAPI with Postgres (
fastapi-pg)
.tool-versionsfile with the version of Python that was last used with this starter project.vscodeVS Code settings to make it easier to work with the projectbinscripts to assist with initializing the application and suchsrc/dev_requirements.txtdependencies used during development and testingsrc/requirements.txtruntime dependenciessrc/appthe Python appsrc/testthe PyTest tests
I used to run my Python apps on Docker using Docker Compose, but I always ended up down a rabbit hole trying to get formatting and linting to work in the way that I wanted. I still use Docker Compose if I want to run things like Postgres, but I expose the ports locally instead. This allows me to have a simpler dev environment and save containerizing for deployed environments.
- Clone this repo, delete the
.gitfolder and then start a new git history. - Run the init script
./bin/initto set up the virtual environment etc.
git clone [email protected]:urfolomeus/python-starter my-project
cd my-project
rm -rf .git
git init
git add .
git commit -m "Initial commit"
./bin/initThe ./bin/init script will create a .envrc file as a copy of the included .envrc-example file. This can be applied using a tool like direnv, or in any other way that you choose to apply environment variables. You may need to adjust some of the values before applying.
Ensure that we are in the virtual environment and then run the code as a Python module.
source .venv/bin/activate # activate.fish if in a fish shell
python -m src.app.mainTests can be run manually with pytest or pytest <path/to/file>. Alternatively, we can use Pytest Watch to run the tests automatically when a file is changed with ptw.