Skip to content

Commit bbca3ba

Browse files
authored
Merge pull request #153 from thisisthepy/feat/design-systems
Layered material3 row and the fork's design systems as pythonx.compose modules, with surface guards
2 parents 28dd28b + 3069325 commit bbca3ba

48 files changed

Lines changed: 2808 additions & 39 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎README.md‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,13 @@ flowchart LR
7979
| `pythonx.compose.runtime` | `androidx.compose.runtime` |
8080
| `pythonx.compose.ui` | `androidx.compose.ui` |
8181
| `pythonx.compose.layout` | `androidx.compose.foundation.layout` |
82-
| `pythonx.compose.material3` | `androidx.compose.material3` |
82+
| `pythonx.compose.material3` | `org.thisisthepy.compose.material3`, then `androidx.compose.material3` |
83+
| `pythonx.compose.cupertino`, `.fluent`, `.gnome`, `.breeze`, `.deepin`, `.liquidglass`, `.designsystem` | `org.thisisthepy.compose.<same>` |
84+
85+
A row may list several packages: a name comes from the first that declares it, so
86+
`pythonx.compose.material3` adds the fork's Material 3 design system (`MaterialButton`,
87+
`materialDesignSystem`) in front of Material 3 itself. The fork's design systems are not on Maven
88+
Central yet, so until python-multiplatform serves them their modules import but resolve no names.
8389

8490
Each module is a real file whose `__init__.py` calls one re-export rule; names resolve on first use.
8591
`Column`, `Row` and `Spacer` are importable from `pythonx.compose.material3` as well as

‎docs/INTENT.md‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,20 @@ them.
202202
alias or compatibility shim. A screen keeps state the notebook's way, with `remember_saveable`
203203
inside `App` (§5.9), or with `mutable_state_of`. The app root's own state stays internal to this
204204
package.
205+
12. **`material3` and the fork's design systems** (owner, 2026-11-13, relayed by the leader; #54). The
206+
owner, verbatim: "org.thisisthepy.compose.material3 저게 .compose 경로에 다른 디자인 시스템들도
207+
있어. 그거 쓰면 되는데?" The decision: `pythonx.compose.material3` maps to the fork's design-system
208+
package `org.thisisthepy.compose.material3` (`compose-multiplatform-core-extended`,
209+
`extended/design-systems/material3`), and the other design systems, `breeze`, `cupertino`, `deepin`,
210+
`fluent`, `gnome` and `liquid-glass` (packages `org.thisisthepy.compose.<name>`, on
211+
`org.thisisthepy.compose.designsystem`), are exposed the same way as `pythonx.compose.<name>`, each
212+
with a regression guard.
213+
214+
> Agent proposal, not confirmed by the owner (#152): the means. The `material3` row lists the
215+
> design-system package **before** `androidx.compose.material3` rather than replacing it, because
216+
> `UI.ipynb` imports `Text`, `Button`, `Card`, `TextField` from `pythonx.compose.material3` and only
217+
> `androidx.compose.material3` declares them (the design-system package declares
218+
> `Material3DesignSystem`, `materialDesignSystem` and `MaterialButton`). The shared contract is
219+
> exposed as `pythonx.compose.designsystem`, and Liquid Glass as `pythonx.compose.liquidglass`
220+
> (its Kotlin package's last segment). The regression guard is a committed public-surface snapshot
221+
> per module (SPEC §2.1).

‎docs/SPEC.md‎

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,11 @@ Current mapping:
282282
| `pythonx.compose.runtime` | `androidx.compose.runtime` |
283283
| `pythonx.compose.ui` (+ `.unit`, `.text`, `.graphics`) | `androidx.compose.ui` (+ same) |
284284
| `pythonx.compose.layout` | `androidx.compose.foundation.layout` |
285-
| `pythonx.compose.material3` | `androidx.compose.material3` |
285+
| `pythonx.compose.material3` | `org.thisisthepy.compose.material3`, then `androidx.compose.material3` (§2.1) |
286286
| `pythonx.compose.material.icons` | `androidx.compose.material.icons` |
287287
| `pythonx.compose.foundation.text.input` | `androidx.compose.foundation.text.input` (S5.5) |
288+
| `pythonx.compose.designsystem` | `org.thisisthepy.compose.designsystem` (§2.1) |
289+
| `pythonx.compose.breeze`, `.cupertino`, `.deepin`, `.fluent`, `.gnome`, `.liquidglass` | `org.thisisthepy.compose.<same>` (§2.1) |
288290

289291
**`[aliases]`** lends a module names from another mapped module, as data. Two forms, both under
290292
`[aliases."<owner module>"]` keyed by the source module: a list of names lent under the **same**
@@ -305,6 +307,44 @@ notebook is git-ignored, so in a worktree or CI checkout it is absent, the expec
305307
and **the test passes without checking anything.** It is only meaningful in the maintainer's main
306308
checkout.
307309

310+
### S2.1 Layered rows and the fork's design systems: `implemented` (served once the binder walks them)
311+
312+
INTENT §5.12 (owner, 2026-11-13; the means are an agent proposal, #152). A row is one Kotlin package
313+
or a list of them. A name is looked up in each listed package in order and the **first that declares
314+
it wins**; a listed package the binder does not serve is skipped; if it serves none, reading a name
315+
is an `AttributeError` that names every package. `dir()` lists every served layer. The stub generator
316+
merges a listed row the same way: the first layer the `kotlin-stubs` artefact has converts as a
317+
one-package row always did, and each later layer adds only the declarations the layers before it do
318+
not define, with the imports they need.
319+
320+
`pythonx.compose.material3` is `["org.thisisthepy.compose.material3", "androidx.compose.material3"]`.
321+
The design systems are `pythonx.compose.designsystem`, `.breeze`, `.cupertino`, `.deepin`, `.fluent`,
322+
`.gnome` and `.liquidglass`. None of `extended/design-systems` is on Maven Central (checked
323+
2026-11-13), so python-multiplatform serves none of them: today every `material3` name comes from
324+
`androidx.compose.material3`, the design-system modules import but every name read raises
325+
`AttributeError`, and their stubs are header-only.
326+
327+
**Regression guard.** `tests/fixtures/surfaces/<module>.txt` is the recorded public surface of each of
328+
those eight modules, read from its committed stub by `scripts/surface.py`: one line per declaration
329+
(functions and methods with parameter names, `=...` for a default, and return type, one line per
330+
overload; classes; annotated names; re-exported names). Parameter types are left out, since the
331+
binder's typing of a parameter improving is not a regression. A regenerated stub may add lines; one
332+
that drops or changes a recorded line fails unless `tests/fixtures/surfaces/allowlist.toml` lists
333+
that line with a reason. A module whose snapshot is empty fails as soon as its stub declares
334+
anything, so its snapshot is recorded the first time the binder serves it.
335+
336+
| Behaviour | Test |
337+
|---|---|
338+
| The rows: `material3` lists the design system first; every design system has its row; a row is a package or a non-empty list | `tests/test_design_systems.py::TheRows` |
339+
| Run time: first layer wins, later layers fill in, unserved layers are skipped, errors name every package, `dir()` lists all | `tests/test_design_systems.py::TheRuntimeSearchesTheLayersInOrder` |
340+
| The generator merges layers the same way; a one-package list equals a string row | `tests/test_design_systems.py::TheGeneratorMergesTheLayers` |
341+
| Surface snapshots exist, lose nothing unacknowledged, empty ones stay empty until recorded; the guard fails on a dropped line | `tests/test_design_systems.py::TheSurfaceGuard` |
342+
| Each design system is a package on disk that imports without a binder | `tests/test_design_systems.py::ThePackagesOnDisk` |
343+
344+
Not done here: publishing `extended/design-systems` (the fork's side, darkpyonix team) and
345+
python-multiplatform walking it; the design-system `material3` module also declares no
346+
`macosArm64`/`linuxX64` target (S1.4).
347+
308348
## 3. `pythonx` is a real package: `implemented` (module level)
309349

310350
Required by INTENT §2.2: `import pythonx.compose.material3` (and every other mapped module) loads

‎docs/guide/guide-manifest.html‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@
3838
<section>
3939
<h2><span data-lang="en">Mapping a module</span><span data-lang="ko">모듈 대응시키기</span></h2>
4040
<pre><code class="language-toml">[modules]
41-
&quot;pythonx.compose.material3&quot; = &quot;androidx.compose.material3&quot;
42-
&quot;pythonx.compose.layout&quot; = &quot;androidx.compose.foundation.layout&quot;</code></pre>
41+
&quot;pythonx.compose.material3&quot; = [&quot;org.thisisthepy.compose.material3&quot;, &quot;androidx.compose.material3&quot;]
42+
&quot;pythonx.compose.layout&quot; = &quot;androidx.compose.foundation.layout&quot;
43+
&quot;pythonx.compose.cupertino&quot; = &quot;org.thisisthepy.compose.cupertino&quot;</code></pre>
44+
<p data-lang="en">A row may list several Kotlin packages. A name comes from the first one that declares it, and a package the binder does not serve is skipped: <code>material3</code> puts the fork&#x27;s Material 3 design system in front of Material 3 itself. The fork&#x27;s design systems (<code>cupertino</code>, <code>fluent</code>, <code>gnome</code>, <code>breeze</code>, <code>deepin</code>, <code>liquidglass</code>, and their contract <code>designsystem</code>) have rows too; they are not on Maven Central yet, so they resolve no names until python-multiplatform serves them.</p><p data-lang="ko">한 줄에 Kotlin 패키지를 여러 개 적을 수 있습니다. 이름은 그것을 선언한 첫 패키지에서 오고, 바인더가 제공하지 않는 패키지는 건너뜁니다: <code>material3</code> 는 Material 3 앞에 포크의 Material 3 디자인 시스템을 둡니다. 포크의 디자인 시스템(<code>cupertino</code>, <code>fluent</code>, <code>gnome</code>, <code>breeze</code>, <code>deepin</code>, <code>liquidglass</code>, 그리고 공통 계약 <code>designsystem</code>)도 줄이 있습니다. 아직 Maven Central 에 없으므로 python-multiplatform 이 제공하기 전까지 이름을 해석하지 않습니다.</p>
4345
<p data-lang="en">The second row is why the mapping is written down rather than derived: it drops <code>foundation.</code> from the middle of the name, which no prefix rule can do.</p><p data-lang="ko">두 번째 줄이 대응을 유도하지 않고 적어 두는 이유입니다: 이름 중간의 <code>foundation.</code> 을 빼는 것은 어떤 접두사 규칙으로도 할 수 없습니다.</p>
4446
<p data-lang="en">Every row is a real file on disk: a new <code>pythonx.compose.*</code> module gets a row here and an <code>__init__.py</code> that calls <code>reexport(__name__)</code>, in the same change.</p><p data-lang="ko">모든 줄은 디스크에 있는 실제 파일입니다: 새 <code>pythonx.compose.*</code> 모듈은 같은 변경 안에서 여기 한 줄과, <code>reexport(__name__)</code> 를 부르는 <code>__init__.py</code> 를 함께 얻습니다.</p>
4547
</section>

‎docs/locale/README_ko.md‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,13 @@ flowchart LR
7777
| `pythonx.compose.runtime` | `androidx.compose.runtime` |
7878
| `pythonx.compose.ui` | `androidx.compose.ui` |
7979
| `pythonx.compose.layout` | `androidx.compose.foundation.layout` |
80-
| `pythonx.compose.material3` | `androidx.compose.material3` |
80+
| `pythonx.compose.material3` | `org.thisisthepy.compose.material3`, 그다음 `androidx.compose.material3` |
81+
| `pythonx.compose.cupertino`, `.fluent`, `.gnome`, `.breeze`, `.deepin`, `.liquidglass`, `.designsystem` | `org.thisisthepy.compose.<같은 이름>` |
82+
83+
한 줄에 패키지를 여러 개 적을 수 있습니다: 이름은 그것을 선언한 첫 패키지에서 오므로,
84+
`pythonx.compose.material3` 는 Material 3 앞에 포크의 Material 3 디자인 시스템(`MaterialButton`,
85+
`materialDesignSystem`)을 더합니다. 포크의 디자인 시스템은 아직 Maven Central 에 없으므로,
86+
python-multiplatform 이 이를 제공하기 전까지 해당 모듈은 import 되지만 이름을 해석하지 않습니다.
8187

8288
각 모듈은 재노출 규칙 하나를 부르는 `__init__.py` 를 가진 실제 파일이며, 이름은 처음 쓸 때
8389
해석됩니다. `Column`, `Row`, `Spacer` 는 노트북이 쓰는 대로 `pythonx.compose.layout` 뿐 아니라

‎pythonx/compose/__init__.pyi‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# GENERATED by scripts/gen_stubs.py from python-multiplatform's Kotlin-named stubs (artifact ks, workflow run 42402779166, commit 9507e6dd, Compose 1.11.1-ext.2). Do not edit.
1+
# GENERATED by scripts/gen_stubs.py from python-multiplatform's Kotlin-named stubs (artifact kotlin-stubs, workflow run 42402779166, commit 9507e6dd, Compose 1.11.1-ext.2). Do not edit.

‎pythonx/compose/_reexport.py‎

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
Manifest = TypedDict(
7070
"Manifest",
7171
{
72-
"modules": dict[str, str],
72+
"modules": dict[str, "str | list[str]"],
7373
"value-classes": _ValueClasses,
7474
"aliases": dict[str, dict[str, "list[str] | dict[str, str]"]],
7575
},
@@ -114,13 +114,18 @@ def manifest() -> Manifest:
114114
return cast(Manifest, tomllib.load(handle))
115115

116116

117-
def kotlin_package_of(module_name: str) -> str:
117+
def kotlin_packages_of(module_name: str) -> tuple[str, ...]:
118+
"""The Kotlin packages [module_name]'s row names, in the order a name is looked up in them.
119+
120+
A row is one package or a list of them (SPEC S2.1): the first package that declares a name wins.
121+
"""
118122
try:
119-
return manifest()["modules"][module_name]
123+
row = manifest()["modules"][module_name]
120124
except KeyError:
121125
raise LookupError(
122126
f"{module_name} has no row in pythonx-map.toml; a re-exported module needs one"
123127
) from None
128+
return (row,) if isinstance(row, str) else tuple(row)
124129

125130

126131
def binding_layer() -> BindingLayer:
@@ -163,10 +168,24 @@ def _prime(binding: BindingLayer) -> None:
163168
_PRIMED.add(binding)
164169

165170

166-
def kotlin_module(module_name: str) -> types.ModuleType:
167-
"""The binder's module for the Kotlin package `module_name` maps to."""
171+
def kotlin_modules(module_name: str) -> list[types.ModuleType]:
172+
"""The binder's modules for the Kotlin packages `module_name` maps to, in lookup order.
173+
174+
A listed package the binder does not serve is skipped: the fork's design systems are listed before
175+
the packages they build on and are not served until they are published (#152). An `ImportError`
176+
naming every package means the binder serves none of them.
177+
"""
168178
_prime(binding_layer())
169-
return importlib.import_module(kotlin_package_of(module_name))
179+
served: list[types.ModuleType] = []
180+
missing: list[str] = []
181+
for package in kotlin_packages_of(module_name):
182+
try:
183+
served.append(importlib.import_module(package))
184+
except ImportError:
185+
missing.append(package)
186+
if not served:
187+
raise ImportError(f"the binder serves none of {', '.join(missing)}")
188+
return served
170189

171190

172191
def _name_table(kotlin: types.ModuleType) -> dict[str, str]:
@@ -439,16 +458,20 @@ def __getattr__(name: str) -> object:
439458
if borrowed is not None:
440459
return _borrow(module_name, name, *borrowed)
441460
try:
442-
kotlin = kotlin_module(module_name)
461+
layers = kotlin_modules(module_name)
443462
except ImportError as missing:
444463
raise AttributeError(
445464
f"module {module_name!r} has no attribute {name!r} ({missing})"
446465
) from missing
447-
resolved = _resolve(kotlin, name)
466+
# The first layer that declares the name answers (SPEC S2.1).
467+
resolved = next(
468+
(found for kotlin in layers if (found := _resolve(kotlin, name)) is not None), None
469+
)
448470
if resolved is None:
471+
searched = ", ".join(kotlin.__name__ for kotlin in layers)
449472
raise AttributeError(
450473
f"module {module_name!r} has no attribute {name!r} (nothing in Kotlin package "
451-
f"{kotlin.__name__} is spelled that way under pythonx's naming rule)"
474+
f"{searched} is spelled that way under pythonx's naming rule)"
452475
)
453476
value, cacheable = resolved
454477
if cacheable:
@@ -458,7 +481,8 @@ def __getattr__(name: str) -> object:
458481
def __dir__() -> list[str]:
459482
own = set(cast(Mapping[str, object], vars(sys.modules[module_name]))) | set(_aliases(module_name))
460483
try:
461-
own.update(_name_table(kotlin_module(module_name)))
484+
for kotlin in kotlin_modules(module_name):
485+
own.update(_name_table(kotlin))
462486
except (RuntimeError, ImportError):
463487
pass
464488
return sorted(own)

‎pythonx/compose/breeze/__init__.py‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""`pythonx.compose.breeze`: the Pythonic view of `org.thisisthepy.compose.breeze`, KDE Breeze (`BreezeDesignSystem`).
2+
3+
From the fork `compose-multiplatform-core-extended`, `extended/design-systems/breeze`, exposed by the
4+
owner's decision of 2026-11-13 (#54, #152). Served by the one rule in `pythonx/compose/_reexport.py`:
5+
Kotlin's own declarations, upper-case names kept, keyword arguments in snake_case. Nothing is
6+
written here by hand.
7+
8+
The design systems are not on Maven Central yet, so the binder serves no `org.thisisthepy.compose.breeze` and every
9+
name read here raises `AttributeError` until python-multiplatform walks the published artefact. Its
10+
stub is empty until then, and `tests/test_design_systems.py` fails the day it is not, until its
11+
surface snapshot is recorded (`scripts/surface.py`).
12+
"""
13+
14+
from pythonx.compose._reexport import reexport
15+
16+
__getattr__, __dir__ = reexport(__name__)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# GENERATED by scripts/gen_stubs.py from python-multiplatform's Kotlin-named stubs (artifact kotlin-stubs, workflow run 42402779166, commit 9507e6dd, Compose 1.11.1-ext.2). Do not edit.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""`pythonx.compose.cupertino`: the Pythonic view of `org.thisisthepy.compose.cupertino`, Apple's Cupertino (`CupertinoDesignSystem`, `CupertinoSurface`, and its `Modifier` extensions).
2+
3+
From the fork `compose-multiplatform-core-extended`, `extended/design-systems/cupertino`, exposed by the
4+
owner's decision of 2026-11-13 (#54, #152). Served by the one rule in `pythonx/compose/_reexport.py`:
5+
Kotlin's own declarations, upper-case names kept, keyword arguments in snake_case. Nothing is
6+
written here by hand.
7+
8+
The design systems are not on Maven Central yet, so the binder serves no `org.thisisthepy.compose.cupertino` and every
9+
name read here raises `AttributeError` until python-multiplatform walks the published artefact. Its
10+
stub is empty until then, and `tests/test_design_systems.py` fails the day it is not, until its
11+
surface snapshot is recorded (`scripts/surface.py`).
12+
"""
13+
14+
from pythonx.compose._reexport import reexport
15+
16+
__getattr__, __dir__ = reexport(__name__)

0 commit comments

Comments
 (0)