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