Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .distro/python-scikit-build-core.spec
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
%global debug_package %{nil}

# Whether to run additional tests, enabled by default
%bcond optional_tests 1

Name: python-scikit-build-core
Version: 0.0.0
Release: %autorelease
Expand Down Expand Up @@ -47,7 +50,7 @@ cp -p src/scikit_build_core/_vendor/pyproject_metadata/LICENSE LICENSE-pyproject

%generate_buildrequires
export HATCH_METADATA_CLASSIFIERS_NO_VERIFY=1
%pyproject_buildrequires -g test,test-meta,test-numpy
%pyproject_buildrequires -g test%{?with_optional_tests:,test-meta,test-numpy,test-pybind11}


%build
Expand All @@ -62,6 +65,7 @@ export HATCH_METADATA_CLASSIFIERS_NO_VERIFY=1

%check
%pyproject_check_import
# Additional tests from optional_tests are automatically skipped/picked-up by pytest
%pytest \
-m "not network"

Expand Down
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ test = [
"cattrs >=22.2.0",
"pip>=23; python_version<'3.13'",
"pip>=24.1; python_version>='3.13'",
"pybind11 >=2.11",
"pytest >=7.2",
"pytest-subprocess >=1.5",
'pytest-xdist >=3.1',
Expand Down Expand Up @@ -111,6 +110,10 @@ test-schema = [
"fastjsonschema",
"validate-pyproject",
]
test-pybind11 = [
{ include-group = "test" },
"pybind11 >=2.11",
]
cov = [
{ include-group = "test" },
"pytest-cov",
Expand All @@ -120,6 +123,7 @@ dev = [
{ include-group = "test-hatchling" },
{ include-group = "test-meta" },
{ include-group = "test-numpy" },
{ include-group = "test-pybind11" },
{ include-group = "test-schema" },
"rich",
]
Expand Down
9 changes: 8 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def pep518_wheelhouse(tmp_path_factory: pytest.TempPathFactory) -> Path:
"cython",
"hatchling",
"pip",
"pybind11",
"setuptools",
"virtualenv",
"wheel",
Expand All @@ -63,6 +62,9 @@ def pep518_wheelhouse(tmp_path_factory: pytest.TempPathFactory) -> Path:
if importlib.util.find_spec("ninja") is not None:
packages.append("ninja")

if importlib.util.find_spec("pybind11") is not None:
packages.append("pybind11")

subprocess.run(
[
sys.executable,
Expand Down Expand Up @@ -374,6 +376,11 @@ def find_spec(name: str, package: str | None = None) -> Any:
monkeypatch.setattr(importlib.util, "find_spec", find_spec)


@pytest.fixture
def pybind11():
return pytest.importorskip("pybind11")


def pytest_collection_modifyitems(items: list[pytest.Item]) -> None:
for item in items:
# Ensure all tests using virtualenv are marked as such
Expand Down
2 changes: 2 additions & 0 deletions tests/test_pyproject_pep517.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ def test_passing_cxx_flags(monkeypatch, env_var, setting, tmp_path: Path):
@pytest.mark.compile
@pytest.mark.configure
@pytest.mark.usefixtures("package_simple_pyproject_ext")
@pytest.mark.usefixtures("pybind11")
def test_pep517_wheel(virtualenv, tmp_path: Path):
dist = tmp_path / "dist"
out = build_wheel(
Expand Down Expand Up @@ -249,6 +250,7 @@ def test_pep517_wheel(virtualenv, tmp_path: Path):
@pytest.mark.compile
@pytest.mark.configure
@pytest.mark.usefixtures("package_simple_pyproject_source_dir")
@pytest.mark.usefixtures("pybind11")
def test_pep517_wheel_source_dir(virtualenv, tmp_path: Path):
dist = tmp_path / "dist"
out = build_wheel(str(dist), config_settings={"skbuild.wheel.build-tag": "1foo"})
Expand Down
4 changes: 4 additions & 0 deletions tests/test_pyproject_pep518.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def compute_uncompressed_hash(inp: Path):

@pytest.mark.network
@pytest.mark.integration
@pytest.mark.usefixtures("pybind11")
def test_pep518_sdist(isolated, package_simple_pyproject_ext, tmp_path: Path):
correct_metadata = textwrap.dedent(
"""\
Expand Down Expand Up @@ -166,6 +167,7 @@ def test_pep518_wheel_sdist_with_cmake_config(
@pytest.mark.configure
@pytest.mark.integration
@pytest.mark.usefixtures("package_simple_pyproject_ext")
@pytest.mark.usefixtures("pybind11")
@pytest.mark.parametrize(
"build_args", [(), ("--wheel",)], ids=["sdist_to_wheel", "wheel_directly"]
)
Expand Down Expand Up @@ -211,6 +213,7 @@ def test_pep518_wheel(isolated, build_args, tmp_path: Path):
"build_args", [(), ("--wheel",)], ids=["sdist_to_wheel", "wheel_directly"]
)
@pytest.mark.usefixtures("package_simple_pyproject_ext")
@pytest.mark.usefixtures("pybind11")
def test_pep518_rebuild_build_dir(isolated, tmp_path, build_args):
isolated.install("build[virtualenv]")

Expand Down Expand Up @@ -256,6 +259,7 @@ def test_pep518_rebuild_build_dir(isolated, tmp_path, build_args):
@pytest.mark.configure
@pytest.mark.integration
@pytest.mark.usefixtures("package_simple_pyproject_ext")
@pytest.mark.usefixtures("pybind11")
def test_pep518_pip(isolated):
isolated.install("-v", ".")

Expand Down
3 changes: 3 additions & 0 deletions tests/test_setuptools_pep517.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def test_pep517_sdist(tmp_path: Path):
@pytest.mark.configure
@pytest.mark.broken_on_urct
@pytest.mark.usefixtures("package_simple_setuptools_ext")
@pytest.mark.usefixtures("pybind11")
def test_pep517_wheel(virtualenv, tmp_path: Path):
dist = tmp_path / "dist"
out = build_wheel(str(dist))
Expand Down Expand Up @@ -149,6 +150,7 @@ def test_toml_sdist(tmp_path: Path):
@pytest.mark.compile
@pytest.mark.configure
@pytest.mark.usefixtures("package_toml_setuptools_ext")
@pytest.mark.usefixtures("pybind11")
@pytest.mark.skipif(
setuptools_version < Version("61.0"), reason="Requires setuptools 61+"
)
Expand Down Expand Up @@ -183,6 +185,7 @@ def test_toml_wheel(virtualenv, tmp_path: Path):
@pytest.mark.compile
@pytest.mark.configure
@pytest.mark.usefixtures("package_mixed_setuptools")
@pytest.mark.usefixtures("pybind11")
def test_mixed_wheel(virtualenv, tmp_path: Path):
dist = tmp_path / "dist"
out = build_wheel(str(dist))
Expand Down
2 changes: 2 additions & 0 deletions tests/test_setuptools_pep518.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
strict=False,
)
@pytest.mark.usefixtures("package_simple_setuptools_ext")
@pytest.mark.usefixtures("pybind11")
def test_pep518_wheel(isolated, tmp_path: Path):
dist = tmp_path / "dist"
isolated.install("build[virtualenv]")
Expand Down Expand Up @@ -56,6 +57,7 @@ def test_pep518_wheel(isolated, tmp_path: Path):
strict=False,
)
@pytest.mark.usefixtures("package_simple_setuptools_ext")
@pytest.mark.usefixtures("pybind11")
def test_pep518_pip(isolated):
isolated.install("-v", ".")

Expand Down
Loading