Skip to content

Commit ebd948c

Browse files
committed
Move pybind11 to its own extra
Signed-off-by: Cristian Le <[email protected]>
1 parent 10de684 commit ebd948c

File tree

5 files changed

+23
-3
lines changed

5 files changed

+23
-3
lines changed

.distro/python-scikit-build-core.spec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
%global debug_package %{nil}
22

3+
# Whether to run additional tests, enabled by default
4+
%bcond optional_tests 1
5+
36
Name: python-scikit-build-core
47
Version: 0.0.0
58
Release: %autorelease
@@ -47,7 +50,7 @@ cp -p src/scikit_build_core/_vendor/pyproject_metadata/LICENSE LICENSE-pyproject
4750

4851
%generate_buildrequires
4952
export HATCH_METADATA_CLASSIFIERS_NO_VERIFY=1
50-
%pyproject_buildrequires -g test,test-meta,test-numpy
53+
%pyproject_buildrequires -g test%{?with_optional_tests:,test-meta,test-numpy,test-pybind11}
5154

5255

5356
%build
@@ -62,6 +65,7 @@ export HATCH_METADATA_CLASSIFIERS_NO_VERIFY=1
6265

6366
%check
6467
%pyproject_check_import
68+
# Additional tests from optional_tests are automatically skipped/picked-up by pytest
6569
%pytest \
6670
-m "not network"
6771

pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ test = [
7979
"cattrs >=22.2.0",
8080
"pip>=23; python_version<'3.13'",
8181
"pip>=24.1; python_version>='3.13'",
82-
"pybind11 >=2.11",
8382
"pytest >=7.2",
8483
"pytest-subprocess >=1.5",
8584
'pytest-xdist >=3.1',
@@ -111,6 +110,10 @@ test-schema = [
111110
"fastjsonschema",
112111
"validate-pyproject",
113112
]
113+
test-pybind11 = [
114+
{ include-group = "test" },
115+
"pybind11 >=2.11",
116+
]
114117
cov = [
115118
{ include-group = "test" },
116119
"pytest-cov",
@@ -120,6 +123,7 @@ dev = [
120123
{ include-group = "test-hatchling" },
121124
{ include-group = "test-meta" },
122125
{ include-group = "test-numpy" },
126+
{ include-group = "test-pybind11" },
123127
{ include-group = "test-schema" },
124128
"rich",
125129
]

tests/conftest.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ def pep518_wheelhouse(tmp_path_factory: pytest.TempPathFactory) -> Path:
5151
"cython",
5252
"hatchling",
5353
"pip",
54-
"pybind11",
5554
"setuptools",
5655
"virtualenv",
5756
"wheel",
@@ -63,6 +62,9 @@ def pep518_wheelhouse(tmp_path_factory: pytest.TempPathFactory) -> Path:
6362
if importlib.util.find_spec("ninja") is not None:
6463
packages.append("ninja")
6564

65+
if importlib.util.find_spec("pybind11") is not None:
66+
packages.append("pybind11")
67+
6668
subprocess.run(
6769
[
6870
sys.executable,
@@ -374,6 +376,11 @@ def find_spec(name: str, package: str | None = None) -> Any:
374376
monkeypatch.setattr(importlib.util, "find_spec", find_spec)
375377

376378

379+
@pytest.fixture
380+
def pybind11():
381+
return pytest.importorskip("pybind11")
382+
383+
377384
def pytest_collection_modifyitems(items: list[pytest.Item]) -> None:
378385
for item in items:
379386
# Ensure all tests using virtualenv are marked as such

tests/test_pyproject_pep517.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ def test_passing_cxx_flags(monkeypatch, env_var, setting, tmp_path: Path):
197197
@pytest.mark.compile
198198
@pytest.mark.configure
199199
@pytest.mark.usefixtures("package_simple_pyproject_ext")
200+
@pytest.mark.usefixtures("pybind11")
200201
def test_pep517_wheel(virtualenv, tmp_path: Path):
201202
dist = tmp_path / "dist"
202203
out = build_wheel(
@@ -249,6 +250,7 @@ def test_pep517_wheel(virtualenv, tmp_path: Path):
249250
@pytest.mark.compile
250251
@pytest.mark.configure
251252
@pytest.mark.usefixtures("package_simple_pyproject_source_dir")
253+
@pytest.mark.usefixtures("pybind11")
252254
def test_pep517_wheel_source_dir(virtualenv, tmp_path: Path):
253255
dist = tmp_path / "dist"
254256
out = build_wheel(str(dist), config_settings={"skbuild.wheel.build-tag": "1foo"})

tests/test_setuptools_pep517.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def test_pep517_sdist(tmp_path: Path):
6969
@pytest.mark.configure
7070
@pytest.mark.broken_on_urct
7171
@pytest.mark.usefixtures("package_simple_setuptools_ext")
72+
@pytest.mark.usefixtures("pybind11")
7273
def test_pep517_wheel(virtualenv, tmp_path: Path):
7374
dist = tmp_path / "dist"
7475
out = build_wheel(str(dist))
@@ -149,6 +150,7 @@ def test_toml_sdist(tmp_path: Path):
149150
@pytest.mark.compile
150151
@pytest.mark.configure
151152
@pytest.mark.usefixtures("package_toml_setuptools_ext")
153+
@pytest.mark.usefixtures("pybind11")
152154
@pytest.mark.skipif(
153155
setuptools_version < Version("61.0"), reason="Requires setuptools 61+"
154156
)
@@ -183,6 +185,7 @@ def test_toml_wheel(virtualenv, tmp_path: Path):
183185
@pytest.mark.compile
184186
@pytest.mark.configure
185187
@pytest.mark.usefixtures("package_mixed_setuptools")
188+
@pytest.mark.usefixtures("pybind11")
186189
def test_mixed_wheel(virtualenv, tmp_path: Path):
187190
dist = tmp_path / "dist"
188191
out = build_wheel(str(dist))

0 commit comments

Comments
 (0)