Skip to content

Commit 9c9db8c

Browse files
committed
Automate basic project lifecycle with make
1 parent b181f51 commit 9c9db8c

File tree

3 files changed

+87
-1
lines changed

3 files changed

+87
-1
lines changed

Makefile

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
.PHONY: clean clean-docs clean-test clean-pyc clean-build dist docs help
2+
.DEFAULT_GOAL := help
3+
4+
SA:=source activate
5+
ENV:=hadoop-yarn-api-python-client
6+
7+
help:
8+
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
9+
10+
11+
## Setup conda environments
12+
env: ## Make a dev environment
13+
-conda env create --file requirements.yml --name $(ENV)
14+
15+
activate: ## Activate the virtualenv (default: hadoop-yarn-api-python-client)
16+
@echo "$(SA) $(ENV)"
17+
18+
nuke: ## Make clean + remove conda env
19+
-conda env remove -n $(ENV) -y
20+
21+
## Clean different build artifacts from multiple build phases
22+
23+
clean: clean-build clean-pyc clean-test clean-docs ## remove all build, test, coverage and Python artifacts
24+
25+
clean-build:
26+
rm -fr build/
27+
rm -fr dist/
28+
rm -fr .eggs/
29+
find . -name '*.egg-info' -exec rm -fr {} +
30+
find . -name '*.egg' -exec rm -f {} +
31+
32+
clean-pyc:
33+
find . -name '*.pyc' -exec rm -f {} +
34+
find . -name '*.pyo' -exec rm -f {} +
35+
find . -name '*~' -exec rm -f {} +
36+
find . -name '__pycache__' -exec rm -fr {} +
37+
38+
clean-test:
39+
rm -fr .tox/
40+
rm -f .coverage
41+
rm -fr htmlcov/
42+
rm -fr .pytest_cache
43+
44+
clean-docs:
45+
$(MAKE) -C docs clean
46+
47+
lint: ## check style with flake8
48+
$(SA) $(ENV) && flake8 yarn-api-client itests tests
49+
50+
test: ## run tests quickly with the default Python
51+
$(SA) $(ENV) && nosetests -v tests
52+
53+
docs: clean-docs ## generate Sphinx HTML documentation, including API docs
54+
$(SA) $(ENV) && $(MAKE) -C docs html
55+
56+
release: dist ## package and upload a release
57+
twine upload dist/*
58+
59+
dist: clean ## builds source and wheel package
60+
$(SA) $(ENV) && python setup.py bdist_wheel
61+
$(SA) $(ENV) && python setup.py sdist
62+
ls -l dist
63+
64+
install: clean ## install the package to the active Python's site-packages
65+
$(SA) $(ENV) && python setup.py install

requirements.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
channels:
2+
- conda-forge
3+
- defaults
4+
dependencies:
5+
- pip
6+
- requests>=2.7,<3.0
7+
8+
# Test Requirements
9+
- mock
10+
- nose
11+
- tox
12+
- pip:
13+
- requests_mock
14+
15+
# Code Style
16+
- flake8
17+
18+
# Documentation Requirements
19+
- recommonmark
20+
- sphinx=1.8.3
21+
- sphinx_rtd_theme

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def find_version(*file_paths):
4040
],
4141
},
4242

43-
tests_require = ['mock'],
43+
tests_require = ['mock', 'flake8'],
4444
test_suite = 'tests',
4545

4646
author = 'Iskandarov Eduard',

0 commit comments

Comments
 (0)