x11-terms/kitty: add importlib_resources as dependency when using Python 3.6
[gentoo.git] / x11-terms / kitty / kitty-0.17.2-r1.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 PYTHON_COMPAT=( python3_{6,7,8} )
7
8 inherit eutils python-single-r1 toolchain-funcs xdg
9
10 if [[ ${PV} == "9999" ]] ; then
11         EGIT_REPO_URI="https://github.com/kovidgoyal/kitty.git"
12         inherit git-r3
13 else
14         SRC_URI="https://github.com/kovidgoyal/kitty/releases/download/v${PV}/${P}.tar.xz"
15         KEYWORDS="~amd64 ~x86"
16 fi
17
18 DESCRIPTION="A modern, hackable, featureful, OpenGL-based terminal emulator"
19 HOMEPAGE="https://github.com/kovidgoyal/kitty"
20
21 LICENSE="GPL-3"
22 SLOT="0"
23 IUSE="debug wayland"
24 REQUIRED_USE="${PYTHON_REQUIRED_USE}"
25
26 RDEPEND="
27         ${PYTHON_DEPS}
28         media-libs/fontconfig
29         media-libs/freetype:2
30         >=media-libs/harfbuzz-1.5.0:=
31         media-libs/libcanberra
32         media-libs/libpng:0=
33         sys-apps/dbus
34         sys-libs/zlib
35         x11-libs/libxcb[xkb]
36         x11-libs/libXcursor
37         x11-libs/libXi
38         x11-libs/libXinerama
39         x11-libs/libxkbcommon[X]
40         x11-libs/libXrandr
41         x11-terms/kitty-terminfo
42         wayland? (
43                 dev-libs/wayland
44                 >=dev-libs/wayland-protocols-1.17
45         )
46         $(python_gen_cond_dep 'dev-python/importlib_resources[${PYTHON_MULTI_USEDEP}]' python3_6)
47 "
48
49 DEPEND="${RDEPEND}
50         media-libs/mesa[X(+)]
51         sys-libs/ncurses
52 "
53
54 BDEPEND="virtual/pkgconfig"
55
56 [[ ${PV} == *9999 ]] && BDEPEND+=" >=dev-python/sphinx-1.7"
57
58 PATCHES=(
59         "${FILESDIR}"/${PN}-0.17.2-flags.patch
60         "${FILESDIR}"/${PN}-0.14.4-svg-icon.patch
61         "${FILESDIR}"/${PN}-0.16.0-remove-terminfo.patch
62 )
63
64 src_prepare() {
65         default
66
67         # disable wayland as required
68         if ! use wayland; then
69                 sed -i "/'x11 wayland'/s/ wayland//" setup.py || die
70         fi
71
72         # respect doc dir
73         sed -i "/htmldir =/s/appname/'${PF}'/" setup.py || die
74
75         tc-export CC
76 }
77
78 src_compile() {
79         "${EPYTHON}" setup.py \
80                 --verbose $(usex debug --debug "") \
81                 --libdir-name $(get_libdir) \
82                 linux-package || die "Failed to compile kitty."
83 }
84
85 src_test() {
86         export KITTY_CONFIG_DIRECTORY=${T}
87         "${EPYTHON}" test.py || die
88 }
89
90 src_install() {
91         insinto /usr
92         doins -r linux-package/*
93         dobin linux-package/bin/kitty
94         python_fix_shebang "${ED}"
95 }
96
97 pkg_postinst() {
98         xdg_icon_cache_update
99         optfeature "Displaying images in the terminal" virtual/imagemagick-tools
100 }
101
102 pkg_postrm() {
103         xdg_icon_cache_update
104 }