3 PYTHON_VERSION ?= 2.4.6
4 PYTHON_URL ?= http://www.python.org/ftp/python/$(PYTHON_VERSION)/Python-$(PYTHON_VERSION).tgz
5 SETUPTOOLS_URL ?= http://peak.telecommunity.com/dist/ez_setup.py
8 ###########################################################################
10 PYTHON = $(BASEDIR)/$(PYTHON_DIR)/bin/python
11 EASY_INSTALL = $(BASEDIR)/$(PYTHON_DIR)/bin/easy_install
12 PIP = $(BASEDIR)/$(PYTHON_DIR)/bin/pip
13 PASTER = $(BASEDIR)/$(PYTHON_DIR)/bin/paster
18 # Downloads egg to '$(DLCACHE)/<package>-*.egg' unless a file with that name
21 # THIS DOES NOT WORK WITH ALL PACKAGES !!! USE WITH CARE
24 if [ -r $(DLCACHE)/$$1-*.egg ]; then \
25 name="`cd $(DLCACHE); echo $$1-*.egg`"; \
26 echo "Fetching '$$name' from cache."; \
28 [ -z "$(NONET)" ] || ( echo "Missing '$$1'."; exit 2 ); \
29 $(EASY_INSTALL) -zmaxd $(DLCACHE) $$1; \
30 name="`cd $(DLCACHE); echo $$1-*.egg`"; \
31 if [ -d $(DLCACHE)/$$name ]; then \
32 cd $(DLCACHE)/$$name; \
33 zip -r ../$$name.zip .; \
36 mv $$name.zip $$name; \
44 # @$(install) <package>
46 # Downloads egg to '$(DLCACHE)/<package>-*.egg' and installs it unless a file
47 # with that name already exists.
50 echo "$(PIP) install --download-cache="$(DLCACHE)/pip" $(PIP_OPTS) $$1"; \
51 $(PIP) install --download-cache="$(DLCACHE)/pip" $(PIP_OPTS) "$$1"; \
53 for file in *.tar.gz; do \
54 name="$${file##*%2F}"; \
55 if [ "$$name" != "$$file" -a ! -r "$$name" ]; then \
56 ln -s $$file $$name || exit 1; \
63 ###########################################################################
65 python-unpack: $(PYTHON_DIR)/Python-$(PYTHON_VERSION)/README
66 $(PYTHON_DIR)/Python-$(PYTHON_VERSION)/README:
67 mkdir -p $(PYTHON_DIR)
68 @$(httpget) $(PYTHON_URL) $(PYTHON_DIR)/python.tgz
69 tar -C $(PYTHON_DIR) -xzf $(PYTHON_DIR)/python.tgz
70 rm -f $(PYTHON_DIR)/python.tgz
73 python-build: $(PYTHON)
75 cd $(PYTHON_DIR)/Python-$(PYTHON_VERSION) && ./configure --prefix=$(BASEDIR)/$(PYTHON_DIR)
76 cd $(PYTHON_DIR)/Python-$(PYTHON_VERSION) && make
77 cd $(PYTHON_DIR)/Python-$(PYTHON_VERSION) && make install
80 python-rebuild: python-clean python-build
81 .PHONY: python-rebuild
84 cd $(PYTHON_DIR)/Python-$(PYTHON_VERSION) && make clean
88 python: python-unpack python-build
91 setuptools: $(BASEDIR)/$(PYTHON_DIR)/bin/easy_install
92 $(BASEDIR)/$(PYTHON_DIR)/bin/easy_install:
93 mkdir -p $(PYTHON_DIR)/Extensions
94 @$(httpget) $(SETUPTOOLS_URL) $(PYTHON_DIR)/Extensions/ez_setup.py
96 if [ -r $(DLCACHE)/setuptools-*.egg ]; then \
97 name="`cd $(DLCACHE); echo setuptools-*.egg`"; \
98 echo "Fetching '$$name' from cache."; \
99 cp "$(DLCACHE)/$$name" $(PYTHON_DIR)/Extensions; \
101 echo "Downloading setuptools."; \
102 ( cd $(PYTHON_DIR)/Extensions && $(PYTHON) -c 'import ez_setup; ez_setup.download_setuptools()' ); \
103 cp $(PYTHON_DIR)/Extensions/setuptools-*.egg $(DLCACHE); \
106 cd $(PYTHON_DIR)/Extensions && $(PYTHON) ez_setup.py
112 $(EASY_INSTALL) $(DLCACHE)/pip-*.egg
115 pybase: python setuptools pip
118 ###########################################################################
121 aptitude install build-essential zlibc
124 @$(install) zc.buildout
127 @$(gitignore) "*.pyc"
128 @$(gitignore) "/python/"
131 @$(env) PATH $(BASEDIR)/$(PYTHON_DIR)/bin
134 rm -rf "$(PYTHON_DIR)"
138 PIP_CACHE_FILES := $(shell cd $(DLCACHE)/pip; ls *.tar.gz | grep -vF '%2F')
140 init-nonet: PIP_OPTS = --no-index $(patsubst %,--find-link=file://$(BASEDIR)/$(DLCACHE)/pip/%,$(PIP_CACHE_FILES))
143 @echo " python-rebuild"
144 @echo " recompile python from source. This may be needed after"
145 @echo " upgrading the host distribution."
149 @echo " PYTHON_VERSION ($(PYTHON_VERSION))"
150 @echo " Python version to download and compile."
152 @echo " PYTHON_URL ($(PYTHON_URL))"
153 @echo " URL to download python from. The default value is automatically"
154 @echo " generated from PYTHON_VERSION."
156 @echo " SETUPTOOLS_URL ($(SETUPTOOLS_URL))"
157 @echo " URL to download 'ez_setup.py' from."
159 @echo " PYTHON_DIR ($(PYTHON_DIR))"
160 @echo " Name of subdirectory for the local python installation."