MCPcopy Create free account
hub / github.com/pybind/pybind11 / tests_build_wheel

Function tests_build_wheel

tests/extra_python_package/test_files.py:250–294  ·  view source on GitHub ↗
(monkeypatch, tmpdir)

Source from the content-addressed store, hash-verified

248
249
250def tests_build_wheel(monkeypatch, tmpdir):
251 monkeypatch.chdir(MAIN_DIR)
252
253 subprocess.run(
254 [sys.executable, "-m", "build", "--wheel", "--outdir", str(tmpdir), *UV_ARGS],
255 check=True,
256 )
257
258 (wheel,) = tmpdir.visit("*.whl")
259 version, simple_version = FILENAME_VERSION.search(wheel.basename).groups()
260
261 files = {f"pybind11/{n}" for n in all_files}
262 files |= {
263 "dist-info/licenses/LICENSE",
264 "dist-info/METADATA",
265 "dist-info/RECORD",
266 "dist-info/WHEEL",
267 "dist-info/entry_points.txt",
268 }
269
270 with zipfile.ZipFile(str(wheel)) as z:
271 names = z.namelist()
272 share = zipfile.Path(z, "pybind11/share")
273 pkgconfig = (share / "pkgconfig/pybind11.pc").read_text(encoding="utf-8")
274 cmakeconfig = (share / "cmake/pybind11/pybind11Config.cmake").read_text(
275 encoding="utf-8"
276 )
277 (pkg_info_path,) = (n for n in names if n.endswith("METADATA"))
278 pkg_info = zipfile.Path(z, pkg_info_path).read_text(encoding="utf-8")
279
280 trimmed = {n for n in names if "dist-info" not in n}
281 trimmed |= {f"dist-info/{n.split('/', 1)[-1]}" for n in names if "dist-info" in n}
282
283 assert files == trimmed
284
285 assert 'set(pybind11_INCLUDE_DIR "${PACKAGE_PREFIX_DIR}/include")' in cmakeconfig
286
287 pkgconfig_expected = PKGCONFIG.format(VERSION=simple_version)
288 assert pkgconfig_expected == pkgconfig
289
290 assert f"Version: {version}" in pkg_info
291 assert "License-Expression: BSD-3-Clause" in pkg_info
292 assert "License-File: LICENSE" in pkg_info
293 assert "Provides-Extra: global" in pkg_info
294 assert f'Requires-Dist: pybind11-global=={version}; extra == "global"' in pkg_info
295
296
297def tests_build_global_wheel(monkeypatch, tmpdir):

Callers

nothing calls this directly

Calls 3

strClass · 0.85
runMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected