4 # The master makefile sets up the follosing customizable (double-colon) targtets.
7 # This optional target may be used by the user to install the necessary
8 # system requirements via 'aptitude'. Must be called as root
11 # Called for basic setup. Executed before installing the basic eggs
14 # Called to install eggs
17 # Called to install the buildout (e.g. call paster create)
20 # Called after the buildout is installed but BEFORE bootstraping
23 # Called BEFORE updating the buildout (e.g. before calling bin/buildout)
26 # Called to bootstrap the buildout. Here you can add actions to be
27 # performed AFTER bootstraping the project whenever a bootstrap is performed
30 # Called to update the buildout (calls bin/buildout). Here you can add
31 # commands to call AFTER bin/buildout returns.
34 # Called to populate the .gitignore file. Use '@$(gitignore) <pattern>' to
38 # Called to add environment variables to be set when executing a shell
39 # Use @$(env) <var> <value> to add a variable settings. <var> may be
40 # PATH Add <value> to PATH
41 # PYTHONPATH Add <value> to PYTHONPATH
42 # <other> Set variable to <value>
45 # Called to clean up all generated files
48 ###########################################################################
58 # @$(httpget) <url> [<target>]
60 # Download <url> to <target>. If <target> is missing, <target> defaults to
61 # the last component of the <url>.
63 # If the file exists in $(DLCACHE), it is retrieved from there instead.
68 [ -n "$$target" ] || target="$$name"; \
69 cache="$(DLCACHE)/$$name"; \
70 if [ -r "$$cache" ]; then \
71 echo "Fetching '$$name' from cache."; \
73 [ -z "$(NONET)" ] || ( echo "Missing '$$1'."; exit 2 ); \
74 echo "Downloading '$$1'."; \
75 wget -O "$$cache" "$$1"; \
77 cp "$$cache" "$$target"; \
85 # Downloads egg to '$(DLCACHE)/<package>-*.egg' unless a file with that name
88 # THIS DOES NOT WORK WITH ALL PACKAGES !!! USE WITH CARE
91 if [ -r $(DLCACHE)/$$1-*.egg ]; then \
92 name="`cd $(DLCACHE); echo $$1-*.egg`"; \
93 echo "Fetching '$$name' from cache."; \
95 [ -z "$(NONET)" ] || ( echo "Missing '$$1'."; exit 2 ); \
96 $(EASY_INSTALL) -zmaxd $(DLCACHE) $$1; \
97 name="`cd $(DLCACHE); echo $$1-*.egg`"; \
98 if [ -d $(DLCACHE)/$$name ]; then \
99 cd $(DLCACHE)/$$name; \
100 zip -r ../$$name.zip .; \
103 mv $$name.zip $$name; \
113 # @$(install) <package>
115 # Downloads egg to '$(DLCACHE)/<package>-*.egg' and installs it unless a file
116 # with that name already exists.
119 echo $(PIP_CACHE_FILES); \
120 echo "$(PIP) install --download-cache="$(DLCACHE)/pip" $(PIP_OPTS) $$1"; \
121 $(PIP) install --download-cache="$(DLCACHE)/pip" $(PIP_OPTS) "$$1"; \
126 ###########################################################################
127 # Customization targets
133 mkdir -p $(DLCACHE) $(DLCACHE)/pip
149 sed -i -e '1s/^#!.*\/python/#!$(subst /,\/,$(PYTHON))/' $(PYTHON_DIR)/bin/*
150 $(PYTHON) -c 'from zc.buildout.buildout import main; main(["bootstrap"])'
153 bin/buildout $(BUILDOUT_OPTS)
157 [ -r .gitignore ] || touch .gitignore; \
158 grep -qxF "$$1" .gitignore || echo "$$1" >>.gitignore; \
163 @echo "Updating .gitignore."
164 @$(gitignore) "*.pyc"
165 @$(gitignore) "*.egg-info/"
166 @$(gitignore) "/.env"
167 @$(gitignore) "/$(DLCACHE)/"
171 [ -r .env ] || touch .env; \
173 PATH|PYTHONPATH) line="export $$1=\"$$2:\$$$$1\"" ;; \
174 *) line="export $$1=\"$$2\"" ;; \
176 grep -qxF "$$line" .env || echo "$$line" >>.env; \
181 @echo "Updating .env."
184 rm -f .gitignore .env
187 ###########################################################################
193 for file in *.tar.gz; do \
194 name="$${file##*%2F}"; \
195 if [ "$$name" != "$$file" -a ! -r "$$name" ]; then \
196 ln -s $$file $$name || exit 1; \
201 PIP_CACHE_FILES := $(shell cd $(DLCACHE)/pip; ls *.tar.gz | grep -vF '%2F')
203 do-init-nonet: PIP_OPTS = --no-index $(patsubst %,--find-link=file://$(BASEDIR)/$(DLCACHE)/pip/%,$(PIP_CACHE_FILES))
204 do-init-nonet: BUILDOUT_OPTS = -N
205 do-init-nonet: NONET=1
208 ###########################################################################
211 init: setup eggs buildout init-hook update-hook bootstrap update .gitignore .env
213 init-nonet: prepare-pipcache
214 @$(MAKE) do-init-nonet
217 @echo "# Add the following lines to [versions] in buildout.cfg to pin all packages"
218 @bin/buildout -vvvvv | sed -ne 's/^Picked: //p' | sort | uniq
221 @eval "`cat .env`"; $$SHELL
223 update-nonet: BUILDOUT_OPTS=-No