# -*- makefile -*- 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 = $(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) # # Downloads egg to '$(DLCACHE)/-*.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) # # Downloads egg to '$(DLCACHE)/-*.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 $(PYTHON_DIR)/Python-$(PYTHON_VERSION)/README: 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 python-build: $(PYTHON) $(PYTHON): cd $(PYTHON_DIR)/Python-$(PYTHON_VERSION) && ./configure --prefix=$(BASEDIR)/$(PYTHON_DIR) cd $(PYTHON_DIR)/Python-$(PYTHON_VERSION) && make cd $(PYTHON_DIR)/Python-$(PYTHON_VERSION) && make install .PHONY: python-build python-rebuild: python-clean python-build .PHONY: python-rebuild python-clean: cd $(PYTHON_DIR)/Python-$(PYTHON_VERSION) && make clean rm -f $(PYTHON) .PHONY: python-clean python: python-unpack python-build .PHONY: python 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 pip: $(PIP) $(PIP): @$(dlegg) pip $(EASY_INSTALL) $(DLCACHE)/pip-*.egg .PHONY: pip pybase: python setuptools pip .PHONY: pybase ########################################################################### debdepends:: aptitude install build-essential zlibc eggs:: @$(install) zc.buildout .gitignore:: @$(gitignore) "*.pyc" @$(gitignore) "/python/" .env:: @$(env) PATH $(BASEDIR)/$(PYTHON_DIR)/bin 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