python-3.13.0.ebuild 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  1. # Copyright 1999-2024 Gentoo Authors
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI="8"
  4. LLVM_COMPAT=( 17 18 19 )
  5. LLVM_OPTIONAL=1
  6. WANT_LIBTOOL="none"
  7. inherit autotools check-reqs flag-o-matic linux-info llvm-r1
  8. inherit multiprocessing pax-utils python-utils-r1 toolchain-funcs
  9. inherit verify-sig
  10. MY_PV=${PV/_}
  11. MY_P="Python-${MY_PV%_p*}"
  12. PYVER=$(ver_cut 1-2)
  13. PATCHSET="python-gentoo-patches-${MY_PV}"
  14. DESCRIPTION="An interpreted, interactive, object-oriented programming language"
  15. HOMEPAGE="
  16. https://www.python.org/
  17. https://github.com/python/cpython/
  18. "
  19. SRC_URI="
  20. https://www.python.org/ftp/python/${PV%%_*}/${MY_P}.tar.xz
  21. https://dev.gentoo.org/~mgorny/dist/python/${PATCHSET}.tar.xz
  22. verify-sig? (
  23. https://www.python.org/ftp/python/${PV%%_*}/${MY_P}.tar.xz.asc
  24. )
  25. "
  26. S="${WORKDIR}/${MY_P}"
  27. LICENSE="PSF-2"
  28. SLOT="${PYVER}"
  29. KEYWORDS="~alpha amd64 arm arm64 hppa ~loong ~m68k ~mips ppc ppc64 ~riscv ~s390 sparc x86"
  30. IUSE="
  31. asan tsan msan ubsan lto thinlto
  32. bluetooth build debug +ensurepip examples gdbm jit
  33. libedit +ncurses pgo +readline +sqlite +ssl test tk valgrind
  34. "
  35. REQUIRED_USE="${PYTHON_REQUIRED_USE}
  36. asan? ( debug )
  37. tsan? ( debug )
  38. msan? ( debug )
  39. ubsan? ( debug )
  40. jit? ( ${LLVM_REQUIRED_USE} )
  41. "
  42. RESTRICT="!test? ( test )"
  43. # Do not add a dependency on dev-lang/python to this ebuild.
  44. # If you need to apply a patch which requires python for bootstrapping, please
  45. # run the bootstrap code on your dev box and include the results in the
  46. # patchset. See bug 447752.
  47. RDEPEND="
  48. app-arch/bzip2:=
  49. app-arch/xz-utils:=
  50. app-crypt/libb2
  51. >=dev-libs/expat-2.1:=
  52. dev-libs/libffi:=
  53. dev-libs/mpdecimal:=
  54. dev-python/gentoo-common
  55. >=sys-libs/zlib-1.1.3:=
  56. virtual/libintl
  57. ensurepip? ( dev-python/ensurepip-pip )
  58. gdbm? ( sys-libs/gdbm:=[berkdb] )
  59. kernel_linux? ( sys-apps/util-linux:= )
  60. ncurses? ( >=sys-libs/ncurses-5.2:= )
  61. readline? (
  62. !libedit? ( >=sys-libs/readline-4.1:= )
  63. libedit? ( dev-libs/libedit:= )
  64. )
  65. sqlite? ( >=dev-db/sqlite-3.3.8:3= )
  66. ssl? ( >=dev-libs/openssl-1.1.1:= )
  67. tk? (
  68. >=dev-lang/tcl-8.0:=
  69. >=dev-lang/tk-8.0:=
  70. dev-tcltk/blt:=
  71. dev-tcltk/tix
  72. )
  73. "
  74. # bluetooth requires headers from bluez
  75. DEPEND="
  76. ${RDEPEND}
  77. bluetooth? ( net-wireless/bluez )
  78. test? (
  79. dev-python/ensurepip-pip
  80. dev-python/ensurepip-setuptools
  81. dev-python/ensurepip-wheel
  82. )
  83. valgrind? ( dev-debug/valgrind )
  84. "
  85. # autoconf-archive needed to eautoreconf
  86. BDEPEND="
  87. dev-build/autoconf-archive
  88. app-alternatives/awk
  89. virtual/pkgconfig
  90. jit? (
  91. $(llvm_gen_dep '
  92. sys-devel/clang:${LLVM_SLOT}
  93. sys-devel/llvm:${LLVM_SLOT}
  94. ')
  95. )
  96. verify-sig? ( >=sec-keys/openpgp-keys-python-20221025 )
  97. "
  98. RDEPEND+="
  99. !build? ( app-misc/mime-types )
  100. "
  101. if [[ ${PV} != *_alpha* ]]; then
  102. RDEPEND+="
  103. dev-lang/python-exec[python_targets_python${PYVER/./_}(-)]
  104. "
  105. fi
  106. VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/openpgp-keys/python.org.asc
  107. # large file tests involve a 2.5G file being copied (duplicated)
  108. CHECKREQS_DISK_BUILD=5500M
  109. QA_PKGCONFIG_VERSION=${PYVER}
  110. # false positives -- functions specific to *BSD
  111. QA_CONFIG_IMPL_DECL_SKIP=( chflags lchflags )
  112. declare -rgA PYTHON_KERNEL_CHECKS=(
  113. ["CROSS_MEMORY_ATTACH"]="test_external_inspection" #bug 938589
  114. ["DNOTIFY"]="test_fcntl" # bug 938662
  115. )
  116. pkg_pretend() {
  117. if use pgo || use test; then
  118. check-reqs_pkg_pretend
  119. fi
  120. if use jit; then
  121. ewarn "USE=jit is considered experimental upstream. Using it"
  122. ewarn "could lead to unexpected breakage, including race conditions"
  123. ewarn "and crashes, respectively. Please do not file Gentoo bugs, unless"
  124. ewarn "you can reproduce the problem with dev-lang/python[-jit]. Instead,"
  125. ewarn "please consider reporting JIT problems upstream."
  126. fi
  127. }
  128. pkg_setup() {
  129. if [[ ${MERGE_TYPE} != binary ]]; then
  130. use jit && llvm-r1_pkg_setup
  131. if use test || use pgo; then
  132. check-reqs_pkg_setup
  133. local CONFIG_CHECK
  134. for f in "${!PYTHON_KERNEL_CHECKS[@]}"; do
  135. CONFIG_CHECK+="~${f} "
  136. done
  137. linux-info_pkg_setup
  138. fi
  139. fi
  140. }
  141. src_unpack() {
  142. if use verify-sig; then
  143. verify-sig_verify_detached "${DISTDIR}"/${MY_P}.tar.xz{,.asc}
  144. fi
  145. default
  146. }
  147. src_prepare() {
  148. # Ensure that internal copies of expat and libffi are not used.
  149. # TODO: Makefile has annoying deps on expat headers
  150. #rm -r Modules/expat || die
  151. local PATCHES=(
  152. "${WORKDIR}/${PATCHSET}"
  153. )
  154. default
  155. # force the correct number of jobs
  156. # https://bugs.gentoo.org/737660
  157. sed -i -e "s:-j0:-j$(makeopts_jobs):" Makefile.pre.in || die
  158. # breaks tests when using --with-wheel-pkg-dir
  159. rm -r Lib/test/wheeldata || die
  160. eautoreconf
  161. }
  162. build_cbuild_python() {
  163. # Hack to workaround get_libdir not being able to handle CBUILD, bug #794181
  164. local cbuild_libdir=$(unset PKG_CONFIG_PATH ; $(tc-getBUILD_PKG_CONFIG) --keep-system-libs --libs-only-L libffi)
  165. # pass system CFLAGS & LDFLAGS as _NODIST, otherwise they'll get
  166. # propagated to sysconfig for built extensions
  167. #
  168. # -fno-lto to avoid bug #700012 (not like it matters for mini-CBUILD Python anyway)
  169. local -x CFLAGS_NODIST="${BUILD_CFLAGS}"
  170. local -x LDFLAGS_NODIST=${BUILD_LDFLAGS}
  171. local -x CFLAGS= LDFLAGS=
  172. local -x BUILD_CFLAGS="${CFLAGS_NODIST}"
  173. local -x BUILD_LDFLAGS=${LDFLAGS_NODIST}
  174. # We need to build our own Python on CBUILD first, and feed it in.
  175. # bug #847910
  176. local myeconfargs_cbuild=(
  177. "${myeconfargs[@]}"
  178. --prefix="${BROOT}"/usr
  179. --libdir="${cbuild_libdir:2}"
  180. # Avoid needing to load the right libpython.so.
  181. --disable-shared
  182. # As minimal as possible for the mini CBUILD Python
  183. # we build just for cross to satisfy --with-build-python.
  184. --without-lto
  185. --without-readline
  186. --disable-optimizations
  187. )
  188. mkdir "${WORKDIR}"/${P}-${CBUILD} || die
  189. pushd "${WORKDIR}"/${P}-${CBUILD} &> /dev/null || die
  190. # Avoid as many dependencies as possible for the cross build.
  191. mkdir Modules || die
  192. cat > Modules/Setup.local <<-EOF || die
  193. *disabled*
  194. nis
  195. _dbm _gdbm
  196. _sqlite3
  197. _hashlib _ssl
  198. _curses _curses_panel
  199. readline
  200. _tkinter
  201. pyexpat
  202. zlib
  203. # We disabled these for CBUILD because Python's setup.py can't handle locating
  204. # libdir correctly for cross. This should be rechecked for the pure Makefile approach,
  205. # and uncommented if needed.
  206. #_ctypes
  207. EOF
  208. ECONF_SOURCE="${S}" econf_build "${myeconfargs_cbuild[@]}"
  209. # Unfortunately, we do have to build this immediately, and
  210. # not in src_compile, because CHOST configure for Python
  211. # will check the existence of the --with-build-python value
  212. # immediately.
  213. emake
  214. popd &> /dev/null || die
  215. }
  216. src_configure() {
  217. # disable automagic bluetooth headers detection
  218. if ! use bluetooth; then
  219. local -x ac_cv_header_bluetooth_bluetooth_h=no
  220. fi
  221. append-flags -fwrapv
  222. filter-flags -malign-double
  223. # Export CXX so it ends up in /usr/lib/python3.X/config/Makefile.
  224. # PKG_CONFIG needed for cross.
  225. tc-export CXX PKG_CONFIG
  226. local dbmliborder=
  227. if use gdbm; then
  228. dbmliborder+="${dbmliborder:+:}gdbm"
  229. fi
  230. # Set baseline test skip flags.
  231. COMMON_TEST_SKIPS=(
  232. # this is actually test_gdb.test_pretty_print
  233. -x test_pretty_print
  234. # https://bugs.gentoo.org/933840
  235. -x test_perf_profiler
  236. )
  237. # Arch-specific skips. See #931888 for a collection of these.
  238. case ${CHOST} in
  239. alpha*)
  240. COMMON_TEST_SKIPS+=(
  241. -x test_builtin
  242. -x test_capi
  243. -x test_cmath
  244. -x test_float
  245. # timeout
  246. -x test_free_threading
  247. -x test_math
  248. -x test_numeric_tower
  249. -x test_random
  250. -x test_statistics
  251. # bug 653850
  252. -x test_resource
  253. -x test_strtod
  254. )
  255. ;;
  256. mips*)
  257. COMMON_TEST_SKIPS+=(
  258. -x test_ctypes
  259. -x test_external_inspection
  260. -x test_statistics
  261. )
  262. ;;
  263. powerpc64-*) # big endian
  264. COMMON_TEST_SKIPS+=(
  265. -x test_gdb
  266. )
  267. ;;
  268. riscv*)
  269. COMMON_TEST_SKIPS+=(
  270. -x test_urllib2
  271. )
  272. ;;
  273. sparc*)
  274. COMMON_TEST_SKIPS+=(
  275. # bug 788022
  276. -x test_multiprocessing_fork
  277. -x test_multiprocessing_forkserver
  278. -x test_multiprocessing_spawn
  279. -x test_ctypes
  280. -x test_gdb
  281. # bug 931908
  282. -x test_exceptions
  283. )
  284. ;;
  285. esac
  286. # Kernel-config specific skips
  287. for option in "${!PYTHON_KERNEL_CHECKS[@]}"; do
  288. if ! linux_config_exists || ! linux_chkconfig_present "${option}"
  289. then
  290. COMMON_TEST_SKIPS+=( -x "${PYTHON_KERNEL_CHECKS[${option}]}" )
  291. fi
  292. done
  293. # musl-specific skips
  294. use elibc_musl && COMMON_TEST_SKIPS+=(
  295. # various musl locale deficiencies
  296. -x test__locale
  297. -x test_c_locale_coercion
  298. -x test_locale
  299. -x test_re
  300. # known issues with find_library on musl
  301. # https://bugs.python.org/issue21622
  302. -x test_ctypes
  303. # fpathconf, ttyname errno values
  304. -x test_os
  305. )
  306. if use pgo; then
  307. local profile_task_flags=(
  308. -m test
  309. "-j$(makeopts_jobs)"
  310. --pgo-extended
  311. --verbose3
  312. -u-network
  313. # We use a timeout because of how often we've had hang issues
  314. # here. It also matches the default upstream PROFILE_TASK.
  315. --timeout 1200
  316. "${COMMON_TEST_SKIPS[@]}"
  317. -x test_dtrace
  318. # All of these seem to occasionally hang for PGO inconsistently
  319. # They'll even hang here but be fine in src_test sometimes.
  320. # bug #828535 (and related: bug #788022)
  321. -x test_asyncio
  322. -x test_httpservers
  323. -x test_logging
  324. -x test_multiprocessing_fork
  325. -x test_socket
  326. -x test_xmlrpc
  327. # Hangs (actually runs indefinitely executing itself w/ many cpython builds)
  328. # bug #900429
  329. -x test_tools
  330. # Fails in profiling run, passes in src_test().
  331. -x test_capi
  332. )
  333. # Arch-specific skips. See #931888 for a collection of these.
  334. case ${CHOST} in
  335. alpha*)
  336. profile_task_flags+=(
  337. -x test_os
  338. )
  339. ;;
  340. hppa*)
  341. profile_task_flags+=(
  342. -x test_descr
  343. # bug 931908
  344. -x test_exceptions
  345. -x test_os
  346. )
  347. ;;
  348. powerpc64-*) # big endian
  349. profile_task_flags+=(
  350. # bug 931908
  351. -x test_exceptions
  352. )
  353. ;;
  354. riscv*)
  355. profile_task_flags+=(
  356. -x test_statistics
  357. )
  358. ;;
  359. esac
  360. if has_version "app-arch/rpm" ; then
  361. # Avoid sandbox failure (attempts to write to /var/lib/rpm)
  362. profile_task_flags+=(
  363. -x test_distutils
  364. )
  365. fi
  366. local -x PROFILE_TASK="${profile_task_flags[*]}"
  367. fi
  368. local myeconfargs=(
  369. # glibc-2.30 removes it; since we can't cleanly force-rebuild
  370. # Python on glibc upgrade, remove it proactively to give
  371. # a chance for users rebuilding python before glibc
  372. ac_cv_header_stropts_h=no
  373. --enable-shared
  374. --without-static-libpython
  375. --enable-ipv6
  376. --infodir='${prefix}/share/info'
  377. --mandir='${prefix}/share/man'
  378. --with-computed-gotos
  379. --with-dbmliborder="${dbmliborder}"
  380. --with-libc=
  381. --enable-loadable-sqlite-extensions
  382. --without-ensurepip
  383. --without-lto
  384. --with-system-expat
  385. --with-system-libmpdec
  386. --with-platlibdir=lib
  387. --with-pkg-config=yes
  388. --with-wheel-pkg-dir="${EPREFIX}"/usr/lib/python/ensurepip
  389. --enable-gil
  390. $(use_with debug assertions)
  391. $(use_enable jit experimental-jit)
  392. $(use_enable pgo optimizations)
  393. $(use_with readline readline "$(usex libedit editline readline)")
  394. $(use_with valgrind)
  395. )
  396. if tc-is-clang ; then
  397. $(use_with asan address-sanitizer)
  398. $(use_with msan memory-sanitizer)
  399. $(use_with ubsan undefined-behavior-sanitizer)
  400. $(use_with tsan thread-sanitizer)
  401. fi
  402. # https://bugs.gentoo.org/700012
  403. if use lto ; then
  404. append-cflags $(test-flags-CC -ffat-lto-objects)
  405. myeconfargs+=(
  406. --with-lto=yes
  407. )
  408. fi
  409. if use thinlto ; then
  410. myeconfargs+=(
  411. --with-lto=thin
  412. )
  413. fi
  414. # Force-disable modules we don't want built.
  415. # See Modules/Setup for docs on how this works. Setup.local contains our local deviations.
  416. cat > Modules/Setup.local <<-EOF || die
  417. *disabled*
  418. nis
  419. $(usev !gdbm '_gdbm _dbm')
  420. $(usev !sqlite '_sqlite3')
  421. $(usev !ssl '_hashlib _ssl')
  422. $(usev !ncurses '_curses _curses_panel')
  423. $(usev !readline 'readline')
  424. $(usev !tk '_tkinter')
  425. EOF
  426. # Workaround for: undefined symbol error with --no-undefined ldflag
  427. append-ldflags $(no-as-needed)
  428. # disable implicit optimization/debugging flags
  429. local -x OPT=
  430. if tc-is-cross-compiler ; then
  431. build_cbuild_python
  432. myeconfargs+=(
  433. # Point the imminent CHOST build to the Python we just
  434. # built for CBUILD.
  435. --with-build-python="${WORKDIR}"/${P}-${CBUILD}/python
  436. )
  437. fi
  438. # pass system CFLAGS & LDFLAGS as _NODIST, otherwise they'll get
  439. # propagated to sysconfig for built extensions
  440. local -x CFLAGS_NODIST=${CFLAGS}
  441. local -x LDFLAGS_NODIST=${LDFLAGS}
  442. local -x CFLAGS= LDFLAGS=
  443. # Fix implicit declarations on cross and prefix builds. Bug #674070.
  444. if use ncurses; then
  445. append-cppflags -I"${ESYSROOT}"/usr/include/ncursesw
  446. fi
  447. econf "${myeconfargs[@]}"
  448. if grep -q "#define POSIX_SEMAPHORES_NOT_ENABLED 1" pyconfig.h; then
  449. eerror "configure has detected that the sem_open function is broken."
  450. eerror "Please ensure that /dev/shm is mounted as a tmpfs with mode 1777."
  451. die "Broken sem_open function (bug 496328)"
  452. fi
  453. # install epython.py as part of stdlib
  454. echo "EPYTHON='python${PYVER}'" > Lib/epython.py || die
  455. }
  456. src_compile() {
  457. # Ensure sed works as expected
  458. # https://bugs.gentoo.org/594768
  459. local -x LC_ALL=C
  460. export PYTHONSTRICTEXTENSIONBUILD=1
  461. # Save PYTHONDONTWRITEBYTECODE so that 'has_version' doesn't
  462. # end up writing bytecode & violating sandbox.
  463. # bug #831897
  464. local -x _PYTHONDONTWRITEBYTECODE=${PYTHONDONTWRITEBYTECODE}
  465. # Gentoo hack to disable accessing system site-packages
  466. export GENTOO_CPYTHON_BUILD=1
  467. if use pgo ; then
  468. # bug 660358
  469. local -x COLUMNS=80
  470. local -x PYTHONDONTWRITEBYTECODE=
  471. local -x TMPDIR=/tmp
  472. fi
  473. # also need to clear the flags explicitly here or they end up
  474. # in _sysconfigdata*
  475. emake CPPFLAGS= CFLAGS= LDFLAGS= DFLAGS= DFFLAGS=
  476. # Restore saved value from above.
  477. local -x PYTHONDONTWRITEBYTECODE=${_PYTHONDONTWRITEBYTECODE}
  478. # Work around bug 329499. See also bug 413751 and 457194.
  479. if has_version dev-libs/libffi[pax-kernel]; then
  480. pax-mark E python
  481. else
  482. pax-mark m python
  483. fi
  484. }
  485. src_test() {
  486. # Tests will not work when cross compiling.
  487. if tc-is-cross-compiler; then
  488. elog "Disabling tests due to crosscompiling."
  489. return
  490. fi
  491. # this just happens to skip test_support.test_freeze that is broken
  492. # without bundled expat
  493. # TODO: get a proper skip for it upstream
  494. local -x LOGNAME=buildbot
  495. local test_opts=(
  496. --verbose3
  497. -u-network
  498. -j "$(makeopts_jobs)"
  499. "${COMMON_TEST_SKIPS[@]}"
  500. )
  501. # bug 660358
  502. local -x COLUMNS=80
  503. local -x PYTHONDONTWRITEBYTECODE=
  504. local -x TMPDIR=/tmp
  505. nonfatal emake -Onone test EXTRATESTOPTS="${test_opts[*]}" \
  506. CPPFLAGS= CFLAGS= LDFLAGS= < /dev/tty
  507. local ret=${?}
  508. [[ ${ret} -eq 0 ]] || die "emake test failed"
  509. }
  510. src_install() {
  511. local libdir=${ED}/usr/lib/python${PYVER}
  512. # -j1 hack for now for bug #843458
  513. emake -j1 DESTDIR="${D}" TEST_MODULES=no altinstall
  514. # Fix collisions between different slots of Python.
  515. rm "${ED}/usr/$(get_libdir)/libpython3.so" || die
  516. # Cheap hack to get version with ABIFLAGS
  517. local abiver=$(cd "${ED}/usr/include"; echo python*)
  518. if [[ ${abiver} != python${PYVER} ]]; then
  519. # Replace python3.X with a symlink to python3.Xm
  520. rm "${ED}/usr/bin/python${PYVER}" || die
  521. dosym "${abiver}" "/usr/bin/python${PYVER}"
  522. # Create python3.X-config symlink
  523. dosym "${abiver}-config" "/usr/bin/python${PYVER}-config"
  524. # Create python-3.5m.pc symlink
  525. dosym "python-${PYVER}.pc" "/usr/$(get_libdir)/pkgconfig/${abiver/${PYVER}/-${PYVER}}.pc"
  526. fi
  527. # python seems to get rebuilt in src_install (bug 569908)
  528. # Work around it for now.
  529. if has_version dev-libs/libffi[pax-kernel]; then
  530. pax-mark E "${ED}/usr/bin/${abiver}"
  531. else
  532. pax-mark m "${ED}/usr/bin/${abiver}"
  533. fi
  534. rm -r "${libdir}"/ensurepip/_bundled || die
  535. if ! use sqlite; then
  536. rm -r "${libdir}/"sqlite3 || die
  537. fi
  538. if ! use tk; then
  539. rm -r "${ED}/usr/bin/idle${PYVER}" || die
  540. rm -r "${libdir}/"{idlelib,tkinter} || die
  541. fi
  542. ln -s ../python/EXTERNALLY-MANAGED "${libdir}/EXTERNALLY-MANAGED" || die
  543. dodoc Misc/{ACKS,HISTORY,NEWS}
  544. if use examples; then
  545. docinto examples
  546. find Tools -name __pycache__ -exec rm -fr {} + || die
  547. dodoc -r Tools
  548. fi
  549. insinto /usr/share/gdb/auto-load/usr/$(get_libdir) #443510
  550. local libname=$(
  551. printf 'e:\n\t@echo $(INSTSONAME)\ninclude Makefile\n' |
  552. emake --no-print-directory -s -f - 2>/dev/null
  553. )
  554. newins Tools/gdb/libpython.py "${libname}"-gdb.py
  555. newconfd "${FILESDIR}/pydoc.conf" pydoc-${PYVER}
  556. newinitd "${FILESDIR}/pydoc.init" pydoc-${PYVER}
  557. sed \
  558. -e "s:@PYDOC_PORT_VARIABLE@:PYDOC${PYVER/./_}_PORT:" \
  559. -e "s:@PYDOC@:pydoc${PYVER}:" \
  560. -i "${ED}/etc/conf.d/pydoc-${PYVER}" \
  561. "${ED}/etc/init.d/pydoc-${PYVER}" || die "sed failed"
  562. # python-exec wrapping support
  563. local pymajor=${PYVER%.*}
  564. local EPYTHON=python${PYVER}
  565. local scriptdir=${D}$(python_get_scriptdir)
  566. mkdir -p "${scriptdir}" || die
  567. # python and pythonX
  568. ln -s "../../../bin/${abiver}" "${scriptdir}/python${pymajor}" || die
  569. ln -s "python${pymajor}" "${scriptdir}/python" || die
  570. # python-config and pythonX-config
  571. # note: we need to create a wrapper rather than symlinking it due
  572. # to some random dirname(argv[0]) magic performed by python-config
  573. cat > "${scriptdir}/python${pymajor}-config" <<-EOF || die
  574. #!/bin/sh
  575. exec "${abiver}-config" "\${@}"
  576. EOF
  577. chmod +x "${scriptdir}/python${pymajor}-config" || die
  578. ln -s "python${pymajor}-config" "${scriptdir}/python-config" || die
  579. # pydoc
  580. ln -s "../../../bin/pydoc${PYVER}" "${scriptdir}/pydoc" || die
  581. # idle
  582. if use tk; then
  583. ln -s "../../../bin/idle${PYVER}" "${scriptdir}/idle" || die
  584. fi
  585. }
  586. pkg_postinst() {
  587. local v
  588. for v in ${REPLACING_VERSIONS}; do
  589. if ver_test "${v}" -lt 3.13.0_beta2; then
  590. ewarn "Python 3.13.0b2 has changed its module ABI. The .pyc files"
  591. ewarn "installed previously are no longer valid and will be regenerated"
  592. ewarn "(or ignored) on the next import. This may cause sandbox failures"
  593. ewarn "when installing some packages and checksum mismatches when removing"
  594. ewarn "old versions. To actively prevent this, rebuild all packages"
  595. ewarn "installing Python 3.13 modules, e.g. using:"
  596. ewarn
  597. ewarn " emerge -1v /usr/lib/python3.13/site-packages"
  598. fi
  599. done
  600. }