aboutsummaryrefslogtreecommitdiff
path: root/python/Makefile
diff options
context:
space:
mode:
authorAlex Nicksay <nicksay@google.com>2016-12-21 04:17:11 -0500
committerEugene Kliuchnikov <eustas@google.com>2016-12-21 10:17:11 +0100
commit6ab0a5cee7a36b30012066caf6bca9a48fcae958 (patch)
tree23ae6ea4ace6e754de6629a2f3e65c2f7a7ae762 /python/Makefile
parentfd96151b2a04667dac73242b72bc62e007b2b543 (diff)
downloadbrotli-6ab0a5cee7a36b30012066caf6bca9a48fcae958.zip
brotli-6ab0a5cee7a36b30012066caf6bca9a48fcae958.tar.gz
brotli-6ab0a5cee7a36b30012066caf6bca9a48fcae958.tar.bz2
Python: Create Makefile for development shortcuts (#488)
Diffstat (limited to 'python/Makefile')
-rw-r--r--python/Makefile49
1 files changed, 49 insertions, 0 deletions
diff --git a/python/Makefile b/python/Makefile
new file mode 100644
index 0000000..cdf3aac
--- /dev/null
+++ b/python/Makefile
@@ -0,0 +1,49 @@
+# Copyright 2016 The Brotli Authors. All rights reserved.
+#
+# Distributed under MIT license.
+# See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
+
+
+# Default
+.PHONY: all
+# Build
+.PHONY: build
+# Test
+.PHONY: test tests
+# Clean
+.PHONY: clean
+# Format
+.PHONY: fix
+
+
+PYTHON ?= python
+YAPF ?= yapf
+
+EXT_SUFFIX=$(shell $(PYTHON) -c 'import sysconfig; print(sysconfig.get_config_var("EXT_SUFFIX"))')
+EXT_SOURCES=$(shell find . -name '*.cc')
+EXTENSIONS=$(EXT_SOURCES:%.cc=%$(EXT_SUFFIX))
+
+
+all: build
+
+build: $(EXTENSIONS)
+
+$(EXTENSIONS): $(EXT_SOURCES)
+ @cd .. && $(PYTHON) setup.py develop
+
+test: tests
+
+tests: build
+ @echo 'running tests'
+ @$(PYTHON) -m unittest discover -p '*_test.py'
+
+clean:
+ @cd .. && $(PYTHON) setup.py clean
+ @find .. -name '*.pyc' | xargs rm -v
+ @find .. -name '*.so' | xargs rm -v
+ @find .. -type d -name '__pycache__' | xargs rm -v -r
+ @find .. -type d -name '*.egg-info' | xargs rm -v -r
+
+fix:
+ @echo 'formatting code'
+ -@$(YAPF) --in-place --recursive --verify .