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

Function tests_build_global_wheel

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

Source from the content-addressed store, hash-verified

295
296
297def tests_build_global_wheel(monkeypatch, tmpdir):
298 monkeypatch.chdir(MAIN_DIR)
299 with build_global():
300 subprocess.run(
301 [
302 sys.executable,
303 "-m",
304 "build",
305 "--wheel",
306 "--outdir",
307 str(tmpdir),
308 *UV_ARGS,
309 ],
310 check=True,
311 )
312
313 (wheel,) = tmpdir.visit("*.whl")
314 version, simple_version = FILENAME_VERSION.search(wheel.basename).groups()
315
316 files = {f"data/data/{n}" for n in headers}
317 files |= {f"data/headers/{n[8:]}" for n in headers}
318 files |= {f"data/data/{n}" for n in generated_files}
319 files |= {
320 "dist-info/licenses/LICENSE",
321 "dist-info/METADATA",
322 "dist-info/WHEEL",
323 "dist-info/RECORD",
324 }
325
326 with zipfile.ZipFile(str(wheel)) as z:
327 names = z.namelist()
328 beginning = names[0].split("/", 1)[0].rsplit(".", 1)[0]
329
330 share = zipfile.Path(z, f"{beginning}.data/data/share")
331 pkgconfig = (share / "pkgconfig/pybind11.pc").read_text(encoding="utf-8")
332 cmakeconfig = (share / "cmake/pybind11/pybind11Config.cmake").read_text(
333 encoding="utf-8"
334 )
335
336 (pkg_info_path,) = (n for n in names if n.endswith("METADATA"))
337 pkg_info = zipfile.Path(z, pkg_info_path).read_text(encoding="utf-8")
338
339 assert f"Version: {version}" in pkg_info
340 assert "License-Expression: BSD-3-Clause" in pkg_info
341 assert "License-File: LICENSE" in pkg_info
342 assert "Provides-Extra: global" not in pkg_info
343 assert 'Requires-Dist: pybind11-global; extra == "global"' not in pkg_info
344
345 trimmed = {n[len(beginning) + 1 :] for n in names}
346
347 assert files == trimmed
348
349 assert 'set(pybind11_INCLUDE_DIR "${PACKAGE_PREFIX_DIR}/include")' in cmakeconfig
350
351 pkgconfig_expected = PKGCONFIG.format(VERSION=simple_version)
352 assert pkgconfig_expected == pkgconfig
353
354

Callers

nothing calls this directly

Calls 5

strClass · 0.85
lenFunction · 0.85
build_globalFunction · 0.70
runMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected