Skip to content

Commit 118e384

Browse files
committed
Add linting and building
1 parent 4f83a65 commit 118e384

File tree

4 files changed

+40
-2
lines changed

4 files changed

+40
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ __pycache__/
22
build/
33
click_command_tree.egg-info/
44
dist/
5+
.eggs/

Makefile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
PYTHON3=/usr/bin/python3
2+
BUILD_DIR=build
3+
DIST_DIR=dist
4+
VIRTUALENV=$(BUILD_DIR)/_virtualenv
5+
VIRTUALENV_BIN=$(VIRTUALENV)/bin
6+
ACTIVATE=$(VIRTUALENV_BIN)/activate
7+
8+
.PHONY: clean test
9+
10+
clean:
11+
rm -rf $(BUILD_DIR) $(DIST_DIR)
12+
13+
lint: $(ACTIVATE)
14+
$(VIRTUALENV_BIN)/python setup.py flake8
15+
16+
test: $(ACTIVATE)
17+
$(VIRTUALENV_BIN)/python -m unittest discover -v
18+
19+
build-dist: clean $(ACTIVATE) lint test
20+
$(VIRTUALENV_BIN)/python setup.py sdist bdist_wheel
21+
22+
publish-dist: build-dist
23+
$(VIRTUALENV_BIN)/pip install twine==1.12.1 && \
24+
$(VIRTUALENV_BIN)/twine upload dist/*
25+
26+
$(VIRTUALENV) $(ACTIVATE):
27+
@command -v virtualenv >/dev/null 2>&1 || { echo >&2 "This build requires virtualenv to be installed. Aborting."; exit 1; }
28+
@mkdir -p $(BUILD_DIR)
29+
@if [ -d $(VIRTUALENV) ]; then \
30+
echo "Existing virtualenv found. Skipping virtualenv creation."; \
31+
else \
32+
echo "Creating virtualenv at $(VIRTUALENV)"; \
33+
virtualenv $(VIRTUALENV) --python=$(PYTHON3); \
34+
fi
35+
. $(ACTIVATE) && pip install .

click_command_tree.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ def __repr__(self):
2424
return '{{_CommandWrapper {}}}'.format(self.name)
2525

2626

27-
2827
def _build_command_tree(click_command):
2928
wrapper = _CommandWrapper(click_command)
3029

setup.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,14 @@
1818
'License :: OSI Approved :: MIT License',
1919
'Programming Language :: Python :: 3'
2020
],
21-
py_modules=['click_command_tree'],\
21+
py_modules=['click_command_tree'],
2222
include_package_data=True,
2323
install_requires=[
2424
'click',
2525
],
26+
setup_requires=[
27+
'flake8==3.7.5',
28+
],
2629
entry_points='''
2730
[click_command_tree]
2831
tree=click_command_tree:tree

0 commit comments

Comments
 (0)