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: Tue, 30 Aug 2022 13:57:45
Message-Id: 1661867859.754db5eb0f4dc71c721e231f5f7e152ee9ee6c89.mgorny@gentoo
1 commit: 754db5eb0f4dc71c721e231f5f7e152ee9ee6c89
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Tue Aug 30 10:57:48 2022 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Tue Aug 30 13:57:39 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=754db5eb
7
8 dev-lang/python: Modernize and cleanup 2.7.18_p15 ebuild
9
10 Copy changes from newer versions. General cleanup and fixes. Remove
11 python-exec wrapping support. Remove the static library.
12
13 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
14
15 dev-lang/python/python-2.7.18_p15-r1.ebuild | 314 ++++++++++++++++++++++++++++
16 1 file changed, 314 insertions(+)
17
18 diff --git a/dev-lang/python/python-2.7.18_p15-r1.ebuild b/dev-lang/python/python-2.7.18_p15-r1.ebuild
19 new file mode 100644
20 index 000000000000..6727edf2a596
21 --- /dev/null
22 +++ b/dev-lang/python/python-2.7.18_p15-r1.ebuild
23 @@ -0,0 +1,314 @@
24 +# Copyright 1999-2022 Gentoo Authors
25 +# Distributed under the terms of the GNU General Public License v2
26 +
27 +EAPI="7"
28 +WANT_LIBTOOL="none"
29 +
30 +inherit autotools flag-o-matic pax-utils
31 +inherit python-utils-r1 toolchain-funcs verify-sig
32 +
33 +MY_P="Python-${PV%_p*}"
34 +PYVER=$(ver_cut 1-2)
35 +PATCHSET="python-gentoo-patches-${PV}"
36 +
37 +DESCRIPTION="An interpreted, interactive, object-oriented programming language"
38 +HOMEPAGE="
39 + https://www.python.org/
40 + https://github.com/python/cpython/
41 + https://gitweb.gentoo.org/fork/cpython.git/
42 +"
43 +SRC_URI="
44 + https://www.python.org/ftp/python/${PV%_*}/${MY_P}.tar.xz
45 + https://dev.gentoo.org/~mgorny/dist/python/${PATCHSET}.tar.xz
46 + verify-sig? (
47 + https://www.python.org/ftp/python/${PV%_*}/${MY_P}.tar.xz.asc
48 + )
49 +"
50 +S="${WORKDIR}/${MY_P}"
51 +
52 +LICENSE="PSF-2"
53 +SLOT="${PYVER}"
54 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
55 +IUSE="
56 + berkdb bluetooth build examples gdbm hardened +ncurses +readline
57 + +sqlite +ssl tk wininst +xml
58 +"
59 +
60 +# Do not add a dependency on dev-lang/python to this ebuild.
61 +# If you need to apply a patch which requires python for bootstrapping, please
62 +# run the bootstrap code on your dev box and include the results in the
63 +# patchset. See bug 447752.
64 +
65 +RDEPEND="
66 + app-arch/bzip2:=
67 + dev-libs/libffi:=
68 + >=sys-libs/zlib-1.1.3:=
69 + virtual/libcrypt:=
70 + virtual/libintl
71 + berkdb? ( || (
72 + sys-libs/db:5.3
73 + sys-libs/db:4.8
74 + ) )
75 + gdbm? ( sys-libs/gdbm:=[berkdb] )
76 + ncurses? ( >=sys-libs/ncurses-5.2:= )
77 + readline? ( >=sys-libs/readline-4.1:= )
78 + sqlite? ( >=dev-db/sqlite-3.3.8:3= )
79 + ssl? ( dev-libs/openssl:= )
80 + tk? (
81 + >=dev-lang/tcl-8.0:=
82 + >=dev-lang/tk-8.0:=
83 + dev-tcltk/blt:=
84 + dev-tcltk/tix
85 + )
86 + xml? ( >=dev-libs/expat-2.1:= )
87 +"
88 +# bluetooth requires headers from bluez
89 +DEPEND="
90 + ${RDEPEND}
91 + bluetooth? ( net-wireless/bluez )
92 +"
93 +BDEPEND="
94 + virtual/awk
95 + virtual/pkgconfig
96 + verify-sig? ( sec-keys/openpgp-keys-python )
97 + !sys-devel/gcc[libffi(-)]
98 +"
99 +RDEPEND+="
100 + !build? ( app-misc/mime-types )
101 +"
102 +
103 +VERIFY_SIG_OPENPGP_KEY_PATH=${BROOT}/usr/share/openpgp-keys/python.org.asc
104 +
105 +QA_PKGCONFIG_VERSION=${PYVER}
106 +
107 +pkg_setup() {
108 + if use berkdb; then
109 + ewarn "'bsddb' module is out-of-date and no longer maintained inside"
110 + ewarn "dev-lang/python. 'bsddb' and 'dbhash' modules have been additionally"
111 + ewarn "removed in Python 3. A maintained alternative of 'bsddb3' module"
112 + ewarn "is provided by dev-python/bsddb3."
113 + fi
114 +}
115 +
116 +src_unpack() {
117 + if use verify-sig; then
118 + verify-sig_verify_detached "${DISTDIR}"/${MY_P}.tar.xz{,.asc}
119 + fi
120 + default
121 +}
122 +
123 +src_prepare() {
124 + # Ensure that internal copies of expat, libffi and zlib are not used.
125 + rm -r Modules/expat || die
126 + rm -r Modules/_ctypes/libffi* || die
127 + rm -r Modules/zlib || die
128 +
129 + local PATCHES=(
130 + "${WORKDIR}/${PATCHSET}"
131 + )
132 +
133 + default
134 +
135 + sed -i -e "s:@@GENTOO_LIBDIR@@:$(get_libdir):g" \
136 + Lib/distutils/command/install.py \
137 + Lib/distutils/sysconfig.py \
138 + Lib/site.py \
139 + Lib/sysconfig.py \
140 + Lib/test/test_site.py \
141 + Makefile.pre.in \
142 + Modules/Setup.dist \
143 + Modules/getpath.c \
144 + setup.py || die "sed failed to replace @@GENTOO_LIBDIR@@"
145 +
146 + eautoreconf
147 +}
148 +
149 +src_configure() {
150 + # dbm module can be linked against berkdb or gdbm.
151 + # Defaults to gdbm when both are enabled, #204343.
152 + local disable
153 + use berkdb || use gdbm || disable+=" dbm"
154 + use berkdb || disable+=" _bsddb"
155 + # disable automagic bluetooth headers detection
156 + use bluetooth || export ac_cv_header_bluetooth_bluetooth_h=no
157 + use gdbm || disable+=" gdbm"
158 + use ncurses || disable+=" _curses _curses_panel"
159 + use readline || disable+=" readline"
160 + use sqlite || disable+=" _sqlite3"
161 + use ssl || export PYTHON_DISABLE_SSL="1"
162 + use tk || disable+=" _tkinter"
163 + use xml || disable+=" _elementtree pyexpat" # _elementtree uses pyexpat.
164 + export PYTHON_DISABLE_MODULES="${disable}"
165 +
166 + if ! use xml; then
167 + ewarn "You have configured Python without XML support."
168 + ewarn "This is NOT a recommended configuration as you"
169 + ewarn "may face problems parsing any XML documents."
170 + fi
171 +
172 + if [[ -n "${PYTHON_DISABLE_MODULES}" ]]; then
173 + einfo "Disabled modules: ${PYTHON_DISABLE_MODULES}"
174 + fi
175 +
176 + append-flags -fwrapv
177 +
178 + filter-flags -malign-double
179 +
180 + if tc-is-cross-compiler; then
181 + # Force some tests that try to poke fs paths.
182 + export ac_cv_file__dev_ptc=no
183 + export ac_cv_file__dev_ptmx=yes
184 + fi
185 +
186 + # Export CXX so it ends up in /usr/lib/python2.X/config/Makefile.
187 + tc-export CXX
188 + # The configure script fails to use pkg-config correctly.
189 + # http://bugs.python.org/issue15506
190 + export ac_cv_path_PKG_CONFIG=$(tc-getPKG_CONFIG)
191 +
192 + local dbmliborder=
193 + if use gdbm; then
194 + dbmliborder+="${dbmliborder:+:}gdbm"
195 + fi
196 + if use berkdb; then
197 + dbmliborder+="${dbmliborder:+:}bdb"
198 + fi
199 +
200 + local myeconfargs=(
201 + # The check is broken on clang, and gives false positive:
202 + # https://bugs.gentoo.org/596798
203 + # (upstream dropped this flag in 3.2a4 anyway)
204 + ac_cv_opt_olimit_ok=no
205 + # glibc-2.30 removes it; since we can't cleanly force-rebuild
206 + # Python on glibc upgrade, remove it proactively to give
207 + # a chance for users rebuilding python before glibc
208 + ac_cv_header_stropts_h=no
209 +
210 + --with-fpectl
211 + --enable-shared
212 + --enable-ipv6
213 + --with-threads
214 + --enable-unicode=ucs4
215 + --infodir='${prefix}/share/info'
216 + --mandir='${prefix}/share/man'
217 + --with-computed-gotos
218 + --with-dbmliborder="${dbmliborder}"
219 + --with-libc=
220 + --enable-loadable-sqlite-extensions
221 + --without-ensurepip
222 + --with-system-expat
223 + --with-system-ffi
224 + )
225 +
226 + # disable implicit optimization/debugging flags
227 + local -x OPT=
228 + econf "${myeconfargs[@]}"
229 +
230 + if grep -q "#define POSIX_SEMAPHORES_NOT_ENABLED 1" pyconfig.h; then
231 + eerror "configure has detected that the sem_open function is broken."
232 + eerror "Please ensure that /dev/shm is mounted as a tmpfs with mode 1777."
233 + die "Broken sem_open function (bug 496328)"
234 + fi
235 +
236 + # install epython.py as part of stdlib
237 + echo "EPYTHON='python${PYVER}'" > Lib/epython.py || die
238 +}
239 +
240 +src_compile() {
241 + # Ensure sed works as expected
242 + # https://bugs.gentoo.org/594768
243 + local -x LC_ALL=C
244 +
245 + # Avoid invoking pgen for cross-compiles.
246 + touch Include/graminit.h Python/graminit.c || die
247 +
248 + emake
249 +
250 + # Work around bug 329499. See also bug 413751 and 457194.
251 + if has_version dev-libs/libffi[pax-kernel]; then
252 + pax-mark E python
253 + else
254 + pax-mark m python
255 + fi
256 +}
257 +
258 +src_test() {
259 + # Tests will not work when cross compiling.
260 + if tc-is-cross-compiler; then
261 + elog "Disabling tests due to crosscompiling."
262 + return
263 + fi
264 +
265 + # Skip failing tests.
266 + local skipped_tests=( distutils gdb )
267 +
268 + for test in "${skipped_tests[@]}"; do
269 + mv Lib/test/test_${test}.py "${T}"/ || die
270 + done
271 +
272 + # bug 660358
273 + local -x COLUMNS=80
274 +
275 + # Daylight saving time problem
276 + # https://bugs.python.org/issue22067
277 + # https://bugs.gentoo.org/610628
278 + local -x TZ=UTC
279 +
280 + # Rerun failed tests in verbose mode (regrtest -w).
281 + emake test EXTRATESTOPTS="-w" < /dev/tty
282 +
283 + for test in "${skipped_tests[@]}"; do
284 + mv "${T}/test_${test}.py" Lib/test/ || die
285 + done
286 +}
287 +
288 +src_install() {
289 + local libdir=${ED}/usr/$(get_libdir)/python${PYVER}
290 +
291 + emake DESTDIR="${D}" altinstall
292 +
293 + sed -e "s/\(LDFLAGS=\).*/\1/" -i "${libdir}/config/Makefile" || die
294 +
295 + # Remove static library
296 + rm "${ED}"/usr/$(get_libdir)/libpython*.a || die
297 +
298 + # Fix collisions between different slots of Python.
299 + mv "${ED}/usr/bin/2to3" "${ED}/usr/bin/2to3-${PYVER}" || die
300 + mv "${ED}/usr/bin/pydoc" "${ED}/usr/bin/pydoc${PYVER}" || die
301 + mv "${ED}/usr/bin/idle" "${ED}/usr/bin/idle${PYVER}" || die
302 + rm "${ED}/usr/bin/smtpd.py" || die
303 +
304 + if ! use berkdb; then
305 + rm -r "${libdir}/"{bsddb,dbhash.py*,test/test_bsddb*} || die
306 + fi
307 + if ! use sqlite; then
308 + rm -r "${libdir}/"{sqlite3,test/test_sqlite*} || die
309 + fi
310 + if ! use tk; then
311 + rm -r "${ED}/usr/bin/idle${PYVER}" || die
312 + rm -r "${libdir}/"{idlelib,lib-tk} || die
313 + fi
314 + if ! use wininst; then
315 + rm "${libdir}/distutils/command/"wininst-*.exe || die
316 + fi
317 +
318 + dodoc Misc/{ACKS,HISTORY,NEWS}
319 +
320 + if use examples; then
321 + docinto examples
322 + dodoc -r Tools
323 + fi
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 + # python2* is no longer wrapped, so just symlink it
334 + local pymajor=${PYVER%.*}
335 + dosym "python${PYVER}" "/usr/bin/python${pymajor}"
336 + dosym "python${PYVER}-config" "/usr/bin/python${pymajor}-config"
337 +}