caching and offline initialization (init-nonet)
[zope-bootstrap.git] / Makefile.pybase
index af6dc8a..b9db381 100644 (file)
@@ -6,18 +6,19 @@ 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
 
 ###########################################################################
 
 python-unpack: $(PYTHON_DIR)/Python-$(PYTHON_VERSION)/README
 $(PYTHON_DIR)/Python-$(PYTHON_VERSION)/README:
-       mkdir $(PYTHON_DIR)
-       wget "$(PYTHON_URL)" -O $(PYTHON_DIR)/python.tgz
+       mkdir -p $(PYTHON_DIR)
+       @$(httpget) $(PYTHON_URL) $(PYTHON_DIR)/python.tgz
        tar -C $(PYTHON_DIR) -xzf $(PYTHON_DIR)/python.tgz
        rm -f $(PYTHON_DIR)/python.tgz
 .PHONY: python-unpack
@@ -40,14 +41,30 @@ python-clean:
 python: python-unpack python-build
 .PHONY: python
 
-setuptools: $(EASY_INSTALL)
-$(EASY_INSTALL):
-       mkdir $(PYTHON_DIR)/Extensions
-       wget $(SETUPTOOLS_URL) -O $(PYTHON_DIR)/Extensions/ez_setup.py
+setuptools: $(BASEDIR)/$(PYTHON_DIR)/bin/easy_install
+$(BASEDIR)/$(PYTHON_DIR)/bin/easy_install:
+       mkdir -p $(PYTHON_DIR)/Extensions
+       @$(httpget) $(SETUPTOOLS_URL) $(PYTHON_DIR)/Extensions/ez_setup.py
+       @(                                                                                                              \
+           if [ -r $(DLCACHE)/setuptools-*.egg ]; then                                                                 \
+               name="`cd $(DLCACHE); echo setuptools-*.egg`";                                                          \
+               echo "Fetching '$$name' from cache.";                                                                   \
+               cp "$(DLCACHE)/$$name" $(PYTHON_DIR)/Extensions;                                                        \
+           else                                                                                                        \
+               echo "Downloading setuptools.";                                                                         \
+               ( cd $(PYTHON_DIR)/Extensions && $(PYTHON) -c 'import ez_setup; ez_setup.download_setuptools()' );      \
+               cp $(PYTHON_DIR)/Extensions/setuptools-*.egg $(DLCACHE);                                                \
+           fi;                                                                                                         \
+       )
        cd $(PYTHON_DIR)/Extensions && $(PYTHON) ez_setup.py
 .PHONY: setuptools
 
-pybase: python setuptools
+pip: $(PIP)
+$(PIP):
+       @$(dlegg) pip
+       $(EASY_INSTALL) $(DLCACHE)/pip-*.egg
+
+pybase: python setuptools pip
 .PHONY: pybase
 
 ###########################################################################
@@ -56,7 +73,7 @@ debdepends::
        aptitude install build-essential zlibc
 
 eggs::
-       $(EASY_INSTALL) zc.buildout
+       @$(install) zc.buildout
 
 .gitignore::
        @$(gitignore) /python/