Skip to content

Instantly share code, notes, and snippets.

@vndmtrx
Created November 30, 2020 16:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vndmtrx/3c3538125c63d218fbe8bb7be47ce822 to your computer and use it in GitHub Desktop.
Save vndmtrx/3c3538125c63d218fbe8bb7be47ce822 to your computer and use it in GitHub Desktop.
My Makefile for bootstrapping Python projects
SHELL := /bin/bash
.SHELLFLAGS = -e -c
.ONESHELL:
.PHONY: clean freeze
PRJ_NAME = Project Name
.venv: .venv/bin/activate
.venv/bin/activate: requirements.txt
test -d .venv || python3 -m venv .venv/ --prompt $(PRJ_NAME)
source .venv/bin/activate
pip install --upgrade pip setuptools
pip install wheel
test -f requirements.txt && pip install -r requirements.txt
deactivate
freeze: .venv
source .venv/bin/activate
pip freeze | grep -v "pkg-resources" > requirements.txt
deactivate
clean:
find . -name "*.pyc" -type f -delete
find . -name __pycache__ -type d -exec rm -rf {} 2> /dev/null +
find . -name "*.egg-info" -type d -exec rm -rf {} 2> /dev/null +
find . -type d -empty -delete
test -d .venv && rm -r .venv
@vndmtrx
Copy link
Author

vndmtrx commented Nov 30, 2020

And after make command, just run source .venv/bin/activate to enter the virtual enviroment and deactivate to exit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment