Skip to content

Commit

Permalink
Make the docs and man pages available in the macos bundle as well
Browse files Browse the repository at this point in the history
  • Loading branch information
kovidgoyal committed Aug 19, 2022
1 parent 1f499a7 commit 3288400
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 2 deletions.
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ profile:
app:
python3 setup.py kitty.app $(VVAL)

linux-package: FORCE
rm -rf linux-package
python3 setup.py linux-package

FORCE:

man:
$(MAKE) -C docs man

Expand Down
2 changes: 1 addition & 1 deletion kitty/conf/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def ref_map() -> Dict[str, Dict[str, str]]:
return ans


def resolve_ref(ref: str) -> str:
def resolve_ref(ref: str, website_url: Callable[[str], str] = website_url) -> str:
m = ref_map()
href = m['ref'].get(ref, '')
if href:
Expand Down
19 changes: 19 additions & 0 deletions kitty/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,22 @@ def clear_handled_signals(*a: Any) -> None:
signal.pthread_sigmask(signal.SIG_UNBLOCK, handled_signals)
for s in handled_signals:
signal.signal(s, signal.SIG_DFL)


@run_once
def local_docs() -> str:
d = os.path.dirname
base = d(d(kitty_exe()))
subdir = os.path.join('doc', 'kitty', 'html')
linux_ans = os.path.join(base, 'share', subdir)
if getattr(sys, 'frozen', False):
if is_macos:
return os.path.join(d(d(d(extensions_dir))), subdir)
return linux_ans
if os.path.isdir(linux_ans):
return linux_ans
for candidate in ('/usr', '/usr/local', '/opt/homebrew'):
q = os.path.join(candidate, 'share', subdir)
if os.path.isdir(q):
return q
return ''
4 changes: 3 additions & 1 deletion kitty_tests/check_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,15 @@ def test_all_kitten_names(self) -> None:

def test_filesystem_locations(self) -> None:
from kitty.constants import (
logo_png_file, shell_integration_dir, terminfo_dir
local_docs, logo_png_file, shell_integration_dir, terminfo_dir
)
zsh = os.path.join(shell_integration_dir, 'zsh')
self.assertTrue(os.path.isdir(terminfo_dir), f'Terminfo dir: {terminfo_dir}')
self.assertTrue(os.path.exists(logo_png_file), f'Logo file: {logo_png_file}')
self.assertTrue(os.path.exists(zsh), f'Shell integration: {zsh}')
self.assertTrue(os.access(os.path.join(shell_integration_dir, 'ssh', 'askpass.py'), os.X_OK))
if getattr(sys, 'frozen', False):
self.assertTrue(os.path.isdir(local_docs()), f'Local docs: {local_docs()}')

def test_ca_certificates(self):
import ssl
Expand Down
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -1280,6 +1280,8 @@ def create_macos_bundle_gunk(dest: str) -> None:
os.mkdir(ddir / 'Contents')
with open(ddir / 'Contents/Info.plist', 'wb') as fp:
fp.write(macos_info_plist())
copy_man_pages(str(ddir))
copy_html_docs(str(ddir))
os.rename(ddir / 'share', ddir / 'Contents/Resources')
os.rename(ddir / 'bin', ddir / 'Contents/MacOS')
os.rename(ddir / 'lib', ddir / 'Contents/Frameworks')
Expand Down

8 comments on commit 3288400

@page-down
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kovidgoyal
Is it possible to build a macOS App without building the documentation?

Since I need to build the app frequently when developing under macOS, I would like to keep the documentation from becoming a hard dependency so as to shorten the feedback loop, thanks.

Also I have seen that in some Linux distributions the documentation for the software will be separated into a different package. When the documentation is not needed, the user can choose not to install it.

It is suggested in the build page that linux packagers can provide kitty-shell-integration independently, no wonder the shell integration folder is assumed can be removed from the main package.

@kovidgoyal
Copy link
Owner Author

@kovidgoyal kovidgoyal commented on 3288400 Aug 20, 2022 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@page-down
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make app does not include it.

I need to comment out copy_man_pages and copy_html_docs lines to avoid building the documentation.

make app

python3 setup.py kitty.app 
CC: ['clang'] (13, 1)
[67/67] Compiling kitty/gl-wrapper.c ... done
[7/7] Linking launcher ... done
The kitty man pages are missing. If you are building from git then run:
make && make docs
(needs the sphinx documentation system to be installed)

make: *** [app] Error 1

Oh, it's copying the document that has been built. I instead ran the following command before make app.

mkdir -p docs/_build/{man,html}

@kovidgoyal
Copy link
Owner Author

@kovidgoyal kovidgoyal commented on 3288400 Aug 20, 2022 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@page-down
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your reply. These are obvious, in the code.
The lack of its own documentation in the kitty macOS release package has been on my list for a long time, and I'm glad that this issue has been resolved in the recent changes.

... but I guess on macOS for some features you need the bundle.

Yes, so sphinx will be a build-time dependency to run kitty.app from source code and is no longer optional.

Maybe add this to the documentation, before others start questioning this.

Do you think that it is possible to remove Contents/Resources/Python/lib/python3.9/kitty_tests/ from the macOS (and also Linux) release packages? This folder has some fonts for testing.

lib/python3.9/kitty_tests/CascadiaCode-Regular.otf
lib/python3.9/kitty_tests/FiraCode-Medium.otf
lib/python3.9/kitty_tests/LiberationMono-Regular.ttf
lib/python3.9/kitty_tests/iosevka-regular.ttf

There are a lot of empty folders under lib/python3.9 that don't seem to be needed either, maybe I'm wrong.

@kovidgoyal
Copy link
Owner Author

@kovidgoyal kovidgoyal commented on 3288400 Aug 20, 2022 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@page-down
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont see this in the release packages.
Seems to be macOS only ...

Linux releases:
https://github.com/kovidgoyal/kitty/releases/download/nightly/kitty-nightly-x86_64.txz
https://github.com/kovidgoyal/kitty/releases/download/v0.25.2/kitty-0.25.2-x86_64.txz

See the font files and empty folders in the tarball.
It looks like lib/python3.9 could be removed.

@kovidgoyal
Copy link
Owner Author

@kovidgoyal kovidgoyal commented on 3288400 Aug 20, 2022 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.