https://dagster.io/ logo
t

Taylor

03/15/2019, 12:08 AM
I use something like this to combat that kind of shenanigan:
Copy code
clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts

clean-build: ## Remove build artifacts
	rm -fr build/
	rm -fr dist/
	rm -fr .eggs/
	find . -name '*.egg-info' -exec rm -fr {} +
	find . -name '*.egg' -exec rm -f {} +

clean-pyc: ## Remove Python file artifacts
	find . -name '*.pyc' -exec rm -f {} +
	find . -name '*.pyo' -exec rm -f {} +
	find . -name '*~' -exec rm -f {} +
	find . -name '__pycache__' -exec rm -fr {} +

clean-test: ## Remove test and coverage artifacts
	rm -fr .tox/
	rm -f .coverage
	rm -fr htmlcov/
	rm -fr .pytest_cache

dist: clean ## Builds source and wheel package
	python setup.py sdist
	python setup.py bdist_wheel
	ls -l dist

release: dist ## Package and upload a release
	python setup.py sdist upload
Makefile, obviously.
s

schrockn

03/15/2019, 12:10 AM
this is excellent
t

Taylor

03/15/2019, 12:11 AM
here's the whole gem: ( i really like the
make
default help printout )
Copy code
.PHONY: clean clean-test clean-pyc clean-build docs help installl github test release notebooks
.DEFAULT_GOAL := help

define BROWSER_PYSCRIPT
import os, webbrowser, sys

try:
	from urllib import pathname2url
except:
	from urllib.request import pathname2url

webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1])))
endef
export BROWSER_PYSCRIPT

define PRINT_HELP_PYSCRIPT
import re, sys


HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDCOLOR = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'

print(OKBLUE + "You can run these make commands:\n" + ENDCOLOR)

for line in sys.stdin:
	match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line)
	if match:
		target, help = match.groups()
		print(OKGREEN + "%-30s " % target + ENDCOLOR + "%s" % (help))
endef
export PRINT_HELP_PYSCRIPT

BROWSER := python -c "$$BROWSER_PYSCRIPT"

help: ## Get help messages
	@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)

github: ## Open the GitHub repo for this project
	open <https://github.com/bbbb/{{module-name}}>

install: ## update your python environment
	pip install -r requirements.txt || echo 'No requirements.txt found'
	pip install -r dev-requirements.txt || echo 'No dev-requirements.txt found'
	pip install -e .
	pip list

test: ## Run tests
	pytest -s tests

clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts

clean-build: ## Remove build artifacts
	rm -fr build/
	rm -fr dist/
	rm -fr .eggs/
	find . -name '*.egg-info' -exec rm -fr {} +
	find . -name '*.egg' -exec rm -f {} +

clean-pyc: ## Remove Python file artifacts
	find . -name '*.pyc' -exec rm -f {} +
	find . -name '*.pyo' -exec rm -f {} +
	find . -name '*~' -exec rm -f {} +
	find . -name '__pycache__' -exec rm -fr {} +

clean-test: ## Remove test and coverage artifacts
	rm -fr .tox/
	rm -f .coverage
	rm -fr htmlcov/
	rm -fr .pytest_cache

dist: clean ## Builds source and wheel package
	python setup.py sdist
	python setup.py bdist_wheel
	ls -l dist

release: dist ## Package and upload a release to Gemfury
	python setup.py sdist upload -r fury

venv: ## Create a new virtualenv in the repo root
	rm -rf venv
	virtualenv venv
.PHONY: venv

notebooks: ## Run juypter lab for your notebooks
	jupyter lab

coverage: ## Check code coverage
	coverage run --source {{module-name}} -m pytest
	coverage report -m
	coverage html
	$(BROWSER) htmlcov/index.html
s

schrockn

03/15/2019, 12:18 AM
@max this is worth copying, er i mean being inspired by
m

max

03/15/2019, 12:18 AM
yeah for real
t

Taylor

03/15/2019, 12:18 AM
lol. Please enjoy. I've been cultivating that for a while.
part of my karmic reparations
obviously change the github slug
2 Views