tuihost 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. tuihost-0.2.0/LICENSE +21 -0
  2. tuihost-0.2.0/PKG-INFO +245 -0
  3. tuihost-0.2.0/README.md +215 -0
  4. tuihost-0.2.0/pyproject.toml +56 -0
  5. tuihost-0.2.0/setup.cfg +4 -0
  6. tuihost-0.2.0/tests/test_bundle.py +240 -0
  7. tuihost-0.2.0/tests/test_cli.py +401 -0
  8. tuihost-0.2.0/tests/test_deps.py +81 -0
  9. tuihost-0.2.0/tests/test_notices.py +77 -0
  10. tuihost-0.2.0/tests/test_signing.py +98 -0
  11. tuihost-0.2.0/tests/test_templates.py +20 -0
  12. tuihost-0.2.0/tests/test_wheelhouse.py +16 -0
  13. tuihost-0.2.0/tuihost/__init__.py +14 -0
  14. tuihost-0.2.0/tuihost/__main__.py +5 -0
  15. tuihost-0.2.0/tuihost/_terminal.py +69 -0
  16. tuihost-0.2.0/tuihost/app.py +448 -0
  17. tuihost-0.2.0/tuihost/build.py +540 -0
  18. tuihost-0.2.0/tuihost/bundle.py +127 -0
  19. tuihost-0.2.0/tuihost/cli.py +98 -0
  20. tuihost-0.2.0/tuihost/config.py +74 -0
  21. tuihost-0.2.0/tuihost/deps.py +334 -0
  22. tuihost-0.2.0/tuihost/fetch_libghostty.py +204 -0
  23. tuihost-0.2.0/tuihost/licenses/ghostty-LICENSE.txt +21 -0
  24. tuihost-0.2.0/tuihost/licenses/puikit-LICENSE.txt +21 -0
  25. tuihost-0.2.0/tuihost/notices.py +385 -0
  26. tuihost-0.2.0/tuihost/script_templates/build_macos.sh +107 -0
  27. tuihost-0.2.0/tuihost/script_templates/build_windows.ps1 +100 -0
  28. tuihost-0.2.0/tuihost/signing.py +212 -0
  29. tuihost-0.2.0/tuihost/state.py +59 -0
  30. tuihost-0.2.0/tuihost/templates.py +52 -0
  31. tuihost-0.2.0/tuihost/wheelhouse.py +80 -0
  32. tuihost-0.2.0/tuihost/window.py +179 -0
  33. tuihost-0.2.0/tuihost.egg-info/PKG-INFO +245 -0
  34. tuihost-0.2.0/tuihost.egg-info/SOURCES.txt +36 -0
  35. tuihost-0.2.0/tuihost.egg-info/dependency_links.txt +1 -0
  36. tuihost-0.2.0/tuihost.egg-info/entry_points.txt +6 -0
  37. tuihost-0.2.0/tuihost.egg-info/requires.txt +9 -0
  38. tuihost-0.2.0/tuihost.egg-info/top_level.txt +1 -0
tuihost-0.2.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 DevTTY
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
tuihost-0.2.0/PKG-INFO ADDED
@@ -0,0 +1,245 @@
1
+ Metadata-Version: 2.4
2
+ Name: tuihost
3
+ Version: 0.2.0
4
+ Summary: Run any TUI in a native desktop window, and bundle it as a macOS/Windows app
5
+ Author: gomesjj
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/gomesjj/tuihost
8
+ Project-URL: Issues, https://github.com/gomesjj/tuihost/issues
9
+ Keywords: tui,terminal,gui,pty,nuitka,packaging
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Environment :: MacOS X
12
+ Classifier: Environment :: Win32 (MS Windows)
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3 :: Only
16
+ Classifier: Topic :: Software Development :: Build Tools
17
+ Classifier: Topic :: Software Development :: User Interfaces
18
+ Classifier: Topic :: Terminals
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: puikit<1.37,>=1.36
23
+ Provides-Extra: dev
24
+ Requires-Dist: pytest>=8; extra == "dev"
25
+ Requires-Dist: build; extra == "dev"
26
+ Requires-Dist: twine; extra == "dev"
27
+ Provides-Extra: build
28
+ Requires-Dist: nuitka>=4.4; extra == "build"
29
+ Dynamic: license-file
30
+
31
+ # TUI Host
32
+
33
+ Runs any TUI (Textual, PuiKit, curses, …) — or a shell — in a native window with an
34
+ embedded terminal (PuiKit `TerminalView` + libghostty-vt), so it gets a Dock/Taskbar
35
+ presence like a desktop app. It can also package a TUI as a standalone macOS app or
36
+ Windows executable.
37
+
38
+ TUI Host uses Nuitka to compile the Python code and create the executables for packaging
39
+ and distribution.
40
+
41
+ > Status: alpha. macOS is tested; Windows support (host, build and signing) is
42
+ > **experimental and not verified on real hardware**.
43
+
44
+ **Terminology.** Two places are used throughout:
45
+
46
+ - **tuihost** — where TUI Host is installed (`pip install tuihost`), or its source
47
+ repository when developing TUI Host itself.
48
+ - **build application** — the repository of *your* TUI (the program you want to ship as
49
+ an app). Packaging steps run there, with tuihost installed in its build environment.
50
+
51
+ ## 1. Run a TUI in a native window
52
+
53
+ *Where: any environment with tuihost installed.*
54
+
55
+ ```sh
56
+ pip install tuihost
57
+ python -m tuihost.fetch_libghostty # macOS / Windows: installs libghostty-vt into PuiKit's _bin/
58
+
59
+ tuihost # your shell in a native window
60
+ tuihost --title "My TUI" -- my-tui # a TUI
61
+ tuihost --help # all options
62
+ ```
63
+
64
+ Several sessions in one app: *File ▸ New Window* (Cmd+N / Ctrl+Shift+N) starts another
65
+ instance of the program, *New Shell Window* (Cmd+T / Ctrl+Shift+T) a shell. Closing a
66
+ window or quitting asks while something still runs.
67
+
68
+ ## 2. Package a TUI as a desktop app
69
+
70
+ ### 2.1 Add a GUI entry script
71
+
72
+ *Where: build application.*
73
+
74
+ ```python
75
+ # my_tui/gui.py
76
+ from my_tui.__main__ import main
77
+
78
+
79
+ def gui_main() -> None:
80
+ try:
81
+ from tuihost import bundle
82
+ except ImportError:
83
+ main()
84
+ return
85
+ bundle.run(main, title="My TUI", cols=120, rows=48)
86
+
87
+
88
+ if __name__ == "__main__":
89
+ gui_main()
90
+ ```
91
+
92
+ ### 2.2 Build with the template scripts (recommended)
93
+
94
+ *Where: first command anywhere tuihost is installed; the rest in the build application.*
95
+
96
+ ```sh
97
+ pip install tuihost
98
+ python -m tuihost.templates all . # or: tuihost-templates all .
99
+ # copies build_macos.sh and build_windows.ps1 into the current directory
100
+ ```
101
+
102
+ Edit the "Application" block at the top of the script (name, package, entry script,
103
+ bundle id, icon), then run it **in the build application** on the target OS:
104
+
105
+ ```sh
106
+ ./build_macos.sh # macOS -> dist-macos/My TUI.app
107
+ .\build_windows.ps1 # Windows (PowerShell) -> dist-windows\…
108
+ ```
109
+
110
+ The scripts create a build venv, install tuihost (`tuihost[build]`) from PyPI, install
111
+ your application, install libghostty-vt, and run `tuihost.build`. They contain no
112
+ project-specific code, so keep them in the application's repository.
113
+
114
+ Settings (environment variables):
115
+
116
+ | Variable | Script | Meaning |
117
+ | --- | --- | --- |
118
+ | `PYTHON` | both | Interpreter for the build venv. On macOS use a python.org build |
119
+ | `MACOS_MIN` | macOS | Oldest macOS supported (default 15.0), checked after the build |
120
+ | `GHOSTTY_ZIP` | both | libghostty-vt release zip (default: wheelhouse, else download) |
121
+ | `TUIHOST_VERSION` | both | tuihost requirement, e.g. `tuihost==0.2.0` |
122
+ | `WHEELHOUSE` | both | Offline build, see section 4 |
123
+ | `SIGN_IDENTITY`, `NOTARIZE`, `NOTARY_*`, `ENTITLEMENTS` | macOS | Signing, see 3.1 |
124
+ | `SIGN_PFX`, `SIGN_PASSWORD`, `SIGN_THUMBPRINT`, `SIGNTOOL` | Windows | Signing, see 3.2 |
125
+
126
+ ### 2.3 Build by hand
127
+
128
+ *Where: build application, in a venv.*
129
+
130
+ ```sh
131
+ pip install "tuihost[build]" -e . # Nuitka + the application
132
+ python -m tuihost.fetch_libghostty
133
+ python -m tuihost.build my_tui/gui.py --name "My TUI" --package my_tui --version 1.0
134
+ ```
135
+
136
+ Result: macOS → `dist/My TUI.app`; Windows → standalone folder.
137
+
138
+ Use a python.org Python on macOS: the build checks every binary against `--macos-min`
139
+ (default 15.0), and a Homebrew Python targets the macOS it was built on. It also fails
140
+ if a binary in the app loads a library from outside it (e.g. from `/opt/homebrew`), which
141
+ would break the app on other Macs (`--no-bundle-check` to build anyway).
142
+
143
+ Every app ships a `THIRD_PARTY_NOTICES.txt` with the license of everything it bundles;
144
+ a component without license text stops the build (`--notices-allow-missing`,
145
+ `--no-notices`). The build also stops if a dependency in the venv is not from a package
146
+ index (e.g. an editable local checkout) or outside a requirement on it; for a
147
+ development build, `TUIHOST_ALLOW_LOCAL=<name>` lets a named one through.
148
+
149
+ ## 3. Code signing
150
+
151
+ *Where: build application (the options are passed through the template scripts, or to
152
+ `python -m tuihost.build`).* Linux builds are not signed.
153
+
154
+ ### 3.1 macOS
155
+
156
+ Default: **ad-hoc** signing. The app runs on the Mac that built it; Gatekeeper blocks
157
+ it elsewhere.
158
+
159
+ For distribution you need a paid Apple Developer Program membership and a
160
+ "Developer ID Application" certificate in the keychain. Then:
161
+
162
+ ```sh
163
+ SIGN_IDENTITY="Developer ID Application: Name (TEAMID)" ./build_macos.sh # signed
164
+ SIGN_IDENTITY="…" NOTARIZE=1 NOTARY_PROFILE=my-profile ./build_macos.sh # + notarized
165
+ ```
166
+
167
+ Create the keychain profile once with
168
+ `xcrun notarytool store-credentials my-profile` (recommended). Alternatively set
169
+ `NOTARY_APPLE_ID`, `NOTARY_TEAM_ID` and `NOTARY_PASSWORD` (an app-specific password).
170
+ `notarytool` only accepts the password as an argument, so it is briefly visible in the
171
+ process list (it is redacted from the build output); prefer the profile on shared machines.
172
+
173
+ The same with `tuihost.build`: `--macos-sign-identity`, `--macos-notarize`,
174
+ `--macos-keychain-profile` or `--macos-apple-id` + `--macos-team-id`,
175
+ `--macos-entitlements`. Signing is inside-out with the hardened runtime and a secure
176
+ timestamp; notarization submits, waits, staples and validates. Defaults can also come
177
+ from `TUIHOST_MACOS_SIGN_IDENTITY`, `TUIHOST_NOTARY_PROFILE`, `TUIHOST_NOTARY_APPLE_ID`,
178
+ `TUIHOST_NOTARY_TEAM_ID`, `TUIHOST_NOTARY_PASSWORD`. The Developer ID/notarization
179
+ path has not been exercised against a real account yet.
180
+
181
+ ### 3.2 Windows (experimental)
182
+
183
+ Default: unsigned (SmartScreen warns on other PCs). Authenticode signing uses
184
+ `signtool` (Windows SDK), with a PFX file or a certificate in the store/on a token:
185
+
186
+ ```powershell
187
+ $env:SIGN_PFX = "C:\certs\mycert.pfx"; $env:SIGN_PASSWORD = "…"; .\build_windows.ps1
188
+ python -m tuihost.build … --windows-sign-thumbprint <sha1>
189
+ ```
190
+
191
+ `tuihost.build` options: `--windows-sign-pfx`, `--windows-sign-thumbprint`,
192
+ `--windows-timestamp-url`, `--signtool`, and `--windows-sign-args` (raw extra signtool
193
+ arguments, e.g. for a cloud signing service; it takes the rest of the command line, so
194
+ put it **last**). The PFX password comes from `TUIHOST_WINDOWS_SIGN_PASSWORD`; like
195
+ notarytool, signtool takes it as an argument.
196
+
197
+ Certificate options (cost and effort vary; check current prices and rules):
198
+
199
+ - An OV or EV code-signing certificate from a certificate authority. Since 2023 the key
200
+ must live on a hardware token or HSM. EV gives immediate SmartScreen reputation.
201
+ - A cloud signing service (Azure Trusted Signing, SignPath, …), via `--windows-sign-args`.
202
+ - For internal use: an MSIX package signed with a certificate your PCs trust (enterprise
203
+ CA, or a self-signed one installed on them). tuihost does not make MSIX packages yet.
204
+
205
+ ## 4. Without internet access
206
+
207
+ *Where: step 1 on a machine with internet and the same OS, architecture and Python as the
208
+ build machine; step 2 on the build machine, in the build application.*
209
+
210
+ ```sh
211
+ python -m tuihost.wheelhouse ~/wheelhouse --app ~/repos/my-tui # 1. online machine
212
+ WHEELHOUSE=~/wheelhouse ./build_macos.sh # 2. build machine
213
+ ```
214
+
215
+ Or by hand:
216
+
217
+ ```sh
218
+ pip install --no-index --find-links ~/wheelhouse "tuihost[build]"
219
+ python -m tuihost.fetch_libghostty --zip ~/wheelhouse/ghostty/ghostty-vt-*.zip
220
+ ```
221
+
222
+ On Windows Nuitka downloads MinGW64/ccache on first use; carry its cache over separately.
223
+
224
+ ## 5. Developing and releasing tuihost
225
+
226
+ *Where: the tuihost source repository.*
227
+
228
+ ```sh
229
+ pip install -e ".[dev]"
230
+ python -m tuihost.fetch_libghostty
231
+ python -m pytest -q
232
+
233
+ # release: bump __version__ in tuihost/__init__.py, commit, then
234
+ python scripts/release_preflight.py X.Y.Z
235
+ git tag vX.Y.Z
236
+ python -m build && twine check --strict dist/* && twine upload dist/*
237
+ ```
238
+
239
+ ## Security notes
240
+
241
+ - libghostty-vt downloads are pinned and SHA-256-verified.
242
+ - The hosted program gets the window's environment; run only programs you trust.
243
+ - Signing passwords are read from environment variables, never stored by tuihost.
244
+
245
+ More details: [design document](https://github.com/gomesjj/tuihost/blob/main/docs/design/embedded-terminal-host.md).
@@ -0,0 +1,215 @@
1
+ # TUI Host
2
+
3
+ Runs any TUI (Textual, PuiKit, curses, …) — or a shell — in a native window with an
4
+ embedded terminal (PuiKit `TerminalView` + libghostty-vt), so it gets a Dock/Taskbar
5
+ presence like a desktop app. It can also package a TUI as a standalone macOS app or
6
+ Windows executable.
7
+
8
+ TUI Host uses Nuitka to compile the Python code and create the executables for packaging
9
+ and distribution.
10
+
11
+ > Status: alpha. macOS is tested; Windows support (host, build and signing) is
12
+ > **experimental and not verified on real hardware**.
13
+
14
+ **Terminology.** Two places are used throughout:
15
+
16
+ - **tuihost** — where TUI Host is installed (`pip install tuihost`), or its source
17
+ repository when developing TUI Host itself.
18
+ - **build application** — the repository of *your* TUI (the program you want to ship as
19
+ an app). Packaging steps run there, with tuihost installed in its build environment.
20
+
21
+ ## 1. Run a TUI in a native window
22
+
23
+ *Where: any environment with tuihost installed.*
24
+
25
+ ```sh
26
+ pip install tuihost
27
+ python -m tuihost.fetch_libghostty # macOS / Windows: installs libghostty-vt into PuiKit's _bin/
28
+
29
+ tuihost # your shell in a native window
30
+ tuihost --title "My TUI" -- my-tui # a TUI
31
+ tuihost --help # all options
32
+ ```
33
+
34
+ Several sessions in one app: *File ▸ New Window* (Cmd+N / Ctrl+Shift+N) starts another
35
+ instance of the program, *New Shell Window* (Cmd+T / Ctrl+Shift+T) a shell. Closing a
36
+ window or quitting asks while something still runs.
37
+
38
+ ## 2. Package a TUI as a desktop app
39
+
40
+ ### 2.1 Add a GUI entry script
41
+
42
+ *Where: build application.*
43
+
44
+ ```python
45
+ # my_tui/gui.py
46
+ from my_tui.__main__ import main
47
+
48
+
49
+ def gui_main() -> None:
50
+ try:
51
+ from tuihost import bundle
52
+ except ImportError:
53
+ main()
54
+ return
55
+ bundle.run(main, title="My TUI", cols=120, rows=48)
56
+
57
+
58
+ if __name__ == "__main__":
59
+ gui_main()
60
+ ```
61
+
62
+ ### 2.2 Build with the template scripts (recommended)
63
+
64
+ *Where: first command anywhere tuihost is installed; the rest in the build application.*
65
+
66
+ ```sh
67
+ pip install tuihost
68
+ python -m tuihost.templates all . # or: tuihost-templates all .
69
+ # copies build_macos.sh and build_windows.ps1 into the current directory
70
+ ```
71
+
72
+ Edit the "Application" block at the top of the script (name, package, entry script,
73
+ bundle id, icon), then run it **in the build application** on the target OS:
74
+
75
+ ```sh
76
+ ./build_macos.sh # macOS -> dist-macos/My TUI.app
77
+ .\build_windows.ps1 # Windows (PowerShell) -> dist-windows\…
78
+ ```
79
+
80
+ The scripts create a build venv, install tuihost (`tuihost[build]`) from PyPI, install
81
+ your application, install libghostty-vt, and run `tuihost.build`. They contain no
82
+ project-specific code, so keep them in the application's repository.
83
+
84
+ Settings (environment variables):
85
+
86
+ | Variable | Script | Meaning |
87
+ | --- | --- | --- |
88
+ | `PYTHON` | both | Interpreter for the build venv. On macOS use a python.org build |
89
+ | `MACOS_MIN` | macOS | Oldest macOS supported (default 15.0), checked after the build |
90
+ | `GHOSTTY_ZIP` | both | libghostty-vt release zip (default: wheelhouse, else download) |
91
+ | `TUIHOST_VERSION` | both | tuihost requirement, e.g. `tuihost==0.2.0` |
92
+ | `WHEELHOUSE` | both | Offline build, see section 4 |
93
+ | `SIGN_IDENTITY`, `NOTARIZE`, `NOTARY_*`, `ENTITLEMENTS` | macOS | Signing, see 3.1 |
94
+ | `SIGN_PFX`, `SIGN_PASSWORD`, `SIGN_THUMBPRINT`, `SIGNTOOL` | Windows | Signing, see 3.2 |
95
+
96
+ ### 2.3 Build by hand
97
+
98
+ *Where: build application, in a venv.*
99
+
100
+ ```sh
101
+ pip install "tuihost[build]" -e . # Nuitka + the application
102
+ python -m tuihost.fetch_libghostty
103
+ python -m tuihost.build my_tui/gui.py --name "My TUI" --package my_tui --version 1.0
104
+ ```
105
+
106
+ Result: macOS → `dist/My TUI.app`; Windows → standalone folder.
107
+
108
+ Use a python.org Python on macOS: the build checks every binary against `--macos-min`
109
+ (default 15.0), and a Homebrew Python targets the macOS it was built on. It also fails
110
+ if a binary in the app loads a library from outside it (e.g. from `/opt/homebrew`), which
111
+ would break the app on other Macs (`--no-bundle-check` to build anyway).
112
+
113
+ Every app ships a `THIRD_PARTY_NOTICES.txt` with the license of everything it bundles;
114
+ a component without license text stops the build (`--notices-allow-missing`,
115
+ `--no-notices`). The build also stops if a dependency in the venv is not from a package
116
+ index (e.g. an editable local checkout) or outside a requirement on it; for a
117
+ development build, `TUIHOST_ALLOW_LOCAL=<name>` lets a named one through.
118
+
119
+ ## 3. Code signing
120
+
121
+ *Where: build application (the options are passed through the template scripts, or to
122
+ `python -m tuihost.build`).* Linux builds are not signed.
123
+
124
+ ### 3.1 macOS
125
+
126
+ Default: **ad-hoc** signing. The app runs on the Mac that built it; Gatekeeper blocks
127
+ it elsewhere.
128
+
129
+ For distribution you need a paid Apple Developer Program membership and a
130
+ "Developer ID Application" certificate in the keychain. Then:
131
+
132
+ ```sh
133
+ SIGN_IDENTITY="Developer ID Application: Name (TEAMID)" ./build_macos.sh # signed
134
+ SIGN_IDENTITY="…" NOTARIZE=1 NOTARY_PROFILE=my-profile ./build_macos.sh # + notarized
135
+ ```
136
+
137
+ Create the keychain profile once with
138
+ `xcrun notarytool store-credentials my-profile` (recommended). Alternatively set
139
+ `NOTARY_APPLE_ID`, `NOTARY_TEAM_ID` and `NOTARY_PASSWORD` (an app-specific password).
140
+ `notarytool` only accepts the password as an argument, so it is briefly visible in the
141
+ process list (it is redacted from the build output); prefer the profile on shared machines.
142
+
143
+ The same with `tuihost.build`: `--macos-sign-identity`, `--macos-notarize`,
144
+ `--macos-keychain-profile` or `--macos-apple-id` + `--macos-team-id`,
145
+ `--macos-entitlements`. Signing is inside-out with the hardened runtime and a secure
146
+ timestamp; notarization submits, waits, staples and validates. Defaults can also come
147
+ from `TUIHOST_MACOS_SIGN_IDENTITY`, `TUIHOST_NOTARY_PROFILE`, `TUIHOST_NOTARY_APPLE_ID`,
148
+ `TUIHOST_NOTARY_TEAM_ID`, `TUIHOST_NOTARY_PASSWORD`. The Developer ID/notarization
149
+ path has not been exercised against a real account yet.
150
+
151
+ ### 3.2 Windows (experimental)
152
+
153
+ Default: unsigned (SmartScreen warns on other PCs). Authenticode signing uses
154
+ `signtool` (Windows SDK), with a PFX file or a certificate in the store/on a token:
155
+
156
+ ```powershell
157
+ $env:SIGN_PFX = "C:\certs\mycert.pfx"; $env:SIGN_PASSWORD = "…"; .\build_windows.ps1
158
+ python -m tuihost.build … --windows-sign-thumbprint <sha1>
159
+ ```
160
+
161
+ `tuihost.build` options: `--windows-sign-pfx`, `--windows-sign-thumbprint`,
162
+ `--windows-timestamp-url`, `--signtool`, and `--windows-sign-args` (raw extra signtool
163
+ arguments, e.g. for a cloud signing service; it takes the rest of the command line, so
164
+ put it **last**). The PFX password comes from `TUIHOST_WINDOWS_SIGN_PASSWORD`; like
165
+ notarytool, signtool takes it as an argument.
166
+
167
+ Certificate options (cost and effort vary; check current prices and rules):
168
+
169
+ - An OV or EV code-signing certificate from a certificate authority. Since 2023 the key
170
+ must live on a hardware token or HSM. EV gives immediate SmartScreen reputation.
171
+ - A cloud signing service (Azure Trusted Signing, SignPath, …), via `--windows-sign-args`.
172
+ - For internal use: an MSIX package signed with a certificate your PCs trust (enterprise
173
+ CA, or a self-signed one installed on them). tuihost does not make MSIX packages yet.
174
+
175
+ ## 4. Without internet access
176
+
177
+ *Where: step 1 on a machine with internet and the same OS, architecture and Python as the
178
+ build machine; step 2 on the build machine, in the build application.*
179
+
180
+ ```sh
181
+ python -m tuihost.wheelhouse ~/wheelhouse --app ~/repos/my-tui # 1. online machine
182
+ WHEELHOUSE=~/wheelhouse ./build_macos.sh # 2. build machine
183
+ ```
184
+
185
+ Or by hand:
186
+
187
+ ```sh
188
+ pip install --no-index --find-links ~/wheelhouse "tuihost[build]"
189
+ python -m tuihost.fetch_libghostty --zip ~/wheelhouse/ghostty/ghostty-vt-*.zip
190
+ ```
191
+
192
+ On Windows Nuitka downloads MinGW64/ccache on first use; carry its cache over separately.
193
+
194
+ ## 5. Developing and releasing tuihost
195
+
196
+ *Where: the tuihost source repository.*
197
+
198
+ ```sh
199
+ pip install -e ".[dev]"
200
+ python -m tuihost.fetch_libghostty
201
+ python -m pytest -q
202
+
203
+ # release: bump __version__ in tuihost/__init__.py, commit, then
204
+ python scripts/release_preflight.py X.Y.Z
205
+ git tag vX.Y.Z
206
+ python -m build && twine check --strict dist/* && twine upload dist/*
207
+ ```
208
+
209
+ ## Security notes
210
+
211
+ - libghostty-vt downloads are pinned and SHA-256-verified.
212
+ - The hosted program gets the window's environment; run only programs you trust.
213
+ - Signing passwords are read from environment variables, never stored by tuihost.
214
+
215
+ More details: [design document](https://github.com/gomesjj/tuihost/blob/main/docs/design/embedded-terminal-host.md).
@@ -0,0 +1,56 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "tuihost"
7
+ description = "Run any TUI in a native desktop window, and bundle it as a macOS/Windows app"
8
+ license = "MIT"
9
+ license-files = ["LICENSE"]
10
+ authors = [ { name = "gomesjj" } ]
11
+ keywords = ["tui", "terminal", "gui", "pty", "nuitka", "packaging"]
12
+ requires-python = ">=3.10"
13
+ dynamic = [ "version", "readme" ]
14
+ classifiers = [
15
+ "Development Status :: 3 - Alpha",
16
+ "Environment :: MacOS X",
17
+ "Environment :: Win32 (MS Windows)",
18
+ "Intended Audience :: Developers",
19
+ "Operating System :: OS Independent",
20
+ "Programming Language :: Python :: 3 :: Only",
21
+ "Topic :: Software Development :: Build Tools",
22
+ "Topic :: Software Development :: User Interfaces",
23
+ "Topic :: Terminals",
24
+ ]
25
+ dependencies = [
26
+ # HostTerminalView and window.py use PuiKit internals: pin the minor version.
27
+ "puikit>=1.36,<1.37",
28
+ ]
29
+
30
+ [project.optional-dependencies]
31
+ dev = ["pytest>=8", "build", "twine"]
32
+ build = ["nuitka>=4.4"]
33
+
34
+ [project.urls]
35
+ Homepage = "https://github.com/gomesjj/tuihost"
36
+ Issues = "https://github.com/gomesjj/tuihost/issues"
37
+
38
+ [project.scripts]
39
+ tuihost = "tuihost.cli:main"
40
+ tuihost-fetch-libghostty = "tuihost.fetch_libghostty:main"
41
+ tuihost-build = "tuihost.build:main"
42
+ tuihost-notices = "tuihost.notices:main"
43
+ tuihost-templates = "tuihost.templates:main"
44
+
45
+ [tool.setuptools.packages.find]
46
+ include = ["tuihost*"]
47
+
48
+ [tool.setuptools.package-data]
49
+ tuihost = ["licenses/*.txt", "script_templates/*"]
50
+
51
+ [tool.setuptools.dynamic]
52
+ version = { attr = "tuihost.__version__" }
53
+ readme = { file = ["README.md"], content-type = "text/markdown" }
54
+
55
+ [tool.pytest.ini_options]
56
+ testpaths = ["tests"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+