Annotation of /smage/trunk/include/python.sminc
Parent Directory
|
Revision Log
Revision 17219 -
(hide annotations)
(download)
Wed Nov 22 09:33:50 2023 UTC (6 months, 3 weeks ago) by niro
File size: 5444 byte(s)
Wed Nov 22 09:33:50 2023 UTC (6 months, 3 weeks ago) by niro
File size: 5444 byte(s)
-do no print root warning
1 | niro | 3578 | # $Id$ |
2 | niro | 1661 | |
3 | niro | 11533 | # simulate the old behavior |
4 | if [[ -z ${MAGE_PYTHON_EXEC} ]] | ||
5 | then | ||
6 | MAGE_PYTHON_EXEC="python" | ||
7 | niro | 5216 | |
8 | niro | 11533 | SDEPEND="${SDEPEND} |
9 | niro | 16196 | >= dev-lang/python-3" |
10 | niro | 11533 | fi |
11 | |||
12 | niro | 13778 | # call meson include in the smage2, to prevent unnecessary dependencies |
13 | #sminclude meson | ||
14 | |||
15 | niro | 1661 | # get the major.minor current installed python version |
16 | # -> ex 2.4 | ||
17 | niro | 5863 | mget-python-version() |
18 | niro | 1661 | { |
19 | niro | 5216 | local pyver |
20 | niro | 11533 | # pyver="$(${MAGE_PYTHON_EXEC} -V 2>&1 | cut -d' ' -f2 | cut -d. -f1-2)" |
21 | pyver=$(${MAGE_PYTHON_EXEC} -c "import sys ; print (sys.version[:3])") | ||
22 | niro | 5216 | [[ -z ${pyver} ]] && return 1 |
23 | echo "${pyver}" | ||
24 | niro | 1661 | return 0 |
25 | } | ||
26 | niro | 1664 | |
27 | niro | 16196 | mget-python-exec() |
28 | { | ||
29 | echo "${MAGE_PYTHON_EXEC}" | ||
30 | } | ||
31 | |||
32 | niro | 5863 | mget-python-libdir() |
33 | niro | 1664 | { |
34 | local pylib | ||
35 | niro | 16196 | #pylib=$(${MAGE_PYTHON_EXEC} -c 'from distutils import sysconfig; print (sysconfig.get_python_lib())') |
36 | pylib=$(${MAGE_PYTHON_EXEC} -c 'import sysconfig; print (sysconfig.get_path("platlib"))') | ||
37 | niro | 5216 | [[ -z ${pylib} ]] && return 1 |
38 | niro | 1664 | echo "${pylib}" |
39 | return 0 | ||
40 | } | ||
41 | |||
42 | niro | 5863 | mget-python-includedir() |
43 | niro | 3578 | { |
44 | local pyinc | ||
45 | niro | 16196 | #pyinc=$(${MAGE_PYTHON_EXEC} -c 'from distutils import sysconfig; print (sysconfig.get_python_inc())') |
46 | pyinc=$(${MAGE_PYTHON_EXEC} -c 'import sysconfig; print (sysconfig.get_path("platinclude"))') | ||
47 | niro | 5216 | [[ -z ${pyinc} ]] && return 1 |
48 | niro | 3578 | echo "${pyinc}" |
49 | return 0 | ||
50 | } | ||
51 | |||
52 | niro | 5863 | # fallback functions to support old smage scripts, dropped in near future |
53 | get_python_version() | ||
54 | { | ||
55 | echo -e "${COLYELLOW}Warning: get_python_version() is depcrecated, please use mget-python-version() instead${COLDEFAULT}" >&2 | ||
56 | mget-python-version | ||
57 | } | ||
58 | get_python_libdir() | ||
59 | { | ||
60 | echo -e "${COLYELLOW}Warning: get_python_libdir() is depcrecated, please use mget-python-libdir() instead${COLDEFAULT}" >&2 | ||
61 | mget-python-libdir | ||
62 | } | ||
63 | get_python_includedir() | ||
64 | { | ||
65 | echo -e "${COLYELLOW}Warning: get_python_includedir() is depcrecated, please use mget-python-includedir() instead${COLDEFAULT}" >&2 | ||
66 | mget-python-includedir | ||
67 | } | ||
68 | |||
69 | niro | 1664 | python_src_prepare() |
70 | { | ||
71 | munpack ${SRCFILE} || die | ||
72 | } | ||
73 | |||
74 | niro | 16196 | python_multilib_src_prepare() |
75 | { | ||
76 | munpack ${SRCFILE} || die | ||
77 | } | ||
78 | |||
79 | niro | 3578 | python_docompile() |
80 | niro | 1664 | { |
81 | niro | 16196 | if [[ -e pyproject.toml ]] |
82 | niro | 1664 | then |
83 | niro | 16196 | TMPDIR=${BUILDDIR} ${MAGE_PYTHON_EXEC} \ |
84 | -m pip wheel --wheel-dir dist --no-build-isolation --no-deps --disable-pip-version-check \ | ||
85 | --no-cache-dir --use-pep517 --no-clean ${PWD} || die | ||
86 | elif [[ -e setup.py ]] | ||
87 | then | ||
88 | niro | 11533 | ${MAGE_PYTHON_EXEC} setup.py build $@ || die |
89 | niro | 3578 | elif [[ -e waf ]] |
90 | then | ||
91 | niro | 11533 | ${MAGE_PYTHON_EXEC} waf configure --prefix=/usr --libdir=/usr/$(mlibdir) $@ || die |
92 | ${MAGE_PYTHON_EXEC} waf build $@ || die | ||
93 | niro | 13778 | elif [[ -e meson.build ]] |
94 | then | ||
95 | # never run multilib builds here, multilib will be enabled by python_multilib_src_compile | ||
96 | # this honors the logic of other build methods (python, waf, autotools) | ||
97 | MULTILIB_BUILD=false meson_configure -D python=${MAGE_PYTHON_EXEC} || die | ||
98 | MULTILIB_BUILD=false mninja || die | ||
99 | niro | 1664 | elif [[ -e configure ]] |
100 | then | ||
101 | niro | 11533 | if [[ ${MULTILIB_BUILD} = true ]] && [[ ! -z $(typeset -f oldmconfigure) ]] && [[ ! -z $(typeset -f oldmmake) ]] |
102 | then | ||
103 | oldmconfigure $@ || die | ||
104 | oldmmake || die | ||
105 | else | ||
106 | mconfigure $@ || die | ||
107 | mmake || die | ||
108 | fi | ||
109 | niro | 3578 | elif [[ -e install.py ]] |
110 | then | ||
111 | echo "install.py found - nothing to compile here." | ||
112 | niro | 1664 | else |
113 | mmake || die | ||
114 | fi | ||
115 | } | ||
116 | |||
117 | niro | 3578 | python_doinstall() |
118 | niro | 1664 | { |
119 | niro | 16196 | if [[ -e pyproject.toml ]] |
120 | niro | 1664 | then |
121 | niro | 16196 | TMPDIR=${BUILDDIR} ${MAGE_PYTHON_EXEC} \ |
122 | niro | 17219 | -m pip install --root ${BINDIR} --no-index --no-deps --disable-pip-version-check --root-user-action ignore \ |
123 | niro | 16196 | --no-cache-dir --use-pep517 --ignore-installed --no-warn-script-location $(find dist -name \*.whl) || die |
124 | elif [[ -e setup.py ]] | ||
125 | then | ||
126 | niro | 11533 | ${MAGE_PYTHON_EXEC} setup.py install --no-compile --root ${BINDIR} $@ || die |
127 | niro | 3578 | elif [[ -e waf ]] |
128 | then | ||
129 | niro | 11533 | ${MAGE_PYTHON_EXEC} waf install --destdir=${BINDIR} $@ || die |
130 | niro | 13778 | elif [[ -e meson.build ]] |
131 | then | ||
132 | # never run multilib builds here, multilib will be enabled by python_multilib_src_compile | ||
133 | # this honors the logic of other build methods (python, waf, autotools) | ||
134 | MULTILIB=false DESTDIR=${BINDIR} mninja install || die | ||
135 | niro | 3578 | elif [[ -e install.py ]] |
136 | then | ||
137 | niro | 11533 | ${MAGE_PYTHON_EXEC} install.py --prefix=/usr --files-only --destdir=${BINDIR} $@ || die |
138 | niro | 1664 | else |
139 | niro | 11533 | if [[ ${MULTILIB_BUILD} = true ]] && [[ ! -z $(typeset -f oldmconfigure) ]] && [[ ! -z $(typeset -f oldmmake) ]] |
140 | then | ||
141 | oldmmake DESTDIR=${BINDIR} install || die | ||
142 | else | ||
143 | mmake DESTDIR=${BINDIR} install || die | ||
144 | fi | ||
145 | niro | 1664 | fi |
146 | niro | 3578 | } |
147 | niro | 1664 | |
148 | niro | 3578 | python_src_compile() |
149 | { | ||
150 | cd ${SRCDIR} | ||
151 | niro | 11533 | python_docompile $@ || die |
152 | niro | 3578 | } |
153 | |||
154 | niro | 5459 | python_multilib_src_compile() |
155 | { | ||
156 | local abi | ||
157 | local saved_SRCDIR="${SRCDIR}" | ||
158 | |||
159 | for abi in ${MULTILIB_ABIS} | ||
160 | do | ||
161 | SRCDIR="${saved_SRCDIR}-${abi}/${SRCSUBDIR}" | ||
162 | cd ${SRCDIR} | ||
163 | niro | 11533 | abi-${abi} python_docompile $@ || die |
164 | niro | 5459 | done |
165 | SRCDIR="${saved_SRCDIR}" | ||
166 | } | ||
167 | |||
168 | python_src_check() | ||
169 | { | ||
170 | return 0 | ||
171 | } | ||
172 | |||
173 | niro | 3578 | python_src_install() |
174 | { | ||
175 | cd ${SRCDIR} | ||
176 | niro | 11533 | python_doinstall $@ || die |
177 | niro | 3578 | |
178 | niro | 1664 | local i |
179 | for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \ | ||
180 | niro | 16196 | FAQ LICENSE NEWS README* TODO PKG-INFO |
181 | niro | 1664 | do |
182 | if [ -f ${SRCDIR}/${i} ] | ||
183 | then | ||
184 | minstalldocs ${i} || die | ||
185 | fi | ||
186 | done | ||
187 | } | ||
188 | |||
189 | niro | 5459 | python_multilib_src_install() |
190 | { | ||
191 | local abi | ||
192 | local saved_SRCDIR="${SRCDIR}" | ||
193 | |||
194 | for abi in ${MULTILIB_ABIS} | ||
195 | do | ||
196 | SRCDIR="${saved_SRCDIR}-${abi}/${SRCSUBDIR}" | ||
197 | cd ${SRCDIR} | ||
198 | niro | 11533 | abi-${abi} python_doinstall $@ || die |
199 | niro | 5459 | |
200 | local i | ||
201 | for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \ | ||
202 | niro | 16196 | FAQ LICENSE NEWS README* TODO PKG-INFO |
203 | niro | 5459 | do |
204 | if [ -f ${SRCDIR}/${i} ] | ||
205 | then | ||
206 | oldminstalldocs ${i} || die | ||
207 | fi | ||
208 | done | ||
209 | done | ||
210 | SRCDIR="${saved_SRCDIR}" | ||
211 | } | ||
212 | |||
213 | export_inherits python src_prepare src_check | ||
214 | if [[ ${MULTILIB_BUILD} = true ]] | ||
215 | then | ||
216 | export_inherits python_multilib src_compile src_install | ||
217 | else | ||
218 | export_inherits python src_compile src_install | ||
219 | fi |