Diff python-2.7.17-r1 with a python-3.6.9

/usr/portage/dev-lang/python/python-3.6.9.ebuild 2020-02-11 20:51:00.000000000 +0300
1 1
# Copyright 1999-2020 Gentoo Authors
2 2
# Distributed under the terms of the GNU General Public License v2
3 3

  
4
EAPI="7"
4
EAPI="6"
5 5
WANT_LIBTOOL="none"
6 6

  
7 7
inherit autotools flag-o-matic pax-utils python-utils-r1 toolchain-funcs
8 8

  
9 9
MY_P="Python-${PV}"
10
PYVER=$(ver_cut 1-2)
11
PATCHSET="python-gentoo-patches-2.7.17-r1"
10
PATCHSET_VERSION="3.6.8"
12 11

  
13 12
DESCRIPTION="An interpreted, interactive, object-oriented programming language"
14 13
HOMEPAGE="https://www.python.org/"
15 14
SRC_URI="https://www.python.org/ftp/python/${PV}/${MY_P}.tar.xz
16
	https://dev.gentoo.org/~mgorny/dist/python/${PATCHSET}.tar.xz"
17
S="${WORKDIR}/${MY_P}"
15
	https://dev.gentoo.org/~floppym/python/python-gentoo-patches-${PATCHSET_VERSION}.tar.xz"
18 16

  
19 17
LICENSE="PSF-2"
20
SLOT="${PYVER}"
21
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86"
22
IUSE="-berkdb bluetooth build elibc_uclibc examples gdbm hardened ipv6 libressl +ncurses +readline sqlite +ssl +threads tk +wide-unicode wininst +xml"
18
SLOT="3.6/3.6m"
19
KEYWORDS="~alpha amd64 arm arm64 hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86"
20
IUSE="bluetooth build examples gdbm hardened ipv6 libressl +ncurses +readline sqlite +ssl test +threads tk wininst +xml"
21
RESTRICT="!test? ( test )"
23 22

  
24 23
# Do not add a dependency on dev-lang/python to this ebuild.
25 24
# If you need to apply a patch which requires python for bootstrapping, please
26 25
# run the bootstrap code on your dev box and include the results in the
27 26
# patchset. See bug 447752.
28 27

  
29
RDEPEND="app-arch/bzip2:=
30
	>=sys-libs/zlib-1.1.3:=
31
	virtual/libcrypt:=
28
RDEPEND="app-arch/bzip2:0=
29
	app-arch/xz-utils:0=
30
	>=sys-libs/zlib-1.1.3:0=
32 31
	virtual/libffi:=
33 32
	virtual/libintl
34
	berkdb? ( || (
35
		sys-libs/db:5.3
36
		sys-libs/db:5.1
37
		sys-libs/db:4.8
38
		sys-libs/db:4.7
39
		sys-libs/db:4.6
40
		sys-libs/db:4.5
41
		sys-libs/db:4.4
42
		sys-libs/db:4.3
43
		sys-libs/db:4.2
44
	) )
45
	gdbm? ( sys-libs/gdbm:=[berkdb] )
46
	ncurses? ( >=sys-libs/ncurses-5.2:= )
47
	readline? ( >=sys-libs/readline-4.1:= )
33
	gdbm? ( sys-libs/gdbm:0=[berkdb] )
34
	ncurses? ( >=sys-libs/ncurses-5.2:0= )
35
	readline? ( >=sys-libs/readline-4.1:0= )
48 36
	sqlite? ( >=dev-db/sqlite-3.3.8:3= )
49 37
	ssl? (
50
		!libressl? ( dev-libs/openssl:= )
51
		libressl? ( dev-libs/libressl:= )
38
		!libressl? ( dev-libs/openssl:0= )
39
		libressl? ( dev-libs/libressl:0= )
52 40
	)
53 41
	tk? (
54
		>=dev-lang/tcl-8.0:=
55
		>=dev-lang/tk-8.0:=
56
		dev-tcltk/blt:=
42
		>=dev-lang/tcl-8.0:0=
43
		>=dev-lang/tk-8.0:0=
44
		dev-tcltk/blt:0=
57 45
		dev-tcltk/tix
58 46
	)
59
	xml? ( >=dev-libs/expat-2.1:= )"
47
	xml? ( >=dev-libs/expat-2.1:0= )"
60 48
# bluetooth requires headers from bluez
61 49
DEPEND="${RDEPEND}
62 50
	bluetooth? ( net-wireless/bluez )
51
	test? ( app-arch/xz-utils[extra-filters(+)] )
63 52
	virtual/pkgconfig
64 53
	!sys-devel/gcc[libffi(-)]"
65 54
RDEPEND+=" !build? ( app-misc/mime-types )"
66 55
PDEPEND=">=app-eselect/eselect-python-20140125-r1"
67 56

  
68
pkg_setup() {
69
	if use berkdb; then
70
		ewarn "'bsddb' module is out-of-date and no longer maintained inside"
71
		ewarn "dev-lang/python. 'bsddb' and 'dbhash' modules have been additionally"
72
		ewarn "removed in Python 3. A maintained alternative of 'bsddb3' module"
73
		ewarn "is provided by dev-python/bsddb3."
74
	else
75
		if has_version "=${CATEGORY}/${PN}-${PV%%.*}*[berkdb]"; then
76
			ewarn "You are migrating from =${CATEGORY}/${PN}-${PV%%.*}*[berkdb]"
77
			ewarn "to =${CATEGORY}/${PN}-${PV%%.*}*[-berkdb]."
78
			ewarn "You might need to migrate your databases."
79
		fi
80
	fi
81
}
57
S="${WORKDIR}/${MY_P}"
58
PYVER=${SLOT%/*}
82 59

  
83 60
src_prepare() {
84 61
	# Ensure that internal copies of expat, libffi and zlib are not used.
85
	rm -fr Modules/expat || die
86
	rm -fr Modules/_ctypes/libffi* || die
87
	rm -fr Modules/zlib || die
62
	rm -fr Modules/expat
63
	rm -fr Modules/_ctypes/libffi*
64
	rm -fr Modules/zlib
88 65

  
89 66
	local PATCHES=(
90
		"${WORKDIR}/${PATCHSET}"
67
		"${WORKDIR}/patches"
91 68
	)
92 69

  
93 70
	default
......
101 78
		Makefile.pre.in \
102 79
		Modules/Setup.dist \
103 80
		Modules/getpath.c \
81
		configure.ac \
104 82
		setup.py || die "sed failed to replace @@GENTOO_LIBDIR@@"
105 83

  
106 84
	eautoreconf
107 85
}
108 86

  
109 87
src_configure() {
110
	# dbm module can be linked against berkdb or gdbm.
111
	# Defaults to gdbm when both are enabled, #204343.
112 88
	local disable
113
	use berkdb    || use gdbm || disable+=" dbm"
114
	use berkdb    || disable+=" _bsddb"
115 89
	# disable automagic bluetooth headers detection
116 90
	use bluetooth || export ac_cv_header_bluetooth_bluetooth_h=no
117
	use gdbm      || disable+=" gdbm"
118
	use ncurses   || disable+=" _curses _curses_panel"
119
	use readline  || disable+=" readline"
120
	use sqlite    || disable+=" _sqlite3"
121
	use ssl       || export PYTHON_DISABLE_SSL="1"
122
	use tk        || disable+=" _tkinter"
123
	use xml       || disable+=" _elementtree pyexpat" # _elementtree uses pyexpat.
91
	use gdbm     || disable+=" gdbm"
92
	use ncurses  || disable+=" _curses _curses_panel"
93
	use readline || disable+=" readline"
94
	use sqlite   || disable+=" _sqlite3"
95
	use ssl      || export PYTHON_DISABLE_SSL="1"
96
	use tk       || disable+=" _tkinter"
97
	use xml      || disable+=" _elementtree pyexpat" # _elementtree uses pyexpat.
124 98
	export PYTHON_DISABLE_MODULES="${disable}"
125 99

  
126 100
	if ! use xml; then
......
145 119
		use hardened && replace-flags -O3 -O2
146 120
	fi
147 121

  
148
	if tc-is-cross-compiler; then
149
		# Force some tests that try to poke fs paths.
150
		export ac_cv_file__dev_ptc=no
151
		export ac_cv_file__dev_ptmx=yes
152
	fi
153

  
154
	# Export CXX so it ends up in /usr/lib/python2.X/config/Makefile.
122
	# Export CXX so it ends up in /usr/lib/python3.X/config/Makefile.
155 123
	tc-export CXX
156
	# The configure script fails to use pkg-config correctly.
157
	# http://bugs.python.org/issue15506
158
	export ac_cv_path_PKG_CONFIG=$(tc-getPKG_CONFIG)
159 124

  
160
	# Set LDFLAGS so we link modules with -lpython2.7 correctly.
161
	# Needed on FreeBSD unless Python 2.7 is already installed.
125
	# Set LDFLAGS so we link modules with -lpython3.2 correctly.
126
	# Needed on FreeBSD unless Python 3.2 is already installed.
162 127
	# Please query BSD team before removing this!
163 128
	append-ldflags "-L."
164 129

  
......
166 131
	if use gdbm; then
167 132
		dbmliborder+="${dbmliborder:+:}gdbm"
168 133
	fi
169
	if use berkdb; then
170
		dbmliborder+="${dbmliborder:+:}bdb"
171
	fi
172 134

  
173 135
	local myeconfargs=(
174
		# The check is broken on clang, and gives false positive:
175
		# https://bugs.gentoo.org/596798
176
		# (upstream dropped this flag in 3.2a4 anyway)
177
		ac_cv_opt_olimit_ok=no
178

  
179 136
		--with-fpectl
180 137
		--enable-shared
181 138
		$(use_enable ipv6)
182 139
		$(use_with threads)
183
		$(use wide-unicode && echo "--enable-unicode=ucs4" || echo "--enable-unicode=ucs2")
184 140
		--infodir='${prefix}/share/info'
185 141
		--mandir='${prefix}/share/man'
186 142
		--with-computed-gotos
187 143
		--with-dbmliborder="${dbmliborder}"
188 144
		--with-libc=
189 145
		--enable-loadable-sqlite-extensions
146
		--without-ensurepip
190 147
		--with-system-expat
191 148
		--with-system-ffi
192
		--without-ensurepip
193 149
	)
194 150

  
195 151
	OPT="" econf "${myeconfargs[@]}"
......
206 162
	# https://bugs.gentoo.org/594768
207 163
	local -x LC_ALL=C
208 164

  
209
	# Avoid invoking pgen for cross-compiles.
210
	touch Include/graminit.h Python/graminit.c
211

  
212
	emake
165
	emake CPPFLAGS= CFLAGS= LDFLAGS=
213 166

  
214 167
	# Work around bug 329499. See also bug 413751 and 457194.
215 168
	if has_version dev-libs/libffi[pax_kernel]; then
......
227 180
	fi
228 181

  
229 182
	# Skip failing tests.
230
	local skipped_tests="distutils gdb"
183
	local skipped_tests="gdb"
231 184

  
232 185
	for test in ${skipped_tests}; do
233 186
		mv "${S}"/Lib/test/test_${test}.py "${T}"
......
236 189
	# bug 660358
237 190
	local -x COLUMNS=80
238 191

  
239
	# Daylight saving time problem
240
	# https://bugs.python.org/issue22067
241
	# https://bugs.gentoo.org/610628
242
	local -x TZ=UTC
243

  
244
	# Rerun failed tests in verbose mode (regrtest -w).
245
	emake test EXTRATESTOPTS="-w" < /dev/tty
246
	local result="$?"
192
	local -x PYTHONDONTWRITEBYTECODE=
193

  
194
	emake test EXTRATESTOPTS="-u-network" CPPFLAGS= CFLAGS= LDFLAGS= < /dev/tty
195
	local result=$?
247 196

  
248 197
	for test in ${skipped_tests}; do
249 198
		mv "${T}/test_${test}.py" "${S}"/Lib/test
......
268 217

  
269 218
	emake DESTDIR="${D}" altinstall
270 219

  
271
	sed -e "s/\(LDFLAGS=\).*/\1/" -i "${libdir}/config/Makefile" || die
220
	sed \
221
		-e "s/\(CONFIGURE_LDFLAGS=\).*/\1/" \
222
		-e "s/\(PY_LDFLAGS=\).*/\1/" \
223
		-i "${libdir}/config-${PYVER}"*/Makefile || die "sed failed"
272 224

  
273 225
	# Fix collisions between different slots of Python.
274
	mv "${ED}/usr/bin/2to3" "${ED}/usr/bin/2to3-${PYVER}" || die
275
	mv "${ED}/usr/bin/pydoc" "${ED}/usr/bin/pydoc${PYVER}" || die
276
	mv "${ED}/usr/bin/idle" "${ED}/usr/bin/idle${PYVER}" || die
277
	rm "${ED}/usr/bin/smtpd.py" || die
226
	rm -f "${ED}usr/$(get_libdir)/libpython3.so"
227

  
228
	# Cheap hack to get version with ABIFLAGS
229
	local abiver=$(cd "${ED}usr/include"; echo python*)
230
	if [[ ${abiver} != python${PYVER} ]]; then
231
		# Replace python3.X with a symlink to python3.Xm
232
		rm "${ED}usr/bin/python${PYVER}" || die
233
		dosym "${abiver}" "/usr/bin/python${PYVER}"
234
		# Create python3.X-config symlink
235
		dosym "${abiver}-config" "/usr/bin/python${PYVER}-config"
236
		# Create python-3.5m.pc symlink
237
		dosym "python-${PYVER}.pc" "/usr/$(get_libdir)/pkgconfig/${abiver/${PYVER}/-${PYVER}}.pc"
238
	fi
239

  
240
	# python seems to get rebuilt in src_install (bug 569908)
241
	# Work around it for now.
242
	if has_version dev-libs/libffi[pax_kernel]; then
243
		pax-mark E "${ED}usr/bin/${abiver}"
244
	else
245
		pax-mark m "${ED}usr/bin/${abiver}"
246
	fi
278 247

  
279
	use berkdb || rm -r "${libdir}/"{bsddb,dbhash.py*,test/test_bsddb*} || die
280 248
	use sqlite || rm -r "${libdir}/"{sqlite3,test/test_sqlite*} || die
281
	use tk || rm -r "${ED}/usr/bin/idle${PYVER}" "${libdir}/"{idlelib,lib-tk} || die
282
	use elibc_uclibc && rm -fr "${libdir}/"{bsddb/test,test}
249
	use tk || rm -r "${ED}usr/bin/idle${PYVER}" "${libdir}/"{idlelib,tkinter,test/test_tk*} || die
283 250

  
284 251
	use threads || rm -r "${libdir}/multiprocessing" || die
285 252
	use wininst || rm "${libdir}/distutils/command/"wininst-*.exe || die
286 253

  
287
	dodoc Misc/{ACKS,HISTORY,NEWS}
254
	dodoc "${S}"/Misc/{ACKS,HISTORY,NEWS}
288 255

  
289 256
	if use examples; then
290
		docinto examples
291
		dodoc -r Tools
257
		insinto /usr/share/doc/${PF}/examples
258
		find "${S}"/Tools -name __pycache__ -print0 | xargs -0 rm -fr
259
		doins -r "${S}"/Tools
292 260
	fi
293 261
	insinto /usr/share/gdb/auto-load/usr/$(get_libdir) #443510
294 262
	local libname=$(printf 'e:\n\t@echo $(INSTSONAME)\ninclude Makefile\n' | \
......
300 268
	sed \
301 269
		-e "s:@PYDOC_PORT_VARIABLE@:PYDOC${PYVER/./_}_PORT:" \
302 270
		-e "s:@PYDOC@:pydoc${PYVER}:" \
303
		-i "${ED}/etc/conf.d/pydoc-${PYVER}" \
304
		"${ED}/etc/init.d/pydoc-${PYVER}" || die "sed failed"
271
		-i "${ED}etc/conf.d/pydoc-${PYVER}" "${ED}etc/init.d/pydoc-${PYVER}" || die "sed failed"
305 272

  
306 273
	# for python-exec
307 274
	local vars=( EPYTHON PYTHON_SITEDIR PYTHON_SCRIPTDIR )
......
322 289
	local pymajor=${PYVER%.*}
323 290
	mkdir -p "${D}${PYTHON_SCRIPTDIR}" || die
324 291
	# python and pythonX
325
	ln -s "../../../bin/python${PYVER}" \
292
	ln -s "../../../bin/${abiver}" \
326 293
		"${D}${PYTHON_SCRIPTDIR}/python${pymajor}" || die
327
	ln -s "python${pymajor}" "${D}${PYTHON_SCRIPTDIR}/python" || die
294
	ln -s "python${pymajor}" \
295
		"${D}${PYTHON_SCRIPTDIR}/python" || die
328 296
	# python-config and pythonX-config
329
	ln -s "../../../bin/python${PYVER}-config" \
330
		"${D}${PYTHON_SCRIPTDIR}/python${pymajor}-config" || die
297
	# note: we need to create a wrapper rather than symlinking it due
298
	# to some random dirname(argv[0]) magic performed by python-config
299
	cat > "${D}${PYTHON_SCRIPTDIR}/python${pymajor}-config" <<-EOF || die
300
		#!/bin/sh
301
		exec "${abiver}-config" "\${@}"
302
	EOF
303
	chmod +x "${D}${PYTHON_SCRIPTDIR}/python${pymajor}-config" || die
331 304
	ln -s "python${pymajor}-config" \
332 305
		"${D}${PYTHON_SCRIPTDIR}/python-config" || die
333 306
	# 2to3, pydoc, pyvenv
......
335 308
		"${D}${PYTHON_SCRIPTDIR}/2to3" || die
336 309
	ln -s "../../../bin/pydoc${PYVER}" \
337 310
		"${D}${PYTHON_SCRIPTDIR}/pydoc" || die
311
	ln -s "../../../bin/pyvenv-${PYVER}" \
312
		"${D}${PYTHON_SCRIPTDIR}/pyvenv" || die
338 313
	# idle
339 314
	if use tk; then
340 315
		ln -s "../../../bin/idle${PYVER}" \
......
342 317
	fi
343 318
}
344 319

  
320
pkg_preinst() {
321
	if has_version "<${CATEGORY}/${PN}-${PYVER}" && ! has_version ">=${CATEGORY}/${PN}-${PYVER}_alpha"; then
322
		python_updater_warning="1"
323
	fi
324
}
325

  
345 326
eselect_python_update() {
346
	if [[ -z "$(eselect python show)" || \
347
			! -f "${EROOT}/usr/bin/$(eselect python show)" ]]; then
327
	if [[ -z "$(eselect python show)" || ! -f "${EROOT}usr/bin/$(eselect python show)" ]]; then
348 328
		eselect python update
349 329
	fi
350 330

  
351
	if [[ -z "$(eselect python show --python${PV%%.*})" || \
352
			! -f "${EROOT}/usr/bin/$(eselect python show --python${PV%%.*})" ]]
353
	then
331
	if [[ -z "$(eselect python show --python${PV%%.*})" || ! -f "${EROOT}usr/bin/$(eselect python show --python${PV%%.*})" ]]; then
354 332
		eselect python update --python${PV%%.*}
355 333
	fi
356 334
}
357 335

  
358 336
pkg_postinst() {
359 337
	eselect_python_update
338

  
339
	if [[ "${python_updater_warning}" == "1" ]]; then
340
		ewarn "You have just upgraded from an older version of Python."
341
		ewarn
342
		ewarn "Please adjust PYTHON_TARGETS (if so desired), and run emerge with the --newuse or --changed-use option to rebuild packages installing python modules."
343
	fi
360 344
}
361 345

  
362 346
pkg_postrm() {
Thank you!