Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-lang/python/
Date: Thu, 01 Oct 2020 14:04:44
Message-Id: 1601561073.5178b8694f3c8f3969647a137eaded2ed103259c.mgorny@gentoo
1 commit: 5178b8694f3c8f3969647a137eaded2ed103259c
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Thu Oct 1 13:47:49 2020 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Thu Oct 1 14:04:33 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5178b869
7
8 dev-lang/python: Move py2 symlinks from python-exec to python:2.7
9
10 Closes: https://bugs.gentoo.org/745975
11 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
12
13 dev-lang/python/python-2.7.18-r4.ebuild | 369 ++++++++++++++++++++++++++++++++
14 1 file changed, 369 insertions(+)
15
16 diff --git a/dev-lang/python/python-2.7.18-r4.ebuild b/dev-lang/python/python-2.7.18-r4.ebuild
17 new file mode 100644
18 index 00000000000..456f56833cb
19 --- /dev/null
20 +++ b/dev-lang/python/python-2.7.18-r4.ebuild
21 @@ -0,0 +1,369 @@
22 +# Copyright 1999-2020 Gentoo Authors
23 +# Distributed under the terms of the GNU General Public License v2
24 +
25 +EAPI="7"
26 +WANT_LIBTOOL="none"
27 +
28 +inherit autotools flag-o-matic pax-utils python-utils-r1 toolchain-funcs
29 +
30 +MY_P="Python-${PV}"
31 +PYVER=$(ver_cut 1-2)
32 +PATCHSET="python-gentoo-patches-2.7.18-r3"
33 +
34 +DESCRIPTION="An interpreted, interactive, object-oriented programming language"
35 +HOMEPAGE="https://www.python.org/"
36 +SRC_URI="https://www.python.org/ftp/python/${PV}/${MY_P}.tar.xz
37 + https://dev.gentoo.org/~mgorny/dist/python/${PATCHSET}.tar.xz"
38 +S="${WORKDIR}/${MY_P}"
39 +
40 +LICENSE="PSF-2"
41 +SLOT="${PYVER}"
42 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86"
43 +IUSE="-berkdb bluetooth build elibc_uclibc examples gdbm hardened ipv6 libressl +ncurses +readline sqlite +ssl +threads tk +wide-unicode wininst +xml"
44 +
45 +# Do not add a dependency on dev-lang/python to this ebuild.
46 +# If you need to apply a patch which requires python for bootstrapping, please
47 +# run the bootstrap code on your dev box and include the results in the
48 +# patchset. See bug 447752.
49 +
50 +RDEPEND="app-arch/bzip2:=
51 + dev-libs/libffi:=
52 + >=sys-libs/zlib-1.1.3:=
53 + virtual/libcrypt:=
54 + virtual/libintl
55 + berkdb? ( || (
56 + sys-libs/db:5.3
57 + sys-libs/db:5.1
58 + sys-libs/db:4.8
59 + sys-libs/db:4.7
60 + sys-libs/db:4.6
61 + sys-libs/db:4.5
62 + sys-libs/db:4.4
63 + sys-libs/db:4.3
64 + sys-libs/db:4.2
65 + ) )
66 + gdbm? ( sys-libs/gdbm:=[berkdb] )
67 + ncurses? ( >=sys-libs/ncurses-5.2:= )
68 + readline? ( >=sys-libs/readline-4.1:= )
69 + sqlite? ( >=dev-db/sqlite-3.3.8:3= )
70 + ssl? (
71 + !libressl? ( dev-libs/openssl:= )
72 + libressl? ( dev-libs/libressl:= )
73 + )
74 + tk? (
75 + >=dev-lang/tcl-8.0:=
76 + >=dev-lang/tk-8.0:=
77 + dev-tcltk/blt:=
78 + dev-tcltk/tix
79 + )
80 + xml? ( >=dev-libs/expat-2.1:= )"
81 +# bluetooth requires headers from bluez
82 +DEPEND="${RDEPEND}
83 + bluetooth? ( net-wireless/bluez )
84 + virtual/pkgconfig
85 + !sys-devel/gcc[libffi(-)]"
86 +RDEPEND+="
87 + !build? ( app-misc/mime-types )
88 + !<=dev-lang/python-exec-2.4.6-r1"
89 +PDEPEND=">=app-eselect/eselect-python-20140125-r1"
90 +
91 +pkg_setup() {
92 + if use berkdb; then
93 + ewarn "'bsddb' module is out-of-date and no longer maintained inside"
94 + ewarn "dev-lang/python. 'bsddb' and 'dbhash' modules have been additionally"
95 + ewarn "removed in Python 3. A maintained alternative of 'bsddb3' module"
96 + ewarn "is provided by dev-python/bsddb3."
97 + else
98 + if has_version "=${CATEGORY}/${PN}-${PV%%.*}*[berkdb]"; then
99 + ewarn "You are migrating from =${CATEGORY}/${PN}-${PV%%.*}*[berkdb]"
100 + ewarn "to =${CATEGORY}/${PN}-${PV%%.*}*[-berkdb]."
101 + ewarn "You might need to migrate your databases."
102 + fi
103 + fi
104 +}
105 +
106 +src_prepare() {
107 + # Ensure that internal copies of expat, libffi and zlib are not used.
108 + rm -fr Modules/expat || die
109 + rm -fr Modules/_ctypes/libffi* || die
110 + rm -fr Modules/zlib || die
111 +
112 + local PATCHES=(
113 + "${WORKDIR}/${PATCHSET}"
114 + )
115 +
116 + default
117 +
118 + sed -i -e "s:@@GENTOO_LIBDIR@@:$(get_libdir):g" \
119 + Lib/distutils/command/install.py \
120 + Lib/distutils/sysconfig.py \
121 + Lib/site.py \
122 + Lib/sysconfig.py \
123 + Lib/test/test_site.py \
124 + Makefile.pre.in \
125 + Modules/Setup.dist \
126 + Modules/getpath.c \
127 + setup.py || die "sed failed to replace @@GENTOO_LIBDIR@@"
128 +
129 + eautoreconf
130 +}
131 +
132 +src_configure() {
133 + # dbm module can be linked against berkdb or gdbm.
134 + # Defaults to gdbm when both are enabled, #204343.
135 + local disable
136 + use berkdb || use gdbm || disable+=" dbm"
137 + use berkdb || disable+=" _bsddb"
138 + # disable automagic bluetooth headers detection
139 + use bluetooth || export ac_cv_header_bluetooth_bluetooth_h=no
140 + use gdbm || disable+=" gdbm"
141 + use ncurses || disable+=" _curses _curses_panel"
142 + use readline || disable+=" readline"
143 + use sqlite || disable+=" _sqlite3"
144 + use ssl || export PYTHON_DISABLE_SSL="1"
145 + use tk || disable+=" _tkinter"
146 + use xml || disable+=" _elementtree pyexpat" # _elementtree uses pyexpat.
147 + export PYTHON_DISABLE_MODULES="${disable}"
148 +
149 + if ! use xml; then
150 + ewarn "You have configured Python without XML support."
151 + ewarn "This is NOT a recommended configuration as you"
152 + ewarn "may face problems parsing any XML documents."
153 + fi
154 +
155 + if [[ -n "${PYTHON_DISABLE_MODULES}" ]]; then
156 + einfo "Disabled modules: ${PYTHON_DISABLE_MODULES}"
157 + fi
158 +
159 + if [[ "$(gcc-major-version)" -ge 4 ]]; then
160 + append-flags -fwrapv
161 + fi
162 +
163 + filter-flags -malign-double
164 +
165 + # https://bugs.gentoo.org/show_bug.cgi?id=50309
166 + if is-flagq -O3; then
167 + is-flagq -fstack-protector-all && replace-flags -O3 -O2
168 + use hardened && replace-flags -O3 -O2
169 + fi
170 +
171 + if tc-is-cross-compiler; then
172 + # Force some tests that try to poke fs paths.
173 + export ac_cv_file__dev_ptc=no
174 + export ac_cv_file__dev_ptmx=yes
175 + fi
176 +
177 + # Export CXX so it ends up in /usr/lib/python2.X/config/Makefile.
178 + tc-export CXX
179 + # The configure script fails to use pkg-config correctly.
180 + # http://bugs.python.org/issue15506
181 + export ac_cv_path_PKG_CONFIG=$(tc-getPKG_CONFIG)
182 +
183 + # Set LDFLAGS so we link modules with -lpython2.7 correctly.
184 + # Needed on FreeBSD unless Python 2.7 is already installed.
185 + # Please query BSD team before removing this!
186 + append-ldflags "-L."
187 +
188 + local dbmliborder
189 + if use gdbm; then
190 + dbmliborder+="${dbmliborder:+:}gdbm"
191 + fi
192 + if use berkdb; then
193 + dbmliborder+="${dbmliborder:+:}bdb"
194 + fi
195 +
196 + local myeconfargs=(
197 + # The check is broken on clang, and gives false positive:
198 + # https://bugs.gentoo.org/596798
199 + # (upstream dropped this flag in 3.2a4 anyway)
200 + ac_cv_opt_olimit_ok=no
201 + # glibc-2.30 removes it; since we can't cleanly force-rebuild
202 + # Python on glibc upgrade, remove it proactively to give
203 + # a chance for users rebuilding python before glibc
204 + ac_cv_header_stropts_h=no
205 +
206 + --with-fpectl
207 + --enable-shared
208 + $(use_enable ipv6)
209 + $(use_with threads)
210 + $(use wide-unicode && echo "--enable-unicode=ucs4" || echo "--enable-unicode=ucs2")
211 + --infodir='${prefix}/share/info'
212 + --mandir='${prefix}/share/man'
213 + --with-computed-gotos
214 + --with-dbmliborder="${dbmliborder}"
215 + --with-libc=
216 + --enable-loadable-sqlite-extensions
217 + --with-system-expat
218 + --with-system-ffi
219 + --without-ensurepip
220 + )
221 +
222 + OPT="" econf "${myeconfargs[@]}"
223 +
224 + if use threads && grep -q "#define POSIX_SEMAPHORES_NOT_ENABLED 1" pyconfig.h; then
225 + eerror "configure has detected that the sem_open function is broken."
226 + eerror "Please ensure that /dev/shm is mounted as a tmpfs with mode 1777."
227 + die "Broken sem_open function (bug 496328)"
228 + fi
229 +}
230 +
231 +src_compile() {
232 + # Ensure sed works as expected
233 + # https://bugs.gentoo.org/594768
234 + local -x LC_ALL=C
235 +
236 + # Avoid invoking pgen for cross-compiles.
237 + touch Include/graminit.h Python/graminit.c
238 +
239 + emake
240 +
241 + # Work around bug 329499. See also bug 413751 and 457194.
242 + if has_version dev-libs/libffi[pax_kernel]; then
243 + pax-mark E python
244 + else
245 + pax-mark m python
246 + fi
247 +}
248 +
249 +src_test() {
250 + # Tests will not work when cross compiling.
251 + if tc-is-cross-compiler; then
252 + elog "Disabling tests due to crosscompiling."
253 + return
254 + fi
255 +
256 + # Skip failing tests.
257 + local skipped_tests="distutils gdb"
258 +
259 + for test in ${skipped_tests}; do
260 + mv "${S}"/Lib/test/test_${test}.py "${T}"
261 + done
262 +
263 + # bug 660358
264 + local -x COLUMNS=80
265 +
266 + # Daylight saving time problem
267 + # https://bugs.python.org/issue22067
268 + # https://bugs.gentoo.org/610628
269 + local -x TZ=UTC
270 +
271 + # Rerun failed tests in verbose mode (regrtest -w).
272 + emake test EXTRATESTOPTS="-w" < /dev/tty
273 + local result="$?"
274 +
275 + for test in ${skipped_tests}; do
276 + mv "${T}/test_${test}.py" "${S}"/Lib/test
277 + done
278 +
279 + elog "The following tests have been skipped:"
280 + for test in ${skipped_tests}; do
281 + elog "test_${test}.py"
282 + done
283 +
284 + elog "If you would like to run them, you may:"
285 + elog "cd '${EPREFIX}/usr/$(get_libdir)/python${PYVER}/test'"
286 + elog "and run the tests separately."
287 +
288 + if [[ ${result} -ne 0 ]]; then
289 + die "emake test failed"
290 + fi
291 +}
292 +
293 +src_install() {
294 + local libdir=${ED}/usr/$(get_libdir)/python${PYVER}
295 +
296 + emake DESTDIR="${D}" altinstall
297 +
298 + sed -e "s/\(LDFLAGS=\).*/\1/" -i "${libdir}/config/Makefile" || die
299 +
300 + # Fix collisions between different slots of Python.
301 + mv "${ED}/usr/bin/2to3" "${ED}/usr/bin/2to3-${PYVER}" || die
302 + mv "${ED}/usr/bin/pydoc" "${ED}/usr/bin/pydoc${PYVER}" || die
303 + mv "${ED}/usr/bin/idle" "${ED}/usr/bin/idle${PYVER}" || die
304 + rm "${ED}/usr/bin/smtpd.py" || die
305 +
306 + use berkdb || rm -r "${libdir}/"{bsddb,dbhash.py*,test/test_bsddb*} || die
307 + use sqlite || rm -r "${libdir}/"{sqlite3,test/test_sqlite*} || die
308 + use tk || rm -r "${ED}/usr/bin/idle${PYVER}" "${libdir}/"{idlelib,lib-tk} || die
309 + use elibc_uclibc && rm -fr "${libdir}/"{bsddb/test,test}
310 +
311 + use threads || rm -r "${libdir}/multiprocessing" || die
312 + use wininst || rm "${libdir}/distutils/command/"wininst-*.exe || die
313 +
314 + dodoc Misc/{ACKS,HISTORY,NEWS}
315 +
316 + if use examples; then
317 + docinto examples
318 + dodoc -r Tools
319 + fi
320 + insinto /usr/share/gdb/auto-load/usr/$(get_libdir) #443510
321 + local libname=$(printf 'e:\n\t@echo $(INSTSONAME)\ninclude Makefile\n' | \
322 + emake --no-print-directory -s -f - 2>/dev/null)
323 + newins "${S}"/Tools/gdb/libpython.py "${libname}"-gdb.py
324 +
325 + newconfd "${FILESDIR}/pydoc.conf" pydoc-${PYVER}
326 + newinitd "${FILESDIR}/pydoc.init" pydoc-${PYVER}
327 + sed \
328 + -e "s:@PYDOC_PORT_VARIABLE@:PYDOC${PYVER/./_}_PORT:" \
329 + -e "s:@PYDOC@:pydoc${PYVER}:" \
330 + -i "${ED}/etc/conf.d/pydoc-${PYVER}" \
331 + "${ED}/etc/init.d/pydoc-${PYVER}" || die "sed failed"
332 +
333 + local -x EPYTHON=python${PYVER}
334 + # if not using a cross-compiler, use the fresh binary
335 + if ! tc-is-cross-compiler; then
336 + local -x PYTHON=./python
337 + local -x LD_LIBRARY_PATH=${LD_LIBRARY_PATH+${LD_LIBRARY_PATH}:}${PWD}
338 + else
339 + local -x PYTHON=${EPREFIX}/usr/bin/${EPYTHON}
340 + fi
341 +
342 + echo "EPYTHON='${EPYTHON}'" > epython.py || die
343 + python_domodule epython.py
344 +
345 + # python-exec wrapping support
346 + local scriptdir=${D}$(python_get_scriptdir)
347 + mkdir -p "${scriptdir}" || die
348 + # python
349 + ln -s "../../../bin/python${PYVER}" \
350 + "${scriptdir}/python" || die
351 + # python-config
352 + ln -s "../../../bin/python${PYVER}-config" \
353 + "${scriptdir}/python-config" || die
354 + # 2to3, pydoc, pyvenv
355 + ln -s "../../../bin/2to3-${PYVER}" \
356 + "${scriptdir}/2to3" || die
357 + ln -s "../../../bin/pydoc${PYVER}" \
358 + "${scriptdir}/pydoc" || die
359 + # idle
360 + if use tk; then
361 + ln -s "../../../bin/idle${PYVER}" \
362 + "${scriptdir}/idle" || die
363 + fi
364 +
365 + # python2* is no longer wrapped, so just symlink it
366 + local pymajor=${PYVER%.*}
367 + dosym "python${PYVER}" "/usr/bin/python${pymajor}"
368 + dosym "python${PYVER}-config" "/usr/bin/python${pymajor}-config"
369 +}
370 +
371 +eselect_python_update() {
372 + if [[ -z "$(eselect python show)" || \
373 + ! -f "${EROOT}/usr/bin/$(eselect python show)" ]]; then
374 + eselect python update
375 + fi
376 +
377 + if [[ -z "$(eselect python show --python${PV%%.*})" || \
378 + ! -f "${EROOT}/usr/bin/$(eselect python show --python${PV%%.*})" ]]
379 + then
380 + eselect python update --python${PV%%.*}
381 + fi
382 +}
383 +
384 +pkg_postinst() {
385 + eselect_python_update
386 +}
387 +
388 +pkg_postrm() {
389 + eselect_python_update
390 +}