1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
|
#!/usr/bin/make -f
# -*- makefile -*-
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
# This has to be exported to make some magic below work.
export DH_OPTIONS
# setuptools doesn't handle translated messages
export LC_ALL=C
#PYVERS := 2.3 2.5 $(shell pyversions -vr debian/control)
XPYVERS := 2.7
PYVERS := 2.7
PYVERS3 := 3.4
PYVER := $(shell python -c 'import sys; print sys.version[:3]')
SETUPTOOLSVER=1.3.2
export XPYVERS
include /usr/share/python3/python.mk
pname = $(if $(findstring 3.,$(2)),$(subst python-,python3-,$(1)),$(1))
p_pkgr = python-pkg-resources
p_setp = python-setuptools
p_doc = python-setuptools-doc
d_pkgr = debian/$(p_pkgr)
d_setp = debian/$(p_setp)
d_doc = debian/$(p_doc)
build: build-stamp
build-arch: build-stamp
build-indep: build-stamp build-doc-stamp
build-stamp: $(PYVERS:%=build-python%) $(PYVERS3:%=build-python%) build-doc-stamp
touch $@
build-doc-stamp:
PYTHONPATH=$(CURDIR) \
sh -c 'cd docs && sphinx-build -b html -d build/doctrees . build/html'
touch $@
build-python%: pre-build-stamp
python$* setup.py build
touch $@
pre-build-stamp:
[ -d setuptools.egg-info.saved ] || cp -a setuptools.egg-info setuptools.egg-info.saved
touch $@
clean:
dh_testdir
dh_testroot
rm -f build-python* build-doc-stamp build-stamp
rm -rf build dist
-find -name __pycache__ | xargs rm -rf
-find -name '*.py[co]' | xargs rm -f
rm -rf docs/build
rm -f template* \(dev\).py
if [ -d setuptools.egg-info.saved ]; then \
rm -rf setuptools.egg-info; \
mv setuptools.egg-info.saved setuptools.egg-info; \
fi
dh_clean
install: build install-prereq $(PYVERS:%=install-python%) $(PYVERS3:%=install-python%) install-wheel
find debian -name 'setuptools_boot.py*' | xargs -r rm -f
find debian -name '*.py[co]' | xargs -r rm -f
pkgs=$$(dh_listpackages); cd debian && find $$pkgs -mindepth 1 -type d -empty -print -delete
rm -f debian/python-*/usr/bin/easy_install-3*
rm -f debian/python3-*/usr/bin/easy_install-2*
mv debian/python3-setuptools/usr/bin/easy_install \
debian/python3-setuptools/usr/bin/easy_install3
: # Replace all '#!' calls to python with $(PYTHON)
: # and make them executable
for i in \
`find debian/python-*/usr/lib debian/python-*/usr/bin -type f`; \
do \
case "$$i" in *-[0-9].[0-9]) continue; esac; \
sed '1s,#!.*python[^ ]*\(.*\),#! /usr/bin/python\1,' \
$$i > $$i.temp; \
if cmp --quiet $$i $$i.temp; then \
rm -f $$i.temp; \
else \
mv -f $$i.temp $$i; \
chmod 755 $$i; \
echo "fixed interpreter: $$i"; \
fi; \
done
for i in \
`find debian/python3-*/usr/lib debian/python3-*/usr/bin -type f`; \
do \
case "$$i" in *-[0-9].[0-9]) continue; esac; \
sed '1s,#!.*python[^ ]*\(.*\),#! /usr/bin/python3\1,' \
$$i > $$i.temp; \
if cmp --quiet $$i $$i.temp; then \
rm -f $$i.temp; \
else \
mv -f $$i.temp $$i; \
chmod 755 $$i; \
echo "fixed interpreter: $$i"; \
fi; \
done
install-prereq:
dh_testdir
dh_testroot
dh_clean -k
install-python%:
dh_installdirs -A usr/bin /$(call py_libdir,$*)
python$* setup.py install \
--root=$(CURDIR)/$(call pname,$(d_setp),$*) --install-layout=deb
mv $(call pname,$(d_setp),$*)/$(call py_libdir,$*)/pkg_resources.py \
$(call pname,$(d_pkgr),$*)/$(call py_libdir,$*)/
# mv $(call pname,$(d_setp),$*)/$(call py_libdir,$*)/setuptools-$(SETUPTOOLSVER).egg-info \
# $(call pname,$(d_setp),$*)/$(call py_libdir,$*)/setuptools.egg-info
echo setuptools-$(SETUPTOOLSVER).egg-info \
> $(call pname,$(d_setp),$*)/$(call py_libdir,$*)/setuptools.pth
install-wheel:
mkdir -p debian/python-setuptools-whl/usr/share/python-wheels
python3 setup.py bdist_wheel --universal \
-d debian/python-setuptools-whl/usr/share/python-wheels
dh_installdirs -ppython-setuptools-whl usr/share
binary-arch:
binary-indep: build install
dh_testdir
dh_testroot
dh_installchangelogs -p$(p_setp) CHANGES.txt
dh_installchangelogs -N$(p_setp)
dh_installdocs -N$(p_setp) -N$(p_pkgr)
dh_installdocs -p$(p_pkgr) docs/pkg_resources.txt
dh_installdocs -p$(p_setp) -Xpkg_resources docs/*.txt
mkdir -p $(d_doc)/usr/share/doc/$(p_doc)
cp -pr docs/build/html $(d_doc)/usr/share/doc/$(p_doc)/
dh_sphinxdoc -p$(p_doc)
dh_link -p$(p_doc) \
/usr/share/doc/$(p_doc)/html /usr/share/doc/$(p_setp)/html \
/usr/share/doc/$(p_doc)/html /usr/share/doc/$(p_setp3)/html
dh_compress -i
dh_fixperms -i
for v in $(filter-out 3.%, $(PYVERS)); do \
sed -i "s/python2\../python$$v/g" $(d_setp)/usr/bin/easy_install-$$v; \
done
# for v in $(filter-out 2.%, $(PYVERS)); do \
# sed -i "s/python3\../python$$v/g" debian/$(call pname,$(p_setp),3.1)/usr/bin/easy_install-$$v; \
# done
dh_python2 -p$(p_pkgr) -p$(p_setp) #-p$(p_dist)
cat $(d_setp).substvars
( \
echo 'python:Versions=2.7'; \
echo 'python:Provides=python2.7-setuptools'; \
echo 'python:Depends=python:any (>= 2.7), python:any (<< 2.8)'; \
) > $(d_setp).substvars
cp $(d_setp).substvars $(d_pkgr).substvars
dh_python3 -p$(call pname,$(p_pkgr),3.3) -p$(call pname,$(p_setp),3.3) # -p$(call pname,$(p_dist),3.3)
cat debian/$(call pname,$(p_setp),3.2).substvars
cat debian/$(call pname,$(p_pkgr),3.2).substvars
## cp $(d_setp).substvars $(d_dist).substvars
( \
echo 'python3:Versions=3.3'; \
echo 'python3:Provides=python3.3-setuptools'; \
echo 'python3:Depends=python3:any (>= 3.3), python3:any (<< 3.5)'; \
) > $(call pname,$(d_setp),3.3).substvars
cp $(call pname,$(d_setp),3.3).substvars $(call pname,$(d_pkgr),3.3).substvars
dh_installdeb -i
dh_gencontrol -i
dh_md5sums -i
dh_builddeb -i
binary: binary-arch binary-indep
.PHONY: build clean binary-indep binary-arch binary install
|