ape-linux 0.4.1__tar.gz → 0.4.2__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.
- {ape_linux-0.4.1 → ape_linux-0.4.2}/CLAUDE.md +5 -3
- {ape_linux-0.4.1 → ape_linux-0.4.2}/PKG-INFO +1 -1
- {ape_linux-0.4.1 → ape_linux-0.4.2}/ape_linux.py +19 -0
- {ape_linux-0.4.1 → ape_linux-0.4.2}/pyproject.toml +1 -1
- {ape_linux-0.4.1 → ape_linux-0.4.2}/tests/test_app.py +22 -0
- {ape_linux-0.4.1 → ape_linux-0.4.2}/.github/workflows/publish.yaml +0 -0
- {ape_linux-0.4.1 → ape_linux-0.4.2}/.github/workflows/tests.yaml +0 -0
- {ape_linux-0.4.1 → ape_linux-0.4.2}/.gitignore +0 -0
- {ape_linux-0.4.1 → ape_linux-0.4.2}/.python-version +0 -0
- {ape_linux-0.4.1 → ape_linux-0.4.2}/LICENSE +0 -0
- {ape_linux-0.4.1 → ape_linux-0.4.2}/README.md +0 -0
- {ape_linux-0.4.1 → ape_linux-0.4.2}/justfile +0 -0
- {ape_linux-0.4.1 → ape_linux-0.4.2}/uv.lock +0 -0
|
@@ -59,9 +59,11 @@ The flow in `ape_linux.py` is intentionally minimal:
|
|
|
59
59
|
directly change what the tool outputs. `main()` then appends a system-context block
|
|
60
60
|
(see below) so suggestions match the current machine.
|
|
61
61
|
2a. `detect_system_context()` returns a best-effort, newline-separated `Key: value`
|
|
62
|
-
block describing the current machine (OS family + macOS/distro version,
|
|
63
|
-
userland, CPU arch, `$SHELL`, root-or-not, available
|
|
64
|
-
list of common tools).
|
|
62
|
+
block describing the current machine (OS family + macOS/distro version, whether the
|
|
63
|
+
Linux host is WSL, GNU-vs-BSD userland, CPU arch, `$SHELL`, root-or-not, available
|
|
64
|
+
package managers, and a probed list of common tools). WSL is detected (Linux only)
|
|
65
|
+
from the `WSL_DISTRO_NAME`/`WSL_INTEROP` env vars or `"microsoft"` in
|
|
66
|
+
`platform.uname().release`. Two invariants: it **never raises** (every probe is guarded,
|
|
65
67
|
so an unavailable API or missing file just omits that field instead of crashing at
|
|
66
68
|
startup), and it **never includes identifying info** (no username, hostname, working
|
|
67
69
|
directory, or home path). Everything is stdlib (`platform`, `os`, `shutil.which`) and
|
|
@@ -91,6 +91,25 @@ def detect_system_context() -> str:
|
|
|
91
91
|
if distribution:
|
|
92
92
|
lines.append(f"Distribution: {distribution}")
|
|
93
93
|
|
|
94
|
+
# WSL (Windows Subsystem for Linux). WSL2 sets WSL_DISTRO_NAME /
|
|
95
|
+
# WSL_INTEROP, and both WSL1 and WSL2 ship a kernel whose release
|
|
96
|
+
# string contains "microsoft" (e.g. 5.15.0-microsoft-standard-WSL2).
|
|
97
|
+
# platform.uname() never raises. This matters because Windows drives
|
|
98
|
+
# are mounted under /mnt and interop tools like clip.exe are available.
|
|
99
|
+
try:
|
|
100
|
+
release = platform.uname().release
|
|
101
|
+
except Exception:
|
|
102
|
+
release = ""
|
|
103
|
+
if (
|
|
104
|
+
os.environ.get("WSL_DISTRO_NAME")
|
|
105
|
+
or os.environ.get("WSL_INTEROP")
|
|
106
|
+
or "microsoft" in release.lower()
|
|
107
|
+
):
|
|
108
|
+
lines.append(
|
|
109
|
+
"WSL: yes (Windows Subsystem for Linux; "
|
|
110
|
+
"Windows drives under /mnt, interop tools like clip.exe available)"
|
|
111
|
+
)
|
|
112
|
+
|
|
94
113
|
# CPU architecture (e.g. arm64 vs x86_64) — affects Homebrew prefixes and
|
|
95
114
|
# binary/platform names. Never raises; may be empty.
|
|
96
115
|
machine = platform.machine()
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import getpass
|
|
2
2
|
import os
|
|
3
|
+
import platform
|
|
3
4
|
import socket
|
|
4
5
|
|
|
5
6
|
import pytest
|
|
@@ -125,6 +126,27 @@ def test_detect_system_context_returns_str_and_never_crashes():
|
|
|
125
126
|
assert isinstance(context, str)
|
|
126
127
|
|
|
127
128
|
|
|
129
|
+
def test_detect_system_context_reports_wsl(monkeypatch):
|
|
130
|
+
# Force the Linux branch and a WSL marker, regardless of the host.
|
|
131
|
+
monkeypatch.setattr(ape_linux.platform, "system", lambda: "Linux")
|
|
132
|
+
monkeypatch.setenv("WSL_DISTRO_NAME", "Ubuntu")
|
|
133
|
+
context = ape_linux.detect_system_context()
|
|
134
|
+
assert "WSL: yes" in context
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def test_detect_system_context_omits_wsl_when_absent(monkeypatch):
|
|
138
|
+
monkeypatch.setattr(ape_linux.platform, "system", lambda: "Linux")
|
|
139
|
+
monkeypatch.delenv("WSL_DISTRO_NAME", raising=False)
|
|
140
|
+
monkeypatch.delenv("WSL_INTEROP", raising=False)
|
|
141
|
+
monkeypatch.setattr(
|
|
142
|
+
ape_linux.platform, "uname", lambda: platform.uname_result(
|
|
143
|
+
"Linux", "host", "5.15.0-generic", "#1", "x86_64"
|
|
144
|
+
)
|
|
145
|
+
)
|
|
146
|
+
context = ape_linux.detect_system_context()
|
|
147
|
+
assert "WSL:" not in context
|
|
148
|
+
|
|
149
|
+
|
|
128
150
|
def test_detect_system_context_reports_operating_system():
|
|
129
151
|
# platform.system() is non-empty on every supported platform.
|
|
130
152
|
context = ape_linux.detect_system_context()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|