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
7 ###########################################################################
11 PYTHON = $(BASEDIR)/$(PYTHON_DIR)/bin/python
12 EASY_INSTALL = $(BASEDIR)/$(PYTHON_DIR)/bin/easy_install
13 PIP = $(BASEDIR)/$(PYTHON_DIR)/bin/pip
14 PASTER = $(BASEDIR)/$(PYTHON_DIR)/bin/paster
19 # Downloads egg to '$(DLCACHE)/<package>-*.egg' unless a file with that name
22 # THIS DOES NOT WORK WITH ALL PACKAGES !!! USE WITH CARE
25 if [ -r $(DLCACHE)/$$1-*.egg ]; then \
26 name="`cd $(DLCACHE); echo $$1-*.egg`"; \
27 echo "Fetching '$$name' from cache."; \
29 [ -z "$(NONET)" ] || ( echo "Missing '$$1'."; exit 2 ); \
30 $(EASY_INSTALL) -zmaxd $(DLCACHE) $$1; \
31 name="`cd $(DLCACHE); echo $$1-*.egg`"; \
32 if [ -d $(DLCACHE)/$$name ]; then \
33 cd $(DLCACHE)/$$name; \
34 zip -r ../$$name.zip .; \
37 mv $$name.zip $$name; \
45 # @$(install) <package>
47 # Downloads egg to '$(DLCACHE)/<package>-*.egg' and installs it unless a file
48 # with that name already exists.
51 echo $(PIP_CACHE_FILES); \
52 echo "$(PIP) install --download-cache="$(DLCACHE)/pip" $(PIP_OPTS) $$1"; \
53 $(PIP) install --download-cache="$(DLCACHE)/pip" $(PIP_OPTS) "$$1"; \
55 for file in *.tar.gz; do \
56 name="$${file##*%2F}"; \
57 if [ "$$name" != "$$file" -a ! -r "$$name" ]; then \
58 ln -s $$file $$name || exit 1; \
65 ###########################################################################
67 python-unpack: $(PYTHON_DIR)/Python-$(PYTHON_VERSION)/README
68 $(PYTHON_DIR)/Python-$(PYTHON_VERSION)/README:
69 mkdir -p $(PYTHON_DIR)
70 @$(httpget) $(PYTHON_URL) $(PYTHON_DIR)/python.tgz
71 tar -C $(PYTHON_DIR) -xzf $(PYTHON_DIR)/python.tgz
72 rm -f $(PYTHON_DIR)/python.tgz
75 python-build: $(PYTHON)
77 cd $(PYTHON_DIR)/Python-$(PYTHON_VERSION) && ./configure --prefix=$(BASEDIR)/$(PYTHON_DIR)
78 cd $(PYTHON_DIR)/Python-$(PYTHON_VERSION) && make
79 cd $(PYTHON_DIR)/Python-$(PYTHON_VERSION) && make install
82 python-rebuild: python-clean python-build
83 .PHONY: python-rebuild
86 cd $(PYTHON_DIR)/Python-$(PYTHON_VERSION) && make clean
90 python: python-unpack python-build
93 setuptools: $(BASEDIR)/$(PYTHON_DIR)/bin/easy_install
94 $(BASEDIR)/$(PYTHON_DIR)/bin/easy_install:
95 mkdir -p $(PYTHON_DIR)/Extensions
96 @$(httpget) $(SETUPTOOLS_URL) $(PYTHON_DIR)/Extensions/ez_setup.py
98 if [ -r $(DLCACHE)/setuptools-*.egg ]; then \
99 name="`cd $(DLCACHE); echo setuptools-*.egg`"; \
100 echo "Fetching '$$name' from cache."; \
101 cp "$(DLCACHE)/$$name" $(PYTHON_DIR)/Extensions; \
103 echo "Downloading setuptools."; \
104 ( cd $(PYTHON_DIR)/Extensions && $(PYTHON) -c 'import ez_setup; ez_setup.download_setuptools()' ); \
105 cp $(PYTHON_DIR)/Extensions/setuptools-*.egg $(DLCACHE); \
108 cd $(PYTHON_DIR)/Extensions && $(PYTHON) ez_setup.py
114 $(EASY_INSTALL) $(DLCACHE)/pip-*.egg
117 pybase: python setuptools pip
120 ###########################################################################
123 aptitude install build-essential zlibc
126 @$(install) zc.buildout
129 @$(gitignore) /python/
132 @$(env) PATH $(BASEDIR)/$(PYTHON_DIR)/bin
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."