Mike Frysinger | 432f289 | 2021-02-19 15:22:02 -0500 | [diff] [blame] | 1 | # Copyright 1999-2020 Gentoo Authors |
Chad Versace | 9c71f3c | 2018-10-24 16:49:31 -0700 | [diff] [blame] | 2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | |
Mike Frysinger | 0e24516 | 2021-02-19 15:39:45 -0500 | [diff] [blame^] | 4 | EAPI="7" |
Chad Versace | 9c71f3c | 2018-10-24 16:49:31 -0700 | [diff] [blame] | 5 | WANT_LIBTOOL="none" |
| 6 | |
| 7 | inherit autotools flag-o-matic pax-utils python-utils-r1 toolchain-funcs |
| 8 | |
| 9 | MY_P="Python-${PV}" |
Mike Frysinger | 0e24516 | 2021-02-19 15:39:45 -0500 | [diff] [blame^] | 10 | PYVER=$(ver_cut 1-2) |
| 11 | PATCHSET="python-gentoo-patches-3.6.10" |
Chad Versace | 9c71f3c | 2018-10-24 16:49:31 -0700 | [diff] [blame] | 12 | |
| 13 | DESCRIPTION="An interpreted, interactive, object-oriented programming language" |
| 14 | HOMEPAGE="https://www.python.org/" |
| 15 | SRC_URI="https://www.python.org/ftp/python/${PV}/${MY_P}.tar.xz |
Mike Frysinger | 0e24516 | 2021-02-19 15:39:45 -0500 | [diff] [blame^] | 16 | https://dev.gentoo.org/~mgorny/dist/python/${PATCHSET}.tar.xz" |
| 17 | S="${WORKDIR}/${MY_P}" |
Chad Versace | 9c71f3c | 2018-10-24 16:49:31 -0700 | [diff] [blame] | 18 | |
| 19 | LICENSE="PSF-2" |
Mike Frysinger | 0e24516 | 2021-02-19 15:39:45 -0500 | [diff] [blame^] | 20 | SLOT="${PYVER}/${PYVER}m" |
Daniel Campello | 7ded4e3 | 2019-02-06 11:03:46 -0700 | [diff] [blame] | 21 | KEYWORDS="*" |
Mike Frysinger | 432f289 | 2021-02-19 15:22:02 -0500 | [diff] [blame] | 22 | IUSE="bluetooth build examples gdbm hardened ipv6 libressl +ncurses +readline sqlite +ssl test +threads tk wininst +xml" |
Chad Versace | 9c71f3c | 2018-10-24 16:49:31 -0700 | [diff] [blame] | 23 | RESTRICT="!test? ( test )" |
| 24 | |
| 25 | # Do not add a dependency on dev-lang/python to this ebuild. |
| 26 | # If you need to apply a patch which requires python for bootstrapping, please |
| 27 | # run the bootstrap code on your dev box and include the results in the |
| 28 | # patchset. See bug 447752. |
| 29 | |
Mike Frysinger | 0e24516 | 2021-02-19 15:39:45 -0500 | [diff] [blame^] | 30 | RDEPEND="app-arch/bzip2:= |
| 31 | app-arch/xz-utils:= |
Mike Frysinger | 432f289 | 2021-02-19 15:22:02 -0500 | [diff] [blame] | 32 | dev-libs/libffi:= |
Mike Frysinger | 0e24516 | 2021-02-19 15:39:45 -0500 | [diff] [blame^] | 33 | >=sys-libs/zlib-1.1.3:= |
| 34 | virtual/libcrypt:= |
Chad Versace | 9c71f3c | 2018-10-24 16:49:31 -0700 | [diff] [blame] | 35 | virtual/libintl |
Mike Frysinger | 0e24516 | 2021-02-19 15:39:45 -0500 | [diff] [blame^] | 36 | gdbm? ( sys-libs/gdbm:=[berkdb] ) |
| 37 | ncurses? ( >=sys-libs/ncurses-5.2:= ) |
| 38 | readline? ( >=sys-libs/readline-4.1:= ) |
Chad Versace | 9c71f3c | 2018-10-24 16:49:31 -0700 | [diff] [blame] | 39 | sqlite? ( >=dev-db/sqlite-3.3.8:3= ) |
| 40 | ssl? ( |
Mike Frysinger | 0e24516 | 2021-02-19 15:39:45 -0500 | [diff] [blame^] | 41 | !libressl? ( dev-libs/openssl:= ) |
| 42 | libressl? ( dev-libs/libressl:= ) |
Chad Versace | 9c71f3c | 2018-10-24 16:49:31 -0700 | [diff] [blame] | 43 | ) |
| 44 | tk? ( |
Mike Frysinger | 0e24516 | 2021-02-19 15:39:45 -0500 | [diff] [blame^] | 45 | >=dev-lang/tcl-8.0:= |
| 46 | >=dev-lang/tk-8.0:= |
| 47 | dev-tcltk/blt:= |
Chad Versace | 9c71f3c | 2018-10-24 16:49:31 -0700 | [diff] [blame] | 48 | dev-tcltk/tix |
| 49 | ) |
Mike Frysinger | 0e24516 | 2021-02-19 15:39:45 -0500 | [diff] [blame^] | 50 | xml? ( >=dev-libs/expat-2.1:= )" |
Mike Frysinger | 432f289 | 2021-02-19 15:22:02 -0500 | [diff] [blame] | 51 | # bluetooth requires headers from bluez |
Chad Versace | 9c71f3c | 2018-10-24 16:49:31 -0700 | [diff] [blame] | 52 | DEPEND="${RDEPEND} |
Mike Frysinger | 432f289 | 2021-02-19 15:22:02 -0500 | [diff] [blame] | 53 | bluetooth? ( net-wireless/bluez ) |
Chad Versace | 9c71f3c | 2018-10-24 16:49:31 -0700 | [diff] [blame] | 54 | test? ( app-arch/xz-utils[extra-filters(+)] ) |
| 55 | virtual/pkgconfig |
| 56 | !sys-devel/gcc[libffi(-)]" |
| 57 | RDEPEND+=" !build? ( app-misc/mime-types )" |
| 58 | PDEPEND=">=app-eselect/eselect-python-20140125-r1" |
| 59 | |
Chad Versace | 9c71f3c | 2018-10-24 16:49:31 -0700 | [diff] [blame] | 60 | src_prepare() { |
| 61 | # Ensure that internal copies of expat, libffi and zlib are not used. |
Mike Frysinger | 0e24516 | 2021-02-19 15:39:45 -0500 | [diff] [blame^] | 62 | rm -fr Modules/expat || die |
| 63 | rm -fr Modules/_ctypes/libffi* || die |
| 64 | rm -fr Modules/zlib || die |
Chad Versace | 9c71f3c | 2018-10-24 16:49:31 -0700 | [diff] [blame] | 65 | |
Mike Frysinger | 95c720e | 2021-02-19 15:09:00 -0500 | [diff] [blame] | 66 | local PATCHES=( |
Mike Frysinger | 0e24516 | 2021-02-19 15:39:45 -0500 | [diff] [blame^] | 67 | "${WORKDIR}/${PATCHSET}" |
| 68 | "${FILESDIR}/test.support.unlink-ignore-PermissionError.patch" |
Mike Frysinger | 95c720e | 2021-02-19 15:09:00 -0500 | [diff] [blame] | 69 | ) |
Chad Versace | 9c71f3c | 2018-10-24 16:49:31 -0700 | [diff] [blame] | 70 | |
Mike Frysinger | 95c720e | 2021-02-19 15:09:00 -0500 | [diff] [blame] | 71 | default |
Chad Versace | 9c71f3c | 2018-10-24 16:49:31 -0700 | [diff] [blame] | 72 | |
| 73 | # START: Chromium OS |
Mike Frysinger | ce0b8c0 | 2019-07-11 00:40:18 -0400 | [diff] [blame] | 74 | if tc-is-cross-compiler ; then |
Mike Frysinger | 0e24516 | 2021-02-19 15:39:45 -0500 | [diff] [blame^] | 75 | eapply "${FILESDIR}/python-3.6.5-cross-h2py.patch" |
| 76 | eapply "${FILESDIR}/python-3.6.5-cross-hack-compiler.patch" |
Mike Frysinger | ce0b8c0 | 2019-07-11 00:40:18 -0400 | [diff] [blame] | 77 | fi |
Mike Frysinger | 0e24516 | 2021-02-19 15:39:45 -0500 | [diff] [blame^] | 78 | eapply "${FILESDIR}/python-3.6.5-cross-python-config.patch" |
| 79 | eapply "${FILESDIR}/python-3.6.5-cross-setup-sysroot.patch" |
| 80 | eapply "${FILESDIR}/python-3.6.5-cross-distutils.patch" |
| 81 | eapply "${FILESDIR}/python-3.6.5-cross-sysconfig.patch" |
| 82 | eapply "${FILESDIR}/python-3.6.5-ldshared.patch" |
| 83 | eapply "${FILESDIR}/python-3.6.5-system-libffi.patch" |
| 84 | eapply "${FILESDIR}/python-3.6.5-sigint-handler.patch" |
Chad Versace | 9c71f3c | 2018-10-24 16:49:31 -0700 | [diff] [blame] | 85 | |
| 86 | # Undo the @libdir@ change for portage's pym folder as it is always |
| 87 | # installed into /usr/lib/ and not the abi libdir. |
| 88 | sed -i \ |
| 89 | -e '/portage.*pym/s:@@GENTOO_LIBDIR@@:lib:g' \ |
| 90 | Lib/site.py || die |
| 91 | |
| 92 | sed -i -e "s:sys.exec_prefix]:sys.exec_prefix, '/usr/local']:g" \ |
| 93 | Lib/site.py || die "sed failed to add /usr/local to prefixes" |
| 94 | # END: Chromium OS |
| 95 | |
| 96 | sed -i -e "s:@@GENTOO_LIBDIR@@:$(get_libdir):g" \ |
| 97 | Lib/distutils/command/install.py \ |
| 98 | Lib/distutils/sysconfig.py \ |
| 99 | Lib/site.py \ |
| 100 | Lib/sysconfig.py \ |
| 101 | Lib/test/test_site.py \ |
| 102 | Makefile.pre.in \ |
| 103 | Modules/Setup.dist \ |
| 104 | Modules/getpath.c \ |
| 105 | configure.ac \ |
| 106 | setup.py || die "sed failed to replace @@GENTOO_LIBDIR@@" |
| 107 | |
| 108 | eautoreconf |
| 109 | } |
| 110 | |
| 111 | src_configure() { |
| 112 | local disable |
Mike Frysinger | 432f289 | 2021-02-19 15:22:02 -0500 | [diff] [blame] | 113 | # disable automagic bluetooth headers detection |
| 114 | use bluetooth || export ac_cv_header_bluetooth_bluetooth_h=no |
Mike Frysinger | 0e24516 | 2021-02-19 15:39:45 -0500 | [diff] [blame^] | 115 | use gdbm || disable+=" gdbm" |
| 116 | use ncurses || disable+=" _curses _curses_panel" |
| 117 | use readline || disable+=" readline" |
| 118 | use sqlite || disable+=" _sqlite3" |
| 119 | use ssl || export PYTHON_DISABLE_SSL="1" |
| 120 | use tk || disable+=" _tkinter" |
| 121 | use xml || disable+=" _elementtree pyexpat" # _elementtree uses pyexpat. |
Chad Versace | 9c71f3c | 2018-10-24 16:49:31 -0700 | [diff] [blame] | 122 | export PYTHON_DISABLE_MODULES="${disable}" |
| 123 | |
| 124 | if ! use xml; then |
| 125 | ewarn "You have configured Python without XML support." |
| 126 | ewarn "This is NOT a recommended configuration as you" |
| 127 | ewarn "may face problems parsing any XML documents." |
| 128 | fi |
| 129 | |
| 130 | if [[ -n "${PYTHON_DISABLE_MODULES}" ]]; then |
| 131 | einfo "Disabled modules: ${PYTHON_DISABLE_MODULES}" |
| 132 | fi |
| 133 | |
| 134 | if [[ "$(gcc-major-version)" -ge 4 ]]; then |
| 135 | append-flags -fwrapv |
| 136 | fi |
| 137 | |
| 138 | filter-flags -malign-double |
| 139 | |
| 140 | # https://bugs.gentoo.org/show_bug.cgi?id=50309 |
| 141 | if is-flagq -O3; then |
| 142 | is-flagq -fstack-protector-all && replace-flags -O3 -O2 |
| 143 | use hardened && replace-flags -O3 -O2 |
| 144 | fi |
| 145 | |
| 146 | # Export CXX so it ends up in /usr/lib/python3.X/config/Makefile. |
| 147 | tc-export CXX |
| 148 | |
| 149 | # Set LDFLAGS so we link modules with -lpython3.2 correctly. |
| 150 | # Needed on FreeBSD unless Python 3.2 is already installed. |
| 151 | # Please query BSD team before removing this! |
| 152 | append-ldflags "-L." |
| 153 | |
Mike Frysinger | ce0b8c0 | 2019-07-11 00:40:18 -0400 | [diff] [blame] | 154 | tc-export CC |
| 155 | |
Chad Versace | 9c71f3c | 2018-10-24 16:49:31 -0700 | [diff] [blame] | 156 | local dbmliborder |
| 157 | if use gdbm; then |
| 158 | dbmliborder+="${dbmliborder:+:}gdbm" |
| 159 | fi |
| 160 | |
| 161 | local myeconfargs=( |
Mike Frysinger | 0e24516 | 2021-02-19 15:39:45 -0500 | [diff] [blame^] | 162 | # glibc-2.30 removes it; since we can't cleanly force-rebuild |
| 163 | # Python on glibc upgrade, remove it proactively to give |
| 164 | # a chance for users rebuilding python before glibc |
| 165 | ac_cv_header_stropts_h=no |
| 166 | |
Chad Versace | 9c71f3c | 2018-10-24 16:49:31 -0700 | [diff] [blame] | 167 | --with-fpectl |
| 168 | --enable-shared |
| 169 | $(use_enable ipv6) |
| 170 | $(use_with threads) |
| 171 | --infodir='${prefix}/share/info' |
| 172 | --mandir='${prefix}/share/man' |
| 173 | --with-computed-gotos |
| 174 | --with-dbmliborder="${dbmliborder}" |
| 175 | --with-libc= |
| 176 | --enable-loadable-sqlite-extensions |
| 177 | --without-ensurepip |
| 178 | --with-system-expat |
| 179 | --with-system-ffi |
| 180 | ) |
| 181 | |
| 182 | OPT="" econf "${myeconfargs[@]}" |
| 183 | |
| 184 | if use threads && grep -q "#define POSIX_SEMAPHORES_NOT_ENABLED 1" pyconfig.h; then |
| 185 | eerror "configure has detected that the sem_open function is broken." |
| 186 | eerror "Please ensure that /dev/shm is mounted as a tmpfs with mode 1777." |
| 187 | die "Broken sem_open function (bug 496328)" |
| 188 | fi |
| 189 | } |
| 190 | |
| 191 | src_compile() { |
| 192 | # Ensure sed works as expected |
| 193 | # https://bugs.gentoo.org/594768 |
| 194 | local -x LC_ALL=C |
| 195 | |
| 196 | emake CPPFLAGS= CFLAGS= LDFLAGS= |
| 197 | |
| 198 | # Work around bug 329499. See also bug 413751 and 457194. |
| 199 | if has_version dev-libs/libffi[pax_kernel]; then |
| 200 | pax-mark E python |
| 201 | else |
| 202 | pax-mark m python |
| 203 | fi |
| 204 | } |
| 205 | |
| 206 | src_test() { |
| 207 | # Tests will not work when cross compiling. |
| 208 | if tc-is-cross-compiler; then |
| 209 | elog "Disabling tests due to crosscompiling." |
| 210 | return |
| 211 | fi |
| 212 | |
| 213 | # Skip failing tests. |
| 214 | local skipped_tests="gdb" |
| 215 | |
| 216 | for test in ${skipped_tests}; do |
| 217 | mv "${S}"/Lib/test/test_${test}.py "${T}" |
| 218 | done |
| 219 | |
Mike Frysinger | 432f289 | 2021-02-19 15:22:02 -0500 | [diff] [blame] | 220 | # bug 660358 |
| 221 | local -x COLUMNS=80 |
| 222 | |
Chad Versace | 9c71f3c | 2018-10-24 16:49:31 -0700 | [diff] [blame] | 223 | local -x PYTHONDONTWRITEBYTECODE= |
| 224 | |
| 225 | emake test EXTRATESTOPTS="-u-network" CPPFLAGS= CFLAGS= LDFLAGS= < /dev/tty |
| 226 | local result=$? |
| 227 | |
| 228 | for test in ${skipped_tests}; do |
| 229 | mv "${T}/test_${test}.py" "${S}"/Lib/test |
| 230 | done |
| 231 | |
| 232 | elog "The following tests have been skipped:" |
| 233 | for test in ${skipped_tests}; do |
| 234 | elog "test_${test}.py" |
| 235 | done |
| 236 | |
| 237 | elog "If you would like to run them, you may:" |
| 238 | elog "cd '${EPREFIX}/usr/$(get_libdir)/python${PYVER}/test'" |
| 239 | elog "and run the tests separately." |
| 240 | |
| 241 | if [[ ${result} -ne 0 ]]; then |
| 242 | die "emake test failed" |
| 243 | fi |
| 244 | } |
| 245 | |
| 246 | src_install() { |
| 247 | local libdir=${ED}/usr/$(get_libdir)/python${PYVER} |
| 248 | |
| 249 | emake DESTDIR="${D}" altinstall |
| 250 | |
Mike Frysinger | 0e24516 | 2021-02-19 15:39:45 -0500 | [diff] [blame^] | 251 | # Remove static library |
| 252 | rm "${ED}"/usr/$(get_libdir)/libpython*.a || die |
| 253 | |
Chad Versace | 9c71f3c | 2018-10-24 16:49:31 -0700 | [diff] [blame] | 254 | sed \ |
| 255 | -e "s/\(CONFIGURE_LDFLAGS=\).*/\1/" \ |
| 256 | -e "s/\(PY_LDFLAGS=\).*/\1/" \ |
| 257 | -i "${libdir}/config-${PYVER}"*/Makefile || die "sed failed" |
| 258 | |
| 259 | # Fix collisions between different slots of Python. |
Mike Frysinger | 0e24516 | 2021-02-19 15:39:45 -0500 | [diff] [blame^] | 260 | rm "${ED}/usr/$(get_libdir)/libpython3.so" || die |
Chad Versace | 9c71f3c | 2018-10-24 16:49:31 -0700 | [diff] [blame] | 261 | |
| 262 | # Cheap hack to get version with ABIFLAGS |
Mike Frysinger | 0e24516 | 2021-02-19 15:39:45 -0500 | [diff] [blame^] | 263 | local abiver=$(cd "${ED}/usr/include"; echo python*) |
Chad Versace | 9c71f3c | 2018-10-24 16:49:31 -0700 | [diff] [blame] | 264 | if [[ ${abiver} != python${PYVER} ]]; then |
| 265 | # Replace python3.X with a symlink to python3.Xm |
Mike Frysinger | 0e24516 | 2021-02-19 15:39:45 -0500 | [diff] [blame^] | 266 | rm "${ED}/usr/bin/python${PYVER}" || die |
Chad Versace | 9c71f3c | 2018-10-24 16:49:31 -0700 | [diff] [blame] | 267 | dosym "${abiver}" "/usr/bin/python${PYVER}" |
| 268 | # Create python3.X-config symlink |
| 269 | dosym "${abiver}-config" "/usr/bin/python${PYVER}-config" |
| 270 | # Create python-3.5m.pc symlink |
| 271 | dosym "python-${PYVER}.pc" "/usr/$(get_libdir)/pkgconfig/${abiver/${PYVER}/-${PYVER}}.pc" |
| 272 | fi |
| 273 | |
| 274 | # python seems to get rebuilt in src_install (bug 569908) |
| 275 | # Work around it for now. |
| 276 | if has_version dev-libs/libffi[pax_kernel]; then |
Mike Frysinger | 0e24516 | 2021-02-19 15:39:45 -0500 | [diff] [blame^] | 277 | pax-mark E "${ED}/usr/bin/${abiver}" |
Chad Versace | 9c71f3c | 2018-10-24 16:49:31 -0700 | [diff] [blame] | 278 | else |
Mike Frysinger | 0e24516 | 2021-02-19 15:39:45 -0500 | [diff] [blame^] | 279 | pax-mark m "${ED}/usr/bin/${abiver}" |
Chad Versace | 9c71f3c | 2018-10-24 16:49:31 -0700 | [diff] [blame] | 280 | fi |
| 281 | |
| 282 | use sqlite || rm -r "${libdir}/"{sqlite3,test/test_sqlite*} || die |
Mike Frysinger | 0e24516 | 2021-02-19 15:39:45 -0500 | [diff] [blame^] | 283 | use tk || rm -r "${ED}/usr/bin/idle${PYVER}" "${libdir}/"{idlelib,tkinter,test/test_tk*} || die |
Chad Versace | 9c71f3c | 2018-10-24 16:49:31 -0700 | [diff] [blame] | 284 | |
| 285 | use threads || rm -r "${libdir}/multiprocessing" || die |
| 286 | use wininst || rm "${libdir}/distutils/command/"wininst-*.exe || die |
| 287 | |
Mike Frysinger | 0e24516 | 2021-02-19 15:39:45 -0500 | [diff] [blame^] | 288 | dodoc Misc/{ACKS,HISTORY,NEWS} |
Chad Versace | 9c71f3c | 2018-10-24 16:49:31 -0700 | [diff] [blame] | 289 | |
| 290 | if use examples; then |
Mike Frysinger | 0e24516 | 2021-02-19 15:39:45 -0500 | [diff] [blame^] | 291 | docinto examples |
| 292 | find Tools -name __pycache__ -exec rm -fr {} + || die |
| 293 | dodoc -r Tools |
Chad Versace | 9c71f3c | 2018-10-24 16:49:31 -0700 | [diff] [blame] | 294 | fi |
| 295 | insinto /usr/share/gdb/auto-load/usr/$(get_libdir) #443510 |
| 296 | local libname=$(printf 'e:\n\t@echo $(INSTSONAME)\ninclude Makefile\n' | \ |
| 297 | emake --no-print-directory -s -f - 2>/dev/null) |
| 298 | newins "${S}"/Tools/gdb/libpython.py "${libname}"-gdb.py |
| 299 | |
| 300 | newconfd "${FILESDIR}/pydoc.conf" pydoc-${PYVER} |
| 301 | newinitd "${FILESDIR}/pydoc.init" pydoc-${PYVER} |
| 302 | sed \ |
| 303 | -e "s:@PYDOC_PORT_VARIABLE@:PYDOC${PYVER/./_}_PORT:" \ |
| 304 | -e "s:@PYDOC@:pydoc${PYVER}:" \ |
Mike Frysinger | 0e24516 | 2021-02-19 15:39:45 -0500 | [diff] [blame^] | 305 | -i "${ED}/etc/conf.d/pydoc-${PYVER}" \ |
| 306 | "${ED}/etc/init.d/pydoc-${PYVER}" || die "sed failed" |
Chad Versace | 9c71f3c | 2018-10-24 16:49:31 -0700 | [diff] [blame] | 307 | |
| 308 | # for python-exec |
| 309 | local vars=( EPYTHON PYTHON_SITEDIR PYTHON_SCRIPTDIR ) |
| 310 | |
| 311 | # if not using a cross-compiler, use the fresh binary |
| 312 | if ! tc-is-cross-compiler; then |
| 313 | local -x PYTHON=./python |
| 314 | local -x LD_LIBRARY_PATH=${LD_LIBRARY_PATH+${LD_LIBRARY_PATH}:}${PWD} |
| 315 | else |
| 316 | vars=( PYTHON "${vars[@]}" ) |
| 317 | fi |
| 318 | |
| 319 | python_export "python${PYVER}" "${vars[@]}" |
| 320 | echo "EPYTHON='${EPYTHON}'" > epython.py || die |
| 321 | python_domodule epython.py |
| 322 | |
| 323 | # python-exec wrapping support |
| 324 | local pymajor=${PYVER%.*} |
| 325 | mkdir -p "${D}${PYTHON_SCRIPTDIR}" || die |
| 326 | # python and pythonX |
| 327 | ln -s "../../../bin/${abiver}" \ |
| 328 | "${D}${PYTHON_SCRIPTDIR}/python${pymajor}" || die |
Mike Frysinger | 0e24516 | 2021-02-19 15:39:45 -0500 | [diff] [blame^] | 329 | ln -s "python${pymajor}" "${D}${PYTHON_SCRIPTDIR}/python" || die |
Chad Versace | 9c71f3c | 2018-10-24 16:49:31 -0700 | [diff] [blame] | 330 | # python-config and pythonX-config |
| 331 | # note: we need to create a wrapper rather than symlinking it due |
| 332 | # to some random dirname(argv[0]) magic performed by python-config |
| 333 | cat > "${D}${PYTHON_SCRIPTDIR}/python${pymajor}-config" <<-EOF || die |
| 334 | #!/bin/sh |
| 335 | exec "${abiver}-config" "\${@}" |
| 336 | EOF |
| 337 | chmod +x "${D}${PYTHON_SCRIPTDIR}/python${pymajor}-config" || die |
| 338 | ln -s "python${pymajor}-config" \ |
| 339 | "${D}${PYTHON_SCRIPTDIR}/python-config" || die |
| 340 | # 2to3, pydoc, pyvenv |
| 341 | ln -s "../../../bin/2to3-${PYVER}" \ |
| 342 | "${D}${PYTHON_SCRIPTDIR}/2to3" || die |
| 343 | ln -s "../../../bin/pydoc${PYVER}" \ |
| 344 | "${D}${PYTHON_SCRIPTDIR}/pydoc" || die |
| 345 | ln -s "../../../bin/pyvenv-${PYVER}" \ |
| 346 | "${D}${PYTHON_SCRIPTDIR}/pyvenv" || die |
| 347 | # idle |
| 348 | if use tk; then |
| 349 | ln -s "../../../bin/idle${PYVER}" \ |
| 350 | "${D}${PYTHON_SCRIPTDIR}/idle" || die |
| 351 | fi |
Mike Frysinger | 12f1f69 | 2021-02-13 18:32:43 -0500 | [diff] [blame] | 352 | |
| 353 | # Delete unittests as they are a waste of space and are unused. |
| 354 | rm -rf "${libdir}/test" "${libdir}"/{ctypes,email,sqlite3,unittest}/test || die |
Chad Versace | 9c71f3c | 2018-10-24 16:49:31 -0700 | [diff] [blame] | 355 | } |
| 356 | |
| 357 | pkg_preinst() { |
| 358 | if has_version "<${CATEGORY}/${PN}-${PYVER}" && ! has_version ">=${CATEGORY}/${PN}-${PYVER}_alpha"; then |
| 359 | python_updater_warning="1" |
| 360 | fi |
| 361 | } |
| 362 | |
| 363 | eselect_python_update() { |
Mike Frysinger | 0e24516 | 2021-02-19 15:39:45 -0500 | [diff] [blame^] | 364 | if [[ -z "$(eselect python show)" || \ |
| 365 | ! -f "${EROOT}/usr/bin/$(eselect python show)" ]]; then |
Chad Versace | 9c71f3c | 2018-10-24 16:49:31 -0700 | [diff] [blame] | 366 | eselect python update |
| 367 | fi |
| 368 | |
Mike Frysinger | 0e24516 | 2021-02-19 15:39:45 -0500 | [diff] [blame^] | 369 | if [[ -z "$(eselect python show --python${PV%%.*})" || \ |
| 370 | ! -f "${EROOT}/usr/bin/$(eselect python show --python${PV%%.*})" ]] |
| 371 | then |
Chad Versace | 9c71f3c | 2018-10-24 16:49:31 -0700 | [diff] [blame] | 372 | eselect python update --python${PV%%.*} |
| 373 | fi |
| 374 | } |
| 375 | |
| 376 | pkg_postinst() { |
| 377 | eselect_python_update |
| 378 | |
| 379 | if [[ "${python_updater_warning}" == "1" ]]; then |
| 380 | ewarn "You have just upgraded from an older version of Python." |
| 381 | ewarn |
| 382 | ewarn "Please adjust PYTHON_TARGETS (if so desired), and run emerge with the --newuse or --changed-use option to rebuild packages installing python modules." |
| 383 | fi |
| 384 | } |
| 385 | |
| 386 | pkg_postrm() { |
| 387 | eselect_python_update |
| 388 | } |