wazootech-wiki 0.2.2__py3-none-win_amd64.whl

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.
@@ -0,0 +1,4 @@
1
+ [diffend] Oversized file quarantined before diffing.
2
+ name: wazootech_wiki-0.2.2.data/scripts/wiki.exe
3
+ size: 159778749 bytes
4
+ sha256: 5283dd01439f767cf258cd6676d7830a10d1177a8192b17e8f89beb97dc53af2
@@ -0,0 +1,59 @@
1
+ Metadata-Version: 2.4
2
+ Name: wazootech-wiki
3
+ Version: 0.2.2
4
+ Summary: The Wiki CLI as a native binary, with a typed Python API for running it
5
+ License-Expression: MIT
6
+ License-File: LICENSE
7
+ Requires-Python: >=3.10
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Operating System :: MacOS
10
+ Classifier: Operating System :: Microsoft :: Windows
11
+ Classifier: Operating System :: POSIX :: Linux
12
+ Classifier: Typing :: Typed
13
+ Project-URL: Homepage, https://github.com/wazootech/wiki
14
+ Project-URL: Issues, https://github.com/wazootech/wiki/issues
15
+ Project-URL: Changelog, https://github.com/wazootech/wiki/blob/main/CHANGELOG.md
16
+ Description-Content-Type: text/markdown
17
+
18
+ # wazootech-wiki
19
+
20
+ `wazootech-wiki` 0.2.0 and later installs the [Wiki](https://github.com/wazootech/wiki)
21
+ CLI as a native binary, the way ruff and uv ship. Each platform wheel embeds the
22
+ standalone executable that `deno compile` builds from the Deno/TypeScript engine
23
+ and installs it as `wiki` on your `PATH`. No Python runs in the command's hot
24
+ path, and no Deno, Node.js, or download step is needed.
25
+
26
+ ```sh
27
+ pip install wazootech-wiki
28
+ wiki init
29
+ wiki check
30
+ ```
31
+
32
+ Wheels exist for Linux (glibc 2.27+), macOS 12+, and Windows, each on x64 and
33
+ ARM64. Elsewhere (musl Linux such as Alpine), pip installs a binary-less
34
+ fallback whose `wiki` runs a standalone `wazootech-wiki` from `PATH`, and says
35
+ so clearly when there is none.
36
+
37
+ A small typed Python API runs the same binary:
38
+
39
+ ```python
40
+ import wiki
41
+
42
+ result = wiki.run(["check"], cwd="path/to/project")
43
+ if not result.ok:
44
+ print(result.stderr)
45
+ ```
46
+
47
+ `wiki.run` returns a `WikiResult` (`args`, `returncode`, `stdout`, `stderr`,
48
+ `ok`) and always decodes output as UTF-8. `wiki.create_wiki_command` returns
49
+ the argv without running it, and `wiki.find_runtime` reports which binary was
50
+ resolved. Set `WIKI_BINARY` to use a different binary.
51
+
52
+ To upgrade, run `pip install -U wazootech-wiki` (or `uv tool upgrade
53
+ wazootech-wiki`); `wiki upgrade` says the same for a pip-installed binary.
54
+
55
+ Upgrading from 0.1.x: 0.1.23 was the last Python engine release, and its
56
+ Python library API (`Wiki`, `wiki.audit`, and the rest) is gone. See the
57
+ Migration section of the
58
+ [changelog](https://github.com/wazootech/wiki/blob/main/CHANGELOG.md) and the
59
+ [Python API reference](https://github.com/wazootech/wiki/blob/main/docs/wiki/Python_API_Reference.md).
@@ -0,0 +1,10 @@
1
+ wiki/__init__.py,sha256=zQEIyemVfRgEayElz3CM47GDlSU3HwrCOEcsVvXUF4k,855
2
+ wiki/__main__.py,sha256=gHWdST1jadSCa60kjw4NKDteOJ53oTLvfYQMGsPHRxs,2863
3
+ wiki/_runtime.py,sha256=3ti_Qw6nJw6hQ1_Z-9tEdDYdXnnOcJZ9Qqr4ZGI1Vq4,6214
4
+ wiki/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ wiki/_build.py,sha256=PPMHWGD0t2DtEQCqihChVL-qeqwUx3hzq5oYg4mvVII,116
6
+ wazootech_wiki-0.2.2.data/scripts/wiki.exe,sha256=UoPdAUOfdnzyWM1mdteDChDRF3qBkrF-j4m-uX3FOvI,159778749
7
+ wazootech_wiki-0.2.2.dist-info/METADATA,sha256=Ne5DLRDt6C8vaGQ-9nQof5LoOryYEbHgRB_r8AFaxUI,2344
8
+ wazootech_wiki-0.2.2.dist-info/WHEEL,sha256=uRH1l3wKx86ETC5d4514mknYwWzYvfYg1zMhmOeRNd8,115
9
+ wazootech_wiki-0.2.2.dist-info/licenses/LICENSE,sha256=DZI9NzirtH87dAwc7IeqRhO26w-Ymm0l8GYu5JnTkyA,1066
10
+ wazootech_wiki-0.2.2.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: wazootech-wiki scripts/build_wheel.py
3
+ Root-Is-Purelib: false
4
+ Tag: py3-none-win_amd64
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 wazoo.dev
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.
wiki/__init__.py ADDED
@@ -0,0 +1,35 @@
1
+ """Python binding for the Wiki CLI.
2
+
3
+ ``wazootech-wiki`` 0.2.0 and later ships the Wiki CLI as a native binary, not
4
+ a Python engine: each platform wheel embeds the ``deno compile`` standalone
5
+ for its target and installs it as ``wiki``. This package finds that binary and
6
+ runs it. See ``docs/wiki/Python_API_Reference.md``.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ from importlib.metadata import PackageNotFoundError, version
12
+
13
+ from ._runtime import (
14
+ Runtime,
15
+ WikiResult,
16
+ WikiSetupError,
17
+ create_wiki_command,
18
+ find_runtime,
19
+ run,
20
+ )
21
+
22
+ try:
23
+ __version__ = version("wazootech-wiki")
24
+ except PackageNotFoundError: # pragma: no cover - running from a bare checkout
25
+ __version__ = "0.0.0"
26
+
27
+ __all__ = [
28
+ "Runtime",
29
+ "WikiResult",
30
+ "WikiSetupError",
31
+ "__version__",
32
+ "create_wiki_command",
33
+ "find_runtime",
34
+ "run",
35
+ ]
wiki/__main__.py ADDED
@@ -0,0 +1,77 @@
1
+ """``python -m wiki``, and the ``wiki`` console script of the fallback wheel.
2
+
3
+ A platform wheel installs the Wiki binary itself as ``wiki``, so this module
4
+ is not in that hot path; it serves ``python -m wiki`` everywhere, and is the
5
+ ``wiki`` command only in the binary-less ``py3-none-any`` wheel. Its process
6
+ handling mirrors ``bin/wiki.js``: signals are forwarded and exit codes match.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import os
12
+ import signal
13
+ import subprocess
14
+ import sys
15
+ from collections.abc import Sequence
16
+
17
+ from ._runtime import LAUNCHER_ENV, WikiSetupError, child_env, create_wiki_command
18
+
19
+ #: Signals forwarded to the binary, as ``bin/wiki.js`` does. A ``kill`` aimed
20
+ #: at this process alone would otherwise orphan the child.
21
+ FORWARDED_SIGNALS = (signal.SIGINT, signal.SIGTERM)
22
+
23
+
24
+ def main(argv: Sequence[str] | None = None) -> int:
25
+ """Run the Wiki CLI with inherited stdio and return its exit code."""
26
+ if os.environ.get(LAUNCHER_ENV):
27
+ # Everything this package starts carries the marker, so a launcher
28
+ # that sees it was started by a launcher: WIKI_BINARY or
29
+ # `wazootech-wiki` on PATH resolves back to Python, and continuing
30
+ # would recurse without end.
31
+ print(
32
+ "Error: the wazootech-wiki launcher started itself. WIKI_BINARY or "
33
+ "`wazootech-wiki` on PATH is the Python launcher, not a Wiki binary; "
34
+ "point it at a standalone binary from "
35
+ "https://github.com/wazootech/wiki/releases.",
36
+ file=sys.stderr,
37
+ )
38
+ return 1
39
+ try:
40
+ command = create_wiki_command(sys.argv[1:] if argv is None else argv)
41
+ except WikiSetupError as error:
42
+ print(f"Error: {error}", file=sys.stderr)
43
+ return 1
44
+ try:
45
+ child = subprocess.Popen(command, env=child_env())
46
+ except OSError as error:
47
+ print(f"Unable to start the Wiki CLI: {error}", file=sys.stderr)
48
+ return 1
49
+ previous = {}
50
+ if os.name == "posix":
51
+ for signum in FORWARDED_SIGNALS:
52
+ previous[signum] = signal.signal(
53
+ signum, lambda received, _frame: child.send_signal(received)
54
+ )
55
+ try:
56
+ while True:
57
+ try:
58
+ code = child.wait()
59
+ break
60
+ except KeyboardInterrupt:
61
+ # Windows: the child shares the console and gets the same
62
+ # Ctrl-C; let it finish its own shutdown and report its code.
63
+ continue
64
+ finally:
65
+ for signum, handler in previous.items():
66
+ signal.signal(signum, handler)
67
+ # POSIX reports death-by-signal as -N; shells report it as 128 + N, which
68
+ # is also what `bin/wiki.js` returns (130 for SIGINT, 143 for SIGTERM).
69
+ return 128 - code if code < 0 else code
70
+
71
+
72
+ def entry() -> None:
73
+ sys.exit(main())
74
+
75
+
76
+ if __name__ == "__main__":
77
+ entry()
wiki/_build.py ADDED
@@ -0,0 +1,4 @@
1
+ """Written by scripts/build_wheel.py: what this wheel carries."""
2
+
3
+ BUNDLED = True
4
+ TARGET = 'x86_64-pc-windows-msvc'
wiki/_runtime.py ADDED
@@ -0,0 +1,183 @@
1
+ """Locate the Wiki binary and build the argv that runs it.
2
+
3
+ Each platform wheel embeds the ``deno compile`` standalone for its target in
4
+ ``.data/scripts/``, so pip installs it as ``wiki`` (``wiki.exe``) straight onto
5
+ ``PATH`` with no Python in between, the way ruff and uv ship. This module is
6
+ for Python callers: it finds that installed binary and runs it.
7
+
8
+ The ``py3-none-any`` fallback wheel, which pip picks only where no platform
9
+ wheel fits (musl Linux, for example), carries no binary. Its ``wiki`` console
10
+ script is :mod:`wiki.__main__`, which runs a standalone ``wazootech-wiki``
11
+ from ``PATH``.
12
+ """
13
+
14
+ from __future__ import annotations
15
+
16
+ import os
17
+ import shutil
18
+ import subprocess
19
+ import sysconfig
20
+ from collections.abc import Mapping, Sequence
21
+ from dataclasses import dataclass
22
+ from importlib.metadata import PackageNotFoundError, distribution
23
+ from pathlib import Path
24
+ from typing import Literal, Union
25
+
26
+ try:
27
+ # Written into each wheel by `scripts/build_wheel.py`; absent from a
28
+ # source checkout or a plain `pip install .`, which build the fallback.
29
+ from ._build import BUNDLED, TARGET
30
+ except ImportError: # pragma: no cover - only outside a built wheel
31
+ BUNDLED, TARGET = False, None
32
+
33
+ #: The name of the standalone binary on GitHub Releases, as the fallback wheel
34
+ #: expects to find it on ``PATH``. ``wiki`` itself is never looked up: in the
35
+ #: fallback wheel it is this launcher, and running it would recurse.
36
+ STANDALONE_NAME = "wazootech-wiki"
37
+
38
+ #: Set in the environment of every binary this package starts. A launcher
39
+ #: that starts with it already set has been pointed back at itself.
40
+ LAUNCHER_ENV = "WAZOOTECH_WIKI_LAUNCHER"
41
+
42
+ RuntimeKind = Literal["env", "bundled", "path"]
43
+ StrPath = Union[str, "os.PathLike[str]"]
44
+
45
+
46
+ class WikiSetupError(RuntimeError):
47
+ """Raised when no Wiki binary can be found for this install."""
48
+
49
+
50
+ @dataclass(frozen=True)
51
+ class Runtime:
52
+ """The binary that runs the Wiki CLI, and where it came from."""
53
+
54
+ kind: RuntimeKind
55
+ executable: str
56
+
57
+
58
+ @dataclass(frozen=True)
59
+ class WikiResult:
60
+ """The outcome of one :func:`run` call."""
61
+
62
+ args: tuple[str, ...]
63
+ returncode: int
64
+ stdout: str
65
+ stderr: str
66
+
67
+ @property
68
+ def ok(self) -> bool:
69
+ """``True`` when the CLI exited 0."""
70
+ return self.returncode == 0
71
+
72
+
73
+ def _binary_name() -> str:
74
+ return "wiki" + (".exe" if os.name == "nt" else "")
75
+
76
+
77
+ def _bundled_binary() -> Path | None:
78
+ """The binary this wheel installed, wherever pip put the scripts.
79
+
80
+ The dist-info ``RECORD`` holds the installed path of every file, the
81
+ binary included, so it is right for venvs, ``--user``, ``--prefix``, and
82
+ ``uv tool`` alike. The ``sysconfig`` scripts directories are the fallback
83
+ for an installer that wrote no usable ``RECORD``.
84
+ """
85
+ name = _binary_name()
86
+ try:
87
+ files = distribution("wazootech-wiki").files or []
88
+ except PackageNotFoundError:
89
+ files = []
90
+ for entry in files:
91
+ if entry.name == name and ".." in entry.parts:
92
+ located = Path(str(entry.locate())).resolve()
93
+ if located.is_file():
94
+ return located
95
+ for scheme in (sysconfig.get_default_scheme(), f"{os.name}_user"):
96
+ try:
97
+ scripts = sysconfig.get_path("scripts", scheme)
98
+ except KeyError:
99
+ continue
100
+ candidate = Path(scripts) / name
101
+ if candidate.is_file():
102
+ return candidate
103
+ return None
104
+
105
+
106
+ def find_runtime() -> Runtime:
107
+ """Resolve the Wiki binary, first match wins.
108
+
109
+ 1. ``WIKI_BINARY``: an explicit path to a Wiki binary
110
+ 2. the binary embedded in this platform wheel
111
+ 3. in the fallback wheel only, a standalone ``wazootech-wiki`` on ``PATH``
112
+ """
113
+ override = os.environ.get("WIKI_BINARY")
114
+ if override:
115
+ if not Path(override).is_file():
116
+ raise WikiSetupError(f"WIKI_BINARY is set to {override}, which is not a file.")
117
+ return Runtime("env", override)
118
+ if BUNDLED:
119
+ bundled = _bundled_binary()
120
+ if bundled is None:
121
+ raise WikiSetupError(
122
+ f"The Wiki binary this wheel ships for {TARGET} is missing "
123
+ "from the scripts directory. Reinstall wazootech-wiki."
124
+ )
125
+ return Runtime("bundled", str(bundled))
126
+ on_path = shutil.which(STANDALONE_NAME)
127
+ if on_path is not None:
128
+ return Runtime("path", on_path)
129
+ raise WikiSetupError(
130
+ "wazootech-wiki has no Wiki binary for this platform (there are wheels "
131
+ "for Linux glibc, macOS, and Windows on x64 and ARM64; musl Linux, "
132
+ f"such as Alpine, has none). Put a standalone `{STANDALONE_NAME}` on "
133
+ "PATH, or set WIKI_BINARY to one. Standalone binaries: "
134
+ "https://github.com/wazootech/wiki/releases."
135
+ )
136
+
137
+
138
+ def create_wiki_command(args: Sequence[str]) -> list[str]:
139
+ """Build the argv that runs the Wiki CLI with ``args``."""
140
+ if isinstance(args, str):
141
+ raise TypeError("args must be a sequence of strings, not a string")
142
+ return [find_runtime().executable, *args]
143
+
144
+
145
+ def child_env(env: Mapping[str, str] | None = None) -> dict[str, str]:
146
+ """``env`` (default ``os.environ``), marked so a recursive launch fails."""
147
+ marked = dict(os.environ if env is None else env)
148
+ marked[LAUNCHER_ENV] = "1"
149
+ return marked
150
+
151
+
152
+ def run(
153
+ args: Sequence[str],
154
+ *,
155
+ cwd: StrPath | None = None,
156
+ env: Mapping[str, str] | None = None,
157
+ input: str | None = None,
158
+ timeout: float | None = None,
159
+ ) -> WikiResult:
160
+ """Run the Wiki CLI and capture its output.
161
+
162
+ The engine writes UTF-8, so output is always decoded as UTF-8 rather than
163
+ in the platform's locale codepage (see #326). A non-zero exit is returned,
164
+ not raised; check :attr:`WikiResult.ok`.
165
+ """
166
+ command = create_wiki_command(args)
167
+ completed = subprocess.run(
168
+ command,
169
+ cwd=cwd,
170
+ env=child_env(env),
171
+ input=input,
172
+ capture_output=True,
173
+ encoding="utf-8",
174
+ errors="replace",
175
+ timeout=timeout,
176
+ check=False,
177
+ )
178
+ return WikiResult(
179
+ args=tuple(args),
180
+ returncode=completed.returncode,
181
+ stdout=completed.stdout,
182
+ stderr=completed.stderr,
183
+ )
wiki/py.typed ADDED
File without changes