Magellan Linux

Contents of /smage/trunk/include/python.sminc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5863 - (show annotations) (download)
Fri Oct 17 07:59:03 2014 UTC (10 years ago) by niro
File size: 3327 byte(s)
-sync with upstream
1 # $Id$
2
3 SDEPEND="${SDEPEND}
4 >= dev-lang/python-2.7"
5
6 # get the major.minor current installed python version
7 # -> ex 2.4
8 mget-python-version()
9 {
10 local pyver
11 # pyver="$(python -V 2>&1 | cut -d' ' -f2 | cut -d. -f1-2)"
12 pyver=$(python -c "import sys ; print sys.version[:3]")
13 [[ -z ${pyver} ]] && return 1
14 echo "${pyver}"
15 return 0
16 }
17
18 mget-python-libdir()
19 {
20 local pylib
21 pylib=$(python -c 'from distutils import sysconfig; print sysconfig.get_python_lib()')
22 [[ -z ${pylib} ]] && return 1
23 echo "${pylib}"
24 return 0
25 }
26
27 mget-python-includedir()
28 {
29 local pyinc
30 pyinc=$(python -c 'from distutils import sysconfig; print sysconfig.get_python_inc()')
31 [[ -z ${pyinc} ]] && return 1
32 echo "${pyinc}"
33 return 0
34 }
35
36 # fallback functions to support old smage scripts, dropped in near future
37 get_python_version()
38 {
39 echo -e "${COLYELLOW}Warning: get_python_version() is depcrecated, please use mget-python-version() instead${COLDEFAULT}" >&2
40 mget-python-version
41 }
42 get_python_libdir()
43 {
44 echo -e "${COLYELLOW}Warning: get_python_libdir() is depcrecated, please use mget-python-libdir() instead${COLDEFAULT}" >&2
45 mget-python-libdir
46 }
47 get_python_includedir()
48 {
49 echo -e "${COLYELLOW}Warning: get_python_includedir() is depcrecated, please use mget-python-includedir() instead${COLDEFAULT}" >&2
50 mget-python-includedir
51 }
52
53 python_src_prepare()
54 {
55 munpack ${SRCFILE} || die
56 }
57
58 python_docompile()
59 {
60 if [[ -e setup.py ]]
61 then
62 python setup.py build $@ || die
63 elif [[ -e waf ]]
64 then
65 python waf configure --prefix=/usr --libdir=/usr/$(mlibdir) $@ || die
66 python waf build $@ || die
67 elif [[ -e configure ]]
68 then
69 mconfigure $@ || die
70 mmake || die
71 elif [[ -e install.py ]]
72 then
73 echo "install.py found - nothing to compile here."
74 else
75 mmake || die
76 fi
77 }
78
79 python_doinstall()
80 {
81 if [[ -e setup.py ]]
82 then
83 python setup.py install --no-compile --root ${BINDIR} $@ || die
84 elif [[ -e waf ]]
85 then
86 python waf install --destdir=${BINDIR} $@ || die
87 elif [[ -e install.py ]]
88 then
89 python install.py --prefix=/usr --files-only --destdir=${BINDIR} $@ || die
90 else
91 mmake DESTDIR=${BINDIR} install || die
92 fi
93 }
94
95 python_src_compile()
96 {
97 cd ${SRCDIR}
98 python_docompile || die
99 }
100
101 python_multilib_src_compile()
102 {
103 local abi
104 local saved_SRCDIR="${SRCDIR}"
105
106 for abi in ${MULTILIB_ABIS}
107 do
108 SRCDIR="${saved_SRCDIR}-${abi}/${SRCSUBDIR}"
109 cd ${SRCDIR}
110 abi-${abi} python_docompile || die
111 done
112 SRCDIR="${saved_SRCDIR}"
113 }
114
115 python_src_check()
116 {
117 return 0
118 }
119
120 python_src_install()
121 {
122 cd ${SRCDIR}
123 python_doinstall || die
124
125 local i
126 for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \
127 FAQ LICENSE NEWS README TODO
128 do
129 if [ -f ${SRCDIR}/${i} ]
130 then
131 minstalldocs ${i} || die
132 fi
133 done
134 }
135
136 python_multilib_src_install()
137 {
138 local abi
139 local saved_SRCDIR="${SRCDIR}"
140
141 for abi in ${MULTILIB_ABIS}
142 do
143 SRCDIR="${saved_SRCDIR}-${abi}/${SRCSUBDIR}"
144 cd ${SRCDIR}
145 abi-${abi} python_doinstall || die
146
147 local i
148 for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \
149 FAQ LICENSE NEWS README TODO
150 do
151 if [ -f ${SRCDIR}/${i} ]
152 then
153 oldminstalldocs ${i} || die
154 fi
155 done
156 done
157 SRCDIR="${saved_SRCDIR}"
158 }
159
160 export_inherits python src_prepare src_check
161 if [[ ${MULTILIB_BUILD} = true ]]
162 then
163 export_inherits python_multilib src_compile src_install
164 else
165 export_inherits python src_compile src_install
166 fi