# Copyright 1999-2025 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=8 PYTHON_COMPAT=( python3_{11..13} ) DISTUTILS_USE_PEP517=poetry inherit distutils-r1 meson python-r1 DESCRIPTION="Python CLI and API for Meshtastic devices, with optional GUI client" HOMEPAGE="https://github.com/meshtastic/python https://gitlab.com/kop316/gtk-meshtastic-client/" GUI_PV="1.2" SRC_URI=" https://github.com/meshtastic/python/archive/refs/tags/${PV}.tar.gz -> ${P}.tar.gz gui? ( https://gitlab.com/kop316/gtk-meshtastic-client/-/archive/${GUI_PV}/gtk-meshtastic-client-${GUI_PV}.tar.gz ) " LICENSE="GPL-3" SLOT="0" KEYWORDS="~amd64 ~x86 ~arm64" IUSE="gui minimal +qrcode +tun" # Common Python dependencies COMMON_DEPEND=" >=dev-python/bleak-1.0.1[${PYTHON_USEDEP}] >=dev-python/packaging-25.0[${PYTHON_USEDEP}] >=dev-python/platformdirs-4.3.8[${PYTHON_USEDEP}] >=dev-python/protobuf-6.31.1[${PYTHON_USEDEP}] >=dev-python/pyserial-3.5-r2[${PYTHON_USEDEP}] >=dev-python/pyyaml-6.0.2[${PYTHON_USEDEP}] >=dev-python/requests-2.32.4[${PYTHON_USEDEP}] >=dev-python/setuptools-80.9.0-r1[${PYTHON_USEDEP}] >=dev-python/tabulate-0.9.0-r1[${PYTHON_USEDEP}] >=dev-python/build-1.2.2_p1-r2[${PYTHON_USEDEP}] >=dev-python/dotmap-1.3.0[${PYTHON_USEDEP}] >=dev-python/pypubsub-4.0.3[${PYTHON_USEDEP}] !minimal? ( dev-python/print-color[${PYTHON_USEDEP}] ) qrcode? ( >=dev-python/pyqrcode-1.2.1[${PYTHON_USEDEP}] ) tun? ( >=dev-python/pytap2-2.3.0[${PYTHON_USEDEP}] ) " DEPEND=" ${COMMON_DEPEND} ${PYTHON_DEPS} gui? ( $(python_gen_cond_dep ' dev-python/meson-python[${PYTHON_USEDEP}] ') ) " RDEPEND=" ${COMMON_DEPEND} ${PYTHON_DEPS} gui? ( dev-libs/glib:2 x11-libs/gdk-pixbuf:2 dev-libs/gobject-introspection gui-libs/libadwaita[introspection] >=gui-libs/gtk-4.10:4[introspection] >=x11-libs/pango-1.44.0[introspection] media-libs/libshumate[introspection] $(python_gen_cond_dep ' >=dev-python/pygobject-3.36[${PYTHON_USEDEP},cairo] dev-python/dotmap[${PYTHON_USEDEP}] dev-python/pyqrcode[${PYTHON_USEDEP}] ') ) " BDEPEND=" ${PYTHON_DEPS} dev-python/poetry-core[${PYTHON_USEDEP}] dev-python/wheel[${PYTHON_USEDEP}] dev-python/installer[${PYTHON_USEDEP}] gui? ( dev-util/desktop-file-utils x11-libs/gtk+ ) " S="${WORKDIR}/python-${PV}" src_unpack() { default if use gui; then mv "${WORKDIR}/gtk-meshtastic-client-${GUI_PV}" "${WORKDIR}/gtk-meshtastic-client" || die fi } src_prepare() { default distutils-r1_src_prepare } src_configure() { distutils-r1_src_configure if use gui; then [[ -f "${WORKDIR}/gtk-meshtastic-client/meson.build" ]] || die "meson.build not found in ${WORKDIR}/gtk-meshtastic-client" mkdir -p "${WORKDIR}/gui-build" || die pushd "${WORKDIR}/gui-build" || die python_setup meson setup \ --prefix=/usr \ --libdir=lib64 \ --localstatedir=/var/lib \ --sysconfdir=/etc \ --wrap-mode=nodownload \ --build.pkg-config-path=/usr/share/pkgconfig \ --pkg-config-path=/usr/share/pkgconfig \ -Db_pch=false \ -Dwerror=false \ -Dbuildtype=plain \ "${WORKDIR}/gtk-meshtastic-client" \ "${WORKDIR}/gui-build" || die "Meson setup failed" popd || die fi } src_compile() { distutils-r1_src_compile if use gui; then pushd "${WORKDIR}/gui-build" || die python_setup meson_src_compile popd || die fi } src_install() { distutils-r1_src_install dodoc README.md if use gui; then pushd "${WORKDIR}/gui-build" || die python_setup meson_src_install python_optimize python_fix_shebang "${ED}/usr/bin/gtk-meshtastic-client" popd || die if [[ -f "${WORKDIR}/gtk-meshtastic-client/data/io.meshtastic.GtkClient.desktop" ]]; then insinto /usr/share/applications doins "${WORKDIR}/gtk-meshtastic-client/data/io.meshtastic.GtkClient.desktop" fi if [[ -d "${WORKDIR}/gtk-meshtastic-client/data/icons" ]]; then insinto /usr/share/icons doins -r "${WORKDIR}/gtk-meshtastic-client/data/icons"/* fi fi } pkg_postinst() { if use gui; then xdg_pkg_postinst glib-compile-schemas /usr/share/glib-2.0/schemas || die "Failed to compile GSettings schemas" update-desktop-database /usr/share/applications gtk-update-icon-cache -f -t /usr/share/icons/hicolor elog "The Meshtastic GTK Client has been installed and is available in your application menu." elog "To use the GUI, ensure a Meshtastic device is connected via serial, Bluetooth, or TCP." elog "For configuration details, visit: https://meshtastic.org/docs/software/python/gui-client/" elog "Report issues at: https://gitlab.com/kop316/gtk-meshtastic-client/-/issues" fi } pkg_postrm() { if use gui; then update-desktop-database /usr/share/applications gtk-update-icon-cache -f -t /usr/share/icons/hicolor fi }