30 |
30 |
SLOT="${PYVER}"
|
31 |
31 |
KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~loong ~m68k ~mips ppc ppc64 ~riscv ~s390 sparc x86"
|
32 |
32 |
IUSE="
|
33 |
|
bluetooth build debug +ensurepip examples gdbm lto +ncurses pgo
|
34 |
|
+readline +sqlite +ssl test tk valgrind +xml
|
|
33 |
bluetooth build debug +ensurepip examples gdbm libedit lto
|
|
34 |
+ncurses pgo +readline +sqlite +ssl test tk valgrind +xml
|
35 |
35 |
"
|
36 |
36 |
RESTRICT="!test? ( test )"
|
37 |
37 |
|
... | ... | |
43 |
43 |
RDEPEND="
|
44 |
44 |
app-arch/bzip2:=
|
45 |
45 |
app-arch/xz-utils:=
|
|
46 |
dev-lang/python-exec[python_targets_python3_10(-)]
|
46 |
47 |
dev-libs/libffi:=
|
47 |
48 |
dev-python/gentoo-common
|
48 |
49 |
>=sys-libs/zlib-1.1.3:=
|
... | ... | |
52 |
53 |
gdbm? ( sys-libs/gdbm:=[berkdb] )
|
53 |
54 |
kernel_linux? ( sys-apps/util-linux:= )
|
54 |
55 |
ncurses? ( >=sys-libs/ncurses-5.2:= )
|
55 |
|
readline? ( >=sys-libs/readline-4.1:= )
|
|
56 |
readline? (
|
|
57 |
!libedit? ( >=sys-libs/readline-4.1:= )
|
|
58 |
libedit? ( dev-libs/libedit:= )
|
|
59 |
)
|
56 |
60 |
sqlite? ( >=dev-db/sqlite-3.3.8:3= )
|
57 |
61 |
ssl? ( >=dev-libs/openssl-1.1.1:= )
|
58 |
62 |
tk? (
|
... | ... | |
67 |
71 |
DEPEND="
|
68 |
72 |
${RDEPEND}
|
69 |
73 |
bluetooth? ( net-wireless/bluez )
|
70 |
|
test? ( app-arch/xz-utils[extra-filters(+)] )
|
71 |
74 |
valgrind? ( dev-util/valgrind )
|
|
75 |
test? ( app-arch/xz-utils[extra-filters(+)] )
|
72 |
76 |
"
|
73 |
77 |
# autoconf-archive needed to eautoreconf
|
74 |
78 |
BDEPEND="
|
... | ... | |
128 |
132 |
eautoreconf
|
129 |
133 |
}
|
130 |
134 |
|
|
135 |
build_cbuild_python() {
|
|
136 |
# Hack to workaround get_libdir not being able to handle CBUILD, bug #794181
|
|
137 |
local cbuild_libdir=$(unset PKG_CONFIG_PATH ; $(tc-getBUILD_PKG_CONFIG) --keep-system-libs --libs-only-L libffi)
|
|
138 |
|
|
139 |
# pass system CFLAGS & LDFLAGS as _NODIST, otherwise they'll get
|
|
140 |
# propagated to sysconfig for built extensions
|
|
141 |
#
|
|
142 |
# -fno-lto to avoid bug #700012 (not like it matters for mini-CBUILD Python anyway)
|
|
143 |
local -x CFLAGS_NODIST="${BUILD_CFLAGS} -fno-lto"
|
|
144 |
local -x LDFLAGS_NODIST=${BUILD_LDFLAGS}
|
|
145 |
local -x CFLAGS= LDFLAGS=
|
|
146 |
local -x BUILD_CFLAGS="${CFLAGS_NODIST}"
|
|
147 |
local -x BUILD_LDFLAGS=${LDFLAGS_NODIST}
|
|
148 |
|
|
149 |
# We need to build our own Python on CBUILD first, and feed it in.
|
|
150 |
# bug #847910 and bug #864911.
|
|
151 |
local myeconfargs_cbuild=(
|
|
152 |
"${myeconfargs[@]}"
|
|
153 |
|
|
154 |
--prefix="${BROOT}"/usr
|
|
155 |
--libdir="${cbuild_libdir:2}"
|
|
156 |
|
|
157 |
# Avoid needing to load the right libpython.so.
|
|
158 |
--disable-shared
|
|
159 |
|
|
160 |
# As minimal as possible for the mini CBUILD Python
|
|
161 |
# we build just for cross.
|
|
162 |
--without-lto
|
|
163 |
--disable-optimizations
|
|
164 |
)
|
|
165 |
|
|
166 |
mkdir "${WORKDIR}"/${P}-${CBUILD} || die
|
|
167 |
pushd "${WORKDIR}"/${P}-${CBUILD} &> /dev/null || die
|
|
168 |
# We disable _ctypes and _crypt for CBUILD because Python's setup.py can't handle locating
|
|
169 |
# libdir correctly for cross.
|
|
170 |
PYTHON_DISABLE_MODULES+=" _ctypes _crypt" \
|
|
171 |
ECONF_SOURCE="${S}" econf_build "${myeconfargs_cbuild[@]}"
|
|
172 |
|
|
173 |
# Avoid as many dependencies as possible for the cross build.
|
|
174 |
cat >> Makefile <<-EOF || die
|
|
175 |
MODULE_NIS=disabled
|
|
176 |
MODULE__DBM=disabled
|
|
177 |
MODULE__GDBM=disabled
|
|
178 |
MODULE__DBM=disabled
|
|
179 |
MODULE__SQLITE3=disabled
|
|
180 |
MODULE__HASHLIB=disabled
|
|
181 |
MODULE__SSL=disabled
|
|
182 |
MODULE__CURSES=disabled
|
|
183 |
MODULE__CURSES_PANEL=disabled
|
|
184 |
MODULE_READLINE=disabled
|
|
185 |
MODULE__TKINTER=disabled
|
|
186 |
MODULE_PYEXPAT=disabled
|
|
187 |
MODULE_ZLIB=disabled
|
|
188 |
EOF
|
|
189 |
|
|
190 |
# Unfortunately, we do have to build this immediately, and
|
|
191 |
# not in src_compile, because CHOST configure for Python
|
|
192 |
# will check the existence of the Python it was pointed to
|
|
193 |
# immediately.
|
|
194 |
PYTHON_DISABLE_MODULES+=" _ctypes _crypt" emake
|
|
195 |
popd &> /dev/null || die
|
|
196 |
}
|
|
197 |
|
131 |
198 |
src_configure() {
|
132 |
199 |
# disable automagic bluetooth headers detection
|
133 |
200 |
if ! use bluetooth; then
|
... | ... | |
175 |
242 |
-m test
|
176 |
243 |
"-j$(makeopts_jobs)"
|
177 |
244 |
--pgo-extended
|
|
245 |
-u-network
|
|
246 |
|
|
247 |
# We use a timeout because of how often we've had hang issues
|
|
248 |
# here. It also matches the default upstream PROFILE_TASK.
|
|
249 |
--timeout 1200
|
|
250 |
|
178 |
251 |
-x test_gdb
|
179 |
252 |
-x test_dtrace
|
180 |
|
-u-network
|
181 |
253 |
|
182 |
254 |
# All of these seem to occasionally hang for PGO inconsistently
|
183 |
255 |
# They'll even hang here but be fine in src_test sometimes.
|
... | ... | |
210 |
282 |
ac_cv_header_stropts_h=no
|
211 |
283 |
|
212 |
284 |
--enable-shared
|
|
285 |
--without-static-libpython
|
213 |
286 |
--enable-ipv6
|
214 |
287 |
--infodir='${prefix}/share/info'
|
215 |
288 |
--mandir='${prefix}/share/man'
|
... | ... | |
225 |
298 |
$(use_with debug assertions)
|
226 |
299 |
$(use_with lto)
|
227 |
300 |
$(use_enable pgo optimizations)
|
|
301 |
$(use_with readline readline "$(usex libedit editline readline)")
|
228 |
302 |
$(use_with valgrind)
|
229 |
303 |
)
|
230 |
304 |
|
... | ... | |
232 |
306 |
local -x OPT=
|
233 |
307 |
|
234 |
308 |
if tc-is-cross-compiler ; then
|
235 |
|
# Hack to workaround get_libdir not being able to handle CBUILD, bug #794181
|
236 |
|
local cbuild_libdir=$(unset PKG_CONFIG_PATH ; $(tc-getBUILD_PKG_CONFIG) --keep-system-libs --libs-only-L libffi)
|
237 |
|
|
238 |
|
# pass system CFLAGS & LDFLAGS as _NODIST, otherwise they'll get
|
239 |
|
# propagated to sysconfig for built extensions
|
240 |
|
#
|
241 |
|
# -fno-lto to avoid bug #700012 (not like it matters for mini-CBUILD Python anyway)
|
242 |
|
local -x CFLAGS_NODIST="${BUILD_CFLAGS} -fno-lto"
|
243 |
|
local -x LDFLAGS_NODIST=${BUILD_LDFLAGS}
|
244 |
|
local -x CFLAGS= LDFLAGS=
|
245 |
|
local -x BUILD_CFLAGS="${CFLAGS_NODIST}"
|
246 |
|
local -x BUILD_LDFLAGS=${LDFLAGS_NODIST}
|
247 |
|
|
248 |
|
# We need to build our own Python on CBUILD first, and feed it in.
|
249 |
|
# bug #847910 and bug #864911.
|
250 |
|
local myeconfargs_cbuild=(
|
251 |
|
"${myeconfargs[@]}"
|
252 |
|
|
253 |
|
--libdir="${cbuild_libdir:2}"
|
254 |
|
|
255 |
|
# Avoid needing to load the right libpython.so.
|
256 |
|
--disable-shared
|
257 |
|
|
258 |
|
# As minimal as possible for the mini CBUILD Python
|
259 |
|
# we build just for cross.
|
260 |
|
--without-lto
|
261 |
|
--disable-optimizations
|
262 |
|
)
|
263 |
|
|
|
309 |
build_cbuild_python
|
264 |
310 |
# Point the imminent CHOST build to the Python we just
|
265 |
311 |
# built for CBUILD.
|
266 |
312 |
export PATH="${WORKDIR}/${P}-${CBUILD}:${PATH}"
|
267 |
|
|
268 |
|
mkdir "${WORKDIR}"/${P}-${CBUILD} || die
|
269 |
|
pushd "${WORKDIR}"/${P}-${CBUILD} &> /dev/null || die
|
270 |
|
# We disable _ctypes and _crypt for CBUILD because Python's setup.py can't handle locating
|
271 |
|
# libdir correctly for cross.
|
272 |
|
PYTHON_DISABLE_MODULES="${PYTHON_DISABLE_MODULES} _ctypes _crypt" \
|
273 |
|
ECONF_SOURCE="${S}" econf_build "${myeconfargs_cbuild[@]}"
|
274 |
|
|
275 |
|
# Avoid as many dependencies as possible for the cross build.
|
276 |
|
cat >> Makefile <<-EOF || die
|
277 |
|
MODULE_NIS=disabled
|
278 |
|
MODULE__DBM=disabled
|
279 |
|
MODULE__GDBM=disabled
|
280 |
|
MODULE__DBM=disabled
|
281 |
|
MODULE__SQLITE3=disabled
|
282 |
|
MODULE__HASHLIB=disabled
|
283 |
|
MODULE__SSL=disabled
|
284 |
|
MODULE__CURSES=disabled
|
285 |
|
MODULE__CURSES_PANEL=disabled
|
286 |
|
MODULE_READLINE=disabled
|
287 |
|
MODULE__TKINTER=disabled
|
288 |
|
MODULE_PYEXPAT=disabled
|
289 |
|
MODULE_ZLIB=disabled
|
290 |
|
EOF
|
291 |
|
|
292 |
|
# Unfortunately, we do have to build this immediately, and
|
293 |
|
# not in src_compile, because CHOST configure for Python
|
294 |
|
# will check the existence of the Python it was pointed to
|
295 |
|
# immediately.
|
296 |
|
PYTHON_DISABLE_MODULES="${PYTHON_DISABLE_MODULES} _ctypes _crypt" emake
|
297 |
|
popd &> /dev/null || die
|
298 |
313 |
fi
|
299 |
314 |
|
300 |
315 |
# pass system CFLAGS & LDFLAGS as _NODIST, otherwise they'll get
|
... | ... | |
388 |
403 |
# bug 660358
|
389 |
404 |
local -x COLUMNS=80
|
390 |
405 |
local -x PYTHONDONTWRITEBYTECODE=
|
|
406 |
# workaround https://bugs.gentoo.org/775416
|
|
407 |
addwrite "/usr/lib/python${PYVER}/site-packages"
|
391 |
408 |
|
392 |
409 |
nonfatal emake test EXTRATESTOPTS="${test_opts[*]}" \
|
393 |
410 |
CPPFLAGS= CFLAGS= LDFLAGS= < /dev/tty
|
... | ... | |
403 |
420 |
|
404 |
421 |
emake DESTDIR="${D}" altinstall
|
405 |
422 |
|
406 |
|
# Remove static library
|
407 |
|
rm "${ED}"/usr/$(get_libdir)/libpython*.a || die
|
408 |
|
|
409 |
423 |
# Fix collisions between different slots of Python.
|
410 |
424 |
rm "${ED}/usr/$(get_libdir)/libpython3.so" || die
|
411 |
425 |
|