From 85fc0a59b1b8c36ab19ee8bd6db86af819ee9cc3 Mon Sep 17 00:00:00 2001 From: Luflosi Date: Fri, 20 Mar 2020 23:49:57 +0100 Subject: [PATCH 1/3] Rename variable logo_dir -> iconset_dir --- setup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index a4d364b9f..b405c696d 100755 --- a/setup.py +++ b/setup.py @@ -858,10 +858,10 @@ def macos_info_plist() -> bytes: def create_macos_app_icon(where: str = 'Resources') -> None: - logo_dir = os.path.abspath(os.path.join('logo', appname + '.iconset')) + iconset_dir = os.path.abspath(os.path.join('logo', appname + '.iconset')) subprocess.check_call([ - 'iconutil', '-c', 'icns', logo_dir, '-o', - os.path.join(where, os.path.basename(logo_dir).partition('.')[0] + '.icns') + 'iconutil', '-c', 'icns', iconset_dir, '-o', + os.path.join(where, os.path.basename(iconset_dir).partition('.')[0] + '.icns') ]) From 97cae0e355894260d015346e87ffb8ad7fdcf1da Mon Sep 17 00:00:00 2001 From: Luflosi Date: Fri, 20 Mar 2020 23:51:05 +0100 Subject: [PATCH 2/3] Simplify code This piece of code ends up just extracting `appname` from `iconset_dir`. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index b405c696d..df3e7d56e 100755 --- a/setup.py +++ b/setup.py @@ -861,7 +861,7 @@ def create_macos_app_icon(where: str = 'Resources') -> None: iconset_dir = os.path.abspath(os.path.join('logo', appname + '.iconset')) subprocess.check_call([ 'iconutil', '-c', 'icns', iconset_dir, '-o', - os.path.join(where, os.path.basename(iconset_dir).partition('.')[0] + '.icns') + os.path.join(where, appname + '.icns') ]) From 21c7002c680759995b7a6850ca4400045bd0aa31 Mon Sep 17 00:00:00 2001 From: Luflosi Date: Fri, 20 Mar 2020 23:59:58 +0100 Subject: [PATCH 3/3] Add support for png2icns as an alternative to iconutil png2icns is used when building kitty with nix because iconutil seems to be closed-source. libicns also has an iconutil clone called icnsutil in the source tree but the last release is from 2012, which does not include this utility yet. --- setup.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index df3e7d56e..917d29e6a 100755 --- a/setup.py +++ b/setup.py @@ -859,10 +859,23 @@ def macos_info_plist() -> bytes: def create_macos_app_icon(where: str = 'Resources') -> None: iconset_dir = os.path.abspath(os.path.join('logo', appname + '.iconset')) - subprocess.check_call([ - 'iconutil', '-c', 'icns', iconset_dir, '-o', - os.path.join(where, appname + '.icns') - ]) + icns_dir = os.path.join(where, appname + '.icns') + try: + subprocess.check_call([ + 'iconutil', '-c', 'icns', iconset_dir, '-o', icns_dir + ]) + except FileNotFoundError: + print(error('iconutil not found') + ', using png2icns (without retina support) to convert the logo', file=sys.stderr) + subprocess.check_call([ + 'png2icns', icns_dir + ] + [os.path.join(iconset_dir, logo) for logo in [ + # png2icns does not support retina icons, so only pass the non-retina icons + 'icon_16x16.png', + 'icon_32x32.png', + 'icon_128x128.png', + 'icon_256x256.png', + 'icon_512x512.png', + ]]) def create_minimal_macos_bundle(args: Options, where: str) -> None: