Created
October 26, 2018 02:18
-
-
Save scotchneat/6757cd3b3752eedee7e5352676053d94 to your computer and use it in GitHub Desktop.
Sample Makefile for a Python application
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
PACKAGE_NAME = package-name | |
VIRTUALENV = virtualenv --python=python3.7 | |
VENV = .venv | |
VENV_ACTIVATE = . $(VENV)/bin/activate | |
help: ## Prints this help message. | |
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' | |
$(VENV): | |
$(VIRTUALENV) $(VENV) | |
venv: $(VENV) ## Create Python virtual environment. | |
$(VENV_ACTIVATE) | |
install: venv ## Install/upgrade project and development requirements in virtual environment. | |
$(VENV_ACTIVATE); pip install -e .[test]; | |
clean: venv ## Cleans up existing development dependencies | |
rm -fr .venv dist $(PACKAGE_NAME).egg-info | |
lint: venv install ## Run code analysis and validation | |
$(VENV_ACTIVATE); flake8 --filename='*.py' --statistics $(PACKAGE_NAME)/. tests/.; | |
test: venv install ## Run the server | |
$(VENV_ACTIVATE); pytest --cov=$(PACKAGE_NAME) tests/; | |
package: venv ## Run the server | |
$(VENV_ACTIVATE); python setup.py sdist --formats=gztar; ls dist/$(PACKAGE_NAME)-*.tar.gz; | |
package-dev: venv ## Run the server | |
$(VENV_ACTIVATE); pip install -e . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment