@@ -51,6 +51,119 @@ jobs:
5151 set -euo pipefail
5252 python setup.py bdist_wheel
5353
54+ - name : Check wheel layout
55+ run : |
56+ set -euo pipefail
57+ python - <<'PY'
58+ from pathlib import Path
59+ from zipfile import ZipFile
60+
61+ # The wheel ships a kconfiglib package, not fifteen loose modules in
62+ # site-packages. Nothing outside kconfiglib/ but metadata.
63+ #
64+ # That everything the console scripts name is present, importable and
65+ # has the named attribute is checked by resolving them for real in the
66+ # next step, which is strictly stronger than matching paths here.
67+ wheel = next(Path("dist").glob("*.whl"))
68+ with ZipFile(wheel) as archive:
69+ names = set(archive.namelist())
70+
71+ stray = sorted(
72+ name
73+ for name in names
74+ if not name.startswith("kconfiglib/") and ".dist-info/" not in name
75+ )
76+ assert not stray, f"unexpected wheel members: {stray}"
77+ assert "kconfiglib/__init__.py" in names
78+
79+ print(f"{len(names)} members, nothing outside the package")
80+ PY
81+
82+ - name : Check wheel install
83+ run : |
84+ set -euo pipefail
85+ python -m venv /tmp/wheel-env
86+ /tmp/wheel-env/bin/pip install dist/*.whl
87+ # The wheel's own list of console scripts, for the check below
88+ python - <<'PY'
89+ from pathlib import Path
90+ from zipfile import ZipFile
91+
92+ wheel = next(Path("dist").glob("*.whl"))
93+ with ZipFile(wheel) as archive:
94+ name = next(
95+ n for n in archive.namelist()
96+ if n.endswith(".dist-info/entry_points.txt")
97+ )
98+ Path("/tmp/declared.txt").write_bytes(archive.read(name))
99+ PY
100+ export DECLARED=/tmp/declared.txt
101+ # Not from the checkout: the root kconfiglib.py shadows the installed
102+ # package whenever it is the working directory.
103+ cd "$(mktemp -d)"
104+ /tmp/wheel-env/bin/python - <<'PY'
105+ import importlib
106+ import os
107+ from importlib.metadata import entry_points
108+ from pathlib import Path
109+
110+ import kconfiglib
111+
112+ assert kconfiglib.Kconfig
113+
114+ # Resolve every console script the way the generated wrapper does, so
115+ # a module that is present but broken, or a renamed main(), fails here
116+ # rather than the first time a user runs it.
117+ #
118+ # Selected by module prefix rather than asserted over every script in
119+ # the environment, which would also cover pip's, and rather than via
120+ # distribution("kconfiglib"), which picks whichever metadata directory
121+ # comes first when a stray egg-info is on the path.
122+ installed = {
123+ e.name: e
124+ for e in entry_points(group="console_scripts")
125+ if e.module.startswith("kconfiglib.")
126+ }
127+
128+ # Against the wheel's own declaration, so that dropping a script
129+ # still fails here rather than passing because the others survived.
130+ declared = {
131+ line.split("=", 1)[0].strip()
132+ for line in Path(os.environ["DECLARED"]).read_text().splitlines()
133+ if "=" in line and not line.startswith("[")
134+ }
135+ assert declared, "the wheel declares no console scripts"
136+ assert set(installed) == declared, (
137+ f"declared {sorted(declared)}, installed {sorted(installed)}"
138+ )
139+ installed = list(installed.values())
140+
141+ for entry in installed:
142+ if entry.module == "kconfiglib.guiconfig":
143+ try:
144+ import tkinter # noqa: F401
145+ except ImportError:
146+ print(f"no tkinter, skipping {entry.name}")
147+ continue
148+ assert callable(entry.load()), entry.name
149+
150+ # These two ship no script of their own
151+ for module in ("kconfiglib.rawterm", "kconfiglib.uicommon"):
152+ importlib.import_module(module)
153+
154+ print(f"{len(installed)} console scripts resolve")
155+ PY
156+ /tmp/wheel-env/bin/genconfig --help > /dev/null
157+
158+ - name : Check editable install
159+ run : |
160+ set -euo pipefail
161+ python -m pip install --editable .
162+ # The root kconfiglib.py shadows the package whenever the checkout is
163+ # the working directory, so verify the install from somewhere else.
164+ cd "$(mktemp -d)"
165+ python -c "from kconfiglib import Kconfig; import kconfiglib.menuconfig"
166+
54167 - name : List built artifacts
55168 run : |
56169 set -euo pipefail
0 commit comments