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