Annotation of /trunk/include/python.sminc
Parent Directory | Revision Log
Revision 33632 -
(hide annotations)
(download)
Thu Aug 10 15:19:59 2023 UTC (9 months ago) by niro
File size: 5158 byte(s)
Thu Aug 10 15:19:59 2023 UTC (9 months ago) by niro
File size: 5158 byte(s)
-added missing python_multilib_src_prepare() function
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 | niro | 33629 | >= dev-lang/python-3" |
10 | niro | 29773 | 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 | 33630 | pylib=$(${MAGE_PYTHON_EXEC} -c 'import sysconfig; print (sysconfig.get_path("platlib"))') |
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 | 33630 | pyinc=$(${MAGE_PYTHON_EXEC} -c 'import sysconfig; print (sysconfig.get_path("platinclude"))') |
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 | 33632 | python_multilib_src_prepare() |
68 | { | ||
69 | munpack ${SRCFILE} || die | ||
70 | } | ||
71 | |||
72 | niro | 8645 | python_docompile() |
73 | niro | 2 | { |
74 | niro | 33631 | if [[ -e pyproject.toml ]] |
75 | niro | 6882 | then |
76 | niro | 33631 | TMPDIR=${BUILDDIR} ${MAGE_PYTHON_EXEC} \ |
77 | -m pip wheel --wheel-dir dist --no-build-isolation --no-deps --disable-pip-version-check \ | ||
78 | --no-cache-dir --use-pep517 --no-clean ${PWD} || die | ||
79 | elif [[ -e setup.py ]] | ||
80 | then | ||
81 | niro | 29773 | ${MAGE_PYTHON_EXEC} setup.py build $@ || die |
82 | niro | 8121 | elif [[ -e waf ]] |
83 | then | ||
84 | niro | 29773 | ${MAGE_PYTHON_EXEC} waf configure --prefix=/usr --libdir=/usr/$(mlibdir) $@ || die |
85 | ${MAGE_PYTHON_EXEC} waf build $@ || die | ||
86 | niro | 33234 | elif [[ -e meson.build ]] |
87 | then | ||
88 | niro | 33281 | # never run multilib builds here, multilib will be enabled by python_multilib_src_compile |
89 | # this honors the logic of other build methods (python, waf, autotools) | ||
90 | MULTILIB_BUILD=false meson_configure -D python=${MAGE_PYTHON_EXEC} || die | ||
91 | MULTILIB_BUILD=false mninja || die | ||
92 | niro | 6882 | elif [[ -e configure ]] |
93 | then | ||
94 | niro | 29819 | if [[ ${MULTILIB_BUILD} = true ]] && [[ ! -z $(typeset -f oldmconfigure) ]] && [[ ! -z $(typeset -f oldmmake) ]] |
95 | then | ||
96 | oldmconfigure $@ || die | ||
97 | oldmmake || die | ||
98 | else | ||
99 | mconfigure $@ || die | ||
100 | mmake || die | ||
101 | fi | ||
102 | niro | 9471 | elif [[ -e install.py ]] |
103 | niro | 9472 | then |
104 | niro | 9471 | echo "install.py found - nothing to compile here." |
105 | niro | 6882 | else |
106 | mmake || die | ||
107 | fi | ||
108 | niro | 2 | } |
109 | |||
110 | niro | 8645 | python_doinstall() |
111 | niro | 2 | { |
112 | niro | 33631 | if [[ -e pyproject.toml ]] |
113 | niro | 6882 | then |
114 | niro | 33631 | TMPDIR=${BUILDDIR} ${MAGE_PYTHON_EXEC} \ |
115 | -m pip install --root ${BINDIR} --no-index --no-deps --disable-pip-version-check \ | ||
116 | --no-cache-dir --use-pep517 --ignore-installed --no-warn-script-location $(find dist -name \*.whl) || die | ||
117 | elif [[ -e setup.py ]] | ||
118 | then | ||
119 | niro | 29773 | ${MAGE_PYTHON_EXEC} setup.py install --no-compile --root ${BINDIR} $@ || die |
120 | niro | 8121 | elif [[ -e waf ]] |
121 | then | ||
122 | niro | 29773 | ${MAGE_PYTHON_EXEC} waf install --destdir=${BINDIR} $@ || die |
123 | niro | 33234 | elif [[ -e meson.build ]] |
124 | then | ||
125 | niro | 33281 | # never run multilib builds here, multilib will be enabled by python_multilib_src_compile |
126 | # this honors the logic of other build methods (python, waf, autotools) | ||
127 | MULTILIB=false DESTDIR=${BINDIR} mninja install || die | ||
128 | niro | 9471 | elif [[ -e install.py ]] |
129 | niro | 9472 | then |
130 | niro | 29773 | ${MAGE_PYTHON_EXEC} install.py --prefix=/usr --files-only --destdir=${BINDIR} $@ || die |
131 | niro | 6882 | else |
132 | niro | 29819 | if [[ ${MULTILIB_BUILD} = true ]] && [[ ! -z $(typeset -f oldmconfigure) ]] && [[ ! -z $(typeset -f oldmmake) ]] |
133 | then | ||
134 | oldmmake DESTDIR=${BINDIR} install || die | ||
135 | else | ||
136 | mmake DESTDIR=${BINDIR} install || die | ||
137 | fi | ||
138 | niro | 6882 | fi |
139 | niro | 8645 | } |
140 | niro | 6882 | |
141 | niro | 8645 | python_src_compile() |
142 | { | ||
143 | cd ${SRCDIR} | ||
144 | niro | 29782 | python_docompile $@ || die |
145 | niro | 8645 | } |
146 | |||
147 | niro | 21029 | python_multilib_src_compile() |
148 | { | ||
149 | local abi | ||
150 | local saved_SRCDIR="${SRCDIR}" | ||
151 | |||
152 | for abi in ${MULTILIB_ABIS} | ||
153 | do | ||
154 | SRCDIR="${saved_SRCDIR}-${abi}/${SRCSUBDIR}" | ||
155 | cd ${SRCDIR} | ||
156 | niro | 29782 | abi-${abi} python_docompile $@ || die |
157 | niro | 21029 | done |
158 | SRCDIR="${saved_SRCDIR}" | ||
159 | } | ||
160 | |||
161 | niro | 21031 | python_src_check() |
162 | { | ||
163 | return 0 | ||
164 | } | ||
165 | |||
166 | niro | 8645 | python_src_install() |
167 | { | ||
168 | cd ${SRCDIR} | ||
169 | niro | 29782 | python_doinstall $@ || die |
170 | niro | 8645 | |
171 | niro | 2 | local i |
172 | for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \ | ||
173 | niro | 33631 | FAQ LICENSE NEWS README* TODO PKG-INFO |
174 | niro | 2 | do |
175 | if [ -f ${SRCDIR}/${i} ] | ||
176 | then | ||
177 | minstalldocs ${i} || die | ||
178 | fi | ||
179 | done | ||
180 | } | ||
181 | |||
182 | niro | 21029 | python_multilib_src_install() |
183 | { | ||
184 | local abi | ||
185 | local saved_SRCDIR="${SRCDIR}" | ||
186 | |||
187 | for abi in ${MULTILIB_ABIS} | ||
188 | do | ||
189 | SRCDIR="${saved_SRCDIR}-${abi}/${SRCSUBDIR}" | ||
190 | cd ${SRCDIR} | ||
191 | niro | 29782 | abi-${abi} python_doinstall $@ || die |
192 | niro | 21029 | |
193 | local i | ||
194 | for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \ | ||
195 | niro | 33631 | FAQ LICENSE NEWS README* TODO PKG-INFO |
196 | niro | 21029 | do |
197 | if [ -f ${SRCDIR}/${i} ] | ||
198 | then | ||
199 | oldminstalldocs ${i} || die | ||
200 | fi | ||
201 | done | ||
202 | done | ||
203 | SRCDIR="${saved_SRCDIR}" | ||
204 | } | ||
205 | |||
206 | niro | 21031 | export_inherits python src_prepare src_check |
207 | niro | 21029 | if [[ ${MULTILIB_BUILD} = true ]] |
208 | then | ||
209 | export_inherits python_multilib src_compile src_install | ||
210 | else | ||
211 | export_inherits python src_compile src_install | ||
212 | fi |