commit:     54b07999b19d0f3de682b6bec5c545cf1af20bc0
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Oct  9 05:19:33 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Oct 12 05:04:28 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=54b07999

app-portage/gentoolkit: Migrate 9999 to use Meson

Bug: https://bugs.gentoo.org/909888
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
Closes: https://github.com/gentoo/gentoo/pull/33257
Signed-off-by: Sam James <sam <AT> gentoo.org>

 app-portage/gentoolkit/gentoolkit-9999.ebuild | 68 +++++++++++++++++++++++----
 1 file changed, 59 insertions(+), 9 deletions(-)

diff --git a/app-portage/gentoolkit/gentoolkit-9999.ebuild 
b/app-portage/gentoolkit/gentoolkit-9999.ebuild
index 018a60d8df98..e4a3125c8852 100644
--- a/app-portage/gentoolkit/gentoolkit-9999.ebuild
+++ b/app-portage/gentoolkit/gentoolkit-9999.ebuild
@@ -6,7 +6,7 @@ EAPI=8
 PYTHON_COMPAT=( python3_{10..12} pypy3 )
 PYTHON_REQ_USE="xml(+),threads(+)"
 
-inherit distutils-r1 tmpfiles
+inherit meson python-r1 tmpfiles
 
 if [[ ${PV} = 9999* ]]; then
        EGIT_REPO_URI="https://anongit.gentoo.org/git/proj/gentoolkit.git";
@@ -21,6 +21,7 @@ HOMEPAGE="https://wiki.gentoo.org/wiki/Project:Portage-Tools";
 
 LICENSE="GPL-2"
 SLOT="0"
+REQUIRED_USE="${PYTHON_REQUIRED_USE}"
 
 # Need newer Portage for eclean-pkg API, bug #900224
 DEPEND="
@@ -28,19 +29,25 @@ DEPEND="
 "
 RDEPEND="
        ${DEPEND}
+       ${PYTHON_DEPS}
        app-alternatives/awk
        sys-apps/gentoo-functions
 "
-BDEPEND="dev-python/setuptools[${PYTHON_USEDEP}]"
 
-distutils_enable_tests setup.py
-
-python_prepare_all() {
-       python_setup
-       echo VERSION="${PVR}" "${PYTHON}" setup.py set_version
-       VERSION="${PVR}" "${PYTHON}" setup.py set_version
-       distutils-r1_python_prepare_all
+# setuptools is still needed as a workaround for Python 3.12+ for now.
+# https://github.com/mesonbuild/meson/issues/7702
+#
+# >=meson-1.2.1-r1 for bug #912051
+BDEPEND="
+       ${PYTHON_DEPS}
+       >=dev-util/meson-1.2.1-r1
+       $(python_gen_cond_dep '
+               dev-python/setuptools[${PYTHON_USEDEP}]
+       ' python3_12)
+"
 
+src_prepare() {
+       default
        if use prefix-guest ; then
                # use correct repo name, bug #632223
                sed -i \
@@ -49,6 +56,49 @@ python_prepare_all() {
        fi
 }
 
+src_configure() {
+       local code_only=false
+       python_foreach_impl my_src_configure
+}
+
+my_src_configure() {
+       local emesonargs=(
+               -Dcode-only=${code_only}
+               -Deprefix="${EPREFIX}"
+               -Ddocdir="${EPREFIX}/usr/share/doc/${PF}"
+       )
+
+       meson_src_configure
+       code_only=true
+}
+
+src_compile() {
+       python_foreach_impl meson_src_compile
+}
+
+src_test() {
+       python_foreach_impl meson_src_test --no-rebuild --verbose
+}
+
+src_install() {
+       python_foreach_impl my_src_install
+       dotmpfiles data/tmpfiles.d/revdep-rebuild.conf
+
+       local scripts
+       mapfile -t scripts < <(awk '/^#!.*python/ {print FILENAME} {nextfile}' 
"${ED}"/usr/bin/* || die)
+       python_replicate_script "${scripts[@]}"
+}
+
+my_src_install() {
+       local pydirs=(
+               "${D}$(python_get_sitedir)"
+       )
+
+       meson_src_install
+       python_optimize "${pydirs[@]}"
+       python_fix_shebang "${pydirs[@]}"
+}
+
 pkg_postinst() {
        tmpfiles_process revdep-rebuild.conf
 

Reply via email to