Skip to content

Commit 7253136

Browse files
committed
fix: test and fix pinning
Signed-off-by: Henry Schreiner <[email protected]>
1 parent ce7aec7 commit 7253136

File tree

4 files changed

+42
-6
lines changed

4 files changed

+42
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,4 @@ CMakeUserPresents.json
5050
/tmp*
5151
.ruby-version
5252
.*cache*/
53+
*.lock

pyproject.toml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ keywords = [
3131
"C++11",
3232
"Python bindings",
3333
]
34-
dynamic = ["version"]
34+
dynamic = ["version", "optional-dependencies"]
3535
requires-python = ">=3.8"
3636

3737
[project.urls]
@@ -42,9 +42,6 @@ Discussions = "https://github.com/pybind/pybind11/discussions"
4242
Changelog = "https://pybind11.readthedocs.io/en/latest/changelog.html"
4343
Chat = "https://gitter.im/pybind/Lobby"
4444

45-
[project.optional-dependencies]
46-
global = ["pybind11-global"] # TODO: pin
47-
4845
[project.scripts]
4946
pybind11-config = "pybind11.__main__:main"
5047

@@ -55,6 +52,15 @@ pybind11 = "pybind11.__main__:main"
5552
pybind11 = "pybind11.share.pkgconfig"
5653

5754

55+
[dependency-groups]
56+
test = [
57+
"pytest",
58+
"build",
59+
"tomlkit",
60+
]
61+
dev = [{ include-group = "test" }]
62+
63+
5864
[tool.scikit-build]
5965
minimum-version = "build-system.requires"
6066
sdist.exclude = [
@@ -101,9 +107,11 @@ version_info = tuple(_to_int(s) for s in __version__.split("."))
101107
'''
102108

103109

104-
# Can't use tool.uv.sources with requirements.txt
105110
[tool.uv]
111+
# Can't use tool.uv.sources with requirements.txt
106112
index-strategy = "unsafe-best-match"
113+
# This extra confuses uv
114+
override-dependencies = ["pybind11-global"]
107115

108116

109117
[tool.mypy]

tests/extra_python_package/test_files.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,16 +184,23 @@ def test_build_sdist(monkeypatch, tmpdir):
184184
)
185185

186186
(sdist,) = tmpdir.visit("*.tar.gz")
187+
version = sdist.basename.split("-")[1][:-7]
187188

188189
with tarfile.open(str(sdist), "r:gz") as tar:
189190
simpler = {n.split("/", 1)[-1] for n in tar.getnames()[1:]}
191+
(pkg_info_path,) = (n for n in simpler if n.endswith("PKG-INFO"))
190192

191193
pyproject_toml = read_tz_file(tar, "pyproject.toml")
194+
pkg_info = read_tz_file(tar, pkg_info_path).decode("utf-8")
192195

193196
files = headers | sdist_files
194197
assert files <= simpler
195198

196199
assert b'name = "pybind11"' in pyproject_toml
200+
assert "License-Expression: BSD-3-Clause" in pkg_info
201+
assert "License-File: LICENSE" in pkg_info
202+
assert "Provides-Extra: global" in pkg_info
203+
assert f'Requires-Dist: pybind11-global=={version}; extra == "global"' in pkg_info
197204

198205

199206
def test_build_global_dist(monkeypatch, tmpdir):
@@ -216,13 +223,19 @@ def test_build_global_dist(monkeypatch, tmpdir):
216223

217224
with tarfile.open(str(sdist), "r:gz") as tar:
218225
simpler = {n.split("/", 1)[-1] for n in tar.getnames()[1:]}
226+
(pkg_info_path,) = (n for n in simpler if n.endswith("PKG-INFO"))
219227

220228
pyproject_toml = read_tz_file(tar, "pyproject.toml")
229+
pkg_info = read_tz_file(tar, pkg_info_path).decode("utf-8")
221230

222231
files = headers | sdist_files
223232
assert files <= simpler
224233

225234
assert b'name = "pybind11-global"' in pyproject_toml
235+
assert "License-Expression: BSD-3-Clause" in pkg_info
236+
assert "License-File: LICENSE" in pkg_info
237+
assert "Provides-Extra: global" not in pkg_info
238+
assert 'Requires-Dist: pybind11-global; extra == "global"' not in pkg_info
226239

227240

228241
def tests_build_wheel(monkeypatch, tmpdir):
@@ -251,6 +264,8 @@ def tests_build_wheel(monkeypatch, tmpdir):
251264
cmakeconfig = (share / "cmake/pybind11/pybind11Config.cmake").read_text(
252265
encoding="utf-8"
253266
)
267+
(pkg_info_path,) = (n for n in names if n.endswith("METADATA"))
268+
pkg_info = zipfile.Path(z, pkg_info_path).read_text(encoding="utf-8")
254269

255270
trimmed = {n for n in names if "dist-info" not in n}
256271
trimmed |= {f"dist-info/{n.split('/', 1)[-1]}" for n in names if "dist-info" in n}
@@ -264,6 +279,11 @@ def tests_build_wheel(monkeypatch, tmpdir):
264279
pkgconfig_expected = PKGCONFIG.format(VERSION=simple_version)
265280
assert pkgconfig_expected == pkgconfig
266281

282+
assert "License-Expression: BSD-3-Clause" in pkg_info
283+
assert "License-File: LICENSE" in pkg_info
284+
assert "Provides-Extra: global" in pkg_info
285+
assert f'Requires-Dist: pybind11-global=={version}; extra == "global"' in pkg_info
286+
267287

268288
def tests_build_global_wheel(monkeypatch, tmpdir):
269289
monkeypatch.chdir(MAIN_DIR)
@@ -303,6 +323,14 @@ def tests_build_global_wheel(monkeypatch, tmpdir):
303323
encoding="utf-8"
304324
)
305325

326+
(pkg_info_path,) = (n for n in names if n.endswith("METADATA"))
327+
pkg_info = zipfile.Path(z, pkg_info_path).read_text(encoding="utf-8")
328+
329+
assert "License-Expression: BSD-3-Clause" in pkg_info
330+
assert "License-File: LICENSE" in pkg_info
331+
assert "Provides-Extra: global" not in pkg_info
332+
assert 'Requires-Dist: pybind11-global; extra == "global"' not in pkg_info
333+
306334
trimmed = {n[len(beginning) + 1 :] for n in names}
307335

308336
assert files == trimmed

tools/make_global.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
def get_global() -> str:
1717
pyproject = tomlkit.parse(PYPROJECT.read_text())
1818
del pyproject["tool"]["scikit-build"]["generate"]
19-
del pyproject["project"]["optional-dependencies"]
2019
del pyproject["project"]["entry-points"]
2120
del pyproject["project"]["scripts"]
2221
del pyproject["tool"]["scikit-build"]["metadata"]["optional-dependencies"]

0 commit comments

Comments
 (0)