Skip to content

Commit faf7ae2

Browse files
committed
Added bundle-building code.
1 parent 5408773 commit faf7ae2

File tree

1 file changed

+55
-35
lines changed

1 file changed

+55
-35
lines changed

Makefile

Lines changed: 55 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,55 @@
1-
VENV=.venv
2-
PYTHON=$(shell which python3.4)
3-
4-
virtual-env:
5-
$(PYTHON) -m venv $(VENV)
6-
7-
pygraphviz:
8-
@git clone https://github.com/pygraphviz/pygraphviz
9-
@. $(VENV)/bin/activate && \
10-
cd pygraphviz && \
11-
git checkout 6c0876c9bb158452f1193d562531d258e9193f2e && \
12-
git apply ../patches/graphviz-includes.diff && \
13-
python setup.py install
14-
@rm -rf pygraphviz
15-
16-
17-
deps: pygraphviz
18-
. $(VENV)/bin/activate && \
19-
pip3.4 install -r requirements.txt
20-
21-
setup: virtual-env deps
22-
23-
run:
24-
. $(VENV)/bin/activate && \
25-
ipython notebook notebooks/mmpl-preview.ipynb
26-
27-
clean:
28-
rm -rf $(VENV)
29-
30-
# Use the following make target like so:
31-
#
32-
# $ SCRIPT=./my-script.py LAYOUT=twopi MODE=simple make modgraph
33-
modgraph:
34-
python third-party/modgraph.py $(SCRIPT) $(LAYOUT) $(MODE) && \
35-
open modgraph.png
1+
ROOT_DIR = $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
2+
BUNDLE_NAME = code-bundle
3+
BUNDLE_DIR = $(shell dirname $(ROOT_DIR))/$(BUNDLE_NAME)
4+
BUNDLE_ZIP = $(BUNDLE_DIR).zip
5+
CHAPTERS = 01-preview 02-architecture 03-apis 04-interaction 05-high-level 06-custom-and-config 07-cloud-deploy 08-big-data 09-clustering
6+
REPO_BASE = git@github.com:masteringmatplotlib
7+
8+
# git clone git@github.com:masteringmatplotlib/preview.git 01-preview
9+
# git submodule init && git submodule update
10+
11+
$(BUNDLE_DIR):
12+
@echo
13+
@echo "Creating $(BUNDLE_DIR) ..."
14+
@mkdir $(BUNDLE_DIR)
15+
@make download-code
16+
@make strip-git
17+
18+
$(BUNDLE_ZIP):
19+
@echo
20+
@echo "Creating $(BUNDLE_ZIP) ..."
21+
@zip -r $(BUNDLE_DIR) $(BUNDLE_DIR)
22+
23+
bundle: $(BUNDLE_DIR) $(BUNDLE_ZIP)
24+
@echo
25+
@echo "Your code bundle is available here:"
26+
@echo " $(BUNDLE_ZIP)"
27+
28+
download-code:
29+
@echo
30+
@echo "Downloading code ..."
31+
@for CHAP in $(CHAPTERS); \
32+
do \
33+
REPO=`echo $$CHAP|cut -c 4-`; \
34+
git clone $(REPO_BASE)/$${REPO}.git $(BUNDLE_DIR)/$$CHAP; \
35+
cd $(BUNDLE_DIR)/$$CHAP && \
36+
git submodule init && git submodule update; \
37+
done
38+
39+
strip-git:
40+
@echo
41+
@echo "Removing git files ..."
42+
@rm -rf $(BUNDLE_DIR)/*/.git*
43+
@rm -rf $(BUNDLE_DIR)/*/include/.git
44+
45+
bundle-clean:
46+
@echo
47+
@echo "Removing $(BUNDLE_DIR) ..."
48+
@rm -rf $(BUNDLE_DIR)
49+
50+
bundle-zip-clean:
51+
@echo
52+
@echo "Removing $(BUNDLE_ZIP) ..."
53+
@rm -f $(BUNDLE_ZIP)
54+
55+
clean-all: bundle-clean bundle-zip-clean

0 commit comments

Comments
 (0)