PYTHON_VERSION ?= 2.4.6
PYTHON_URL ?= http://www.python.org/ftp/python/$(PYTHON_VERSION)/Python-$(PYTHON_VERSION).tgz
SETUPTOOLS_URL ?= http://peak.telecommunity.com/dist/ez_setup.py
+PYTHON_DIR ?= python
###########################################################################
-PYTHON_DIR ?= python
-
PYTHON = $(BASEDIR)/$(PYTHON_DIR)/bin/python
EASY_INSTALL = $(BASEDIR)/$(PYTHON_DIR)/bin/easy_install
PIP = $(BASEDIR)/$(PYTHON_DIR)/bin/pip
PASTER = $(BASEDIR)/$(PYTHON_DIR)/bin/paster
+# Usage:
+# @$(dlegg) <package>
+#
+# Downloads egg to '$(DLCACHE)/<package>-*.egg' unless a file with that name
+# already exists.
+#
+# THIS DOES NOT WORK WITH ALL PACKAGES !!! USE WITH CARE
+define dlegg
+ _dlegg() { \
+ if [ -r $(DLCACHE)/$$1-*.egg ]; then \
+ name="`cd $(DLCACHE); echo $$1-*.egg`"; \
+ echo "Fetching '$$name' from cache."; \
+ else \
+ [ -z "$(NONET)" ] || ( echo "Missing '$$1'."; exit 2 ); \
+ $(EASY_INSTALL) -zmaxd $(DLCACHE) $$1; \
+ name="`cd $(DLCACHE); echo $$1-*.egg`"; \
+ if [ -d $(DLCACHE)/$$name ]; then \
+ cd $(DLCACHE)/$$name; \
+ zip -r ../$$name.zip .; \
+ cd ..; \
+ rm -r $$name; \
+ mv $$name.zip $$name; \
+ fi; \
+ fi; \
+ }; \
+ _dlegg
+endef
+
+# Usage:
+# @$(install) <package>
+#
+# Downloads egg to '$(DLCACHE)/<package>-*.egg' and installs it unless a file
+# with that name already exists.
+define install
+ _install() { \
+ echo "$(PIP) install --download-cache="$(DLCACHE)/pip" $(PIP_OPTS) $$1"; \
+ $(PIP) install --download-cache="$(DLCACHE)/pip" $(PIP_OPTS) "$$1"; \
+ cd $(DLCACHE)/pip; \
+ for file in *.tar.gz; do \
+ name="$${file##*%2F}"; \
+ if [ "$$name" != "$$file" -a ! -r "$$name" ]; then \
+ ln -s $$file $$name || exit 1; \
+ fi; \
+ done \
+ }; \
+ _install
+endef
+
###########################################################################
python-unpack: $(PYTHON_DIR)/Python-$(PYTHON_VERSION)/README
$(PIP):
@$(dlegg) pip
$(EASY_INSTALL) $(DLCACHE)/pip-*.egg
+.PHONY: pip
pybase: python setuptools pip
.PHONY: pybase
@$(install) zc.buildout
.gitignore::
- @$(gitignore) /python/
+ @$(gitignore) "*.pyc"
+ @$(gitignore) "/python/"
.env::
@$(env) PATH $(BASEDIR)/$(PYTHON_DIR)/bin
-clean:: python-clean
+clean::
+ rm -rf "$(PYTHON_DIR)"
setup:: pybase
+
+PIP_CACHE_FILES := $(shell cd $(DLCACHE)/pip; ls *.tar.gz | grep -vF '%2F')
+
+init-nonet: PIP_OPTS = --no-index $(patsubst %,--find-link=file://$(BASEDIR)/$(DLCACHE)/pip/%,$(PIP_CACHE_FILES))
+
+fullhelp::
+ @echo " python-rebuild"
+ @echo " recompile python from source. This may be needed after"
+ @echo " upgrading the host distribution."
+ @echo
+
+varhelp::
+ @echo " PYTHON_VERSION ($(PYTHON_VERSION))"
+ @echo " Python version to download and compile."
+ @echo
+ @echo " PYTHON_URL ($(PYTHON_URL))"
+ @echo " URL to download python from. The default value is automatically"
+ @echo " generated from PYTHON_VERSION."
+ @echo
+ @echo " SETUPTOOLS_URL ($(SETUPTOOLS_URL))"
+ @echo " URL to download 'ez_setup.py' from."
+ @echo
+ @echo " PYTHON_DIR ($(PYTHON_DIR))"
+ @echo " Name of subdirectory for the local python installation."
+ @echo