Created
November 30, 2020 16:53
-
-
Save vndmtrx/3c3538125c63d218fbe8bb7be47ce822 to your computer and use it in GitHub Desktop.
My Makefile for bootstrapping Python projects
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
And after
makecommand, just runsource .venv/bin/activateto enter the virtual enviroment anddeactivateto exit.