Skip to content
Merged
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
9 changes: 5 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,19 +121,20 @@ jobs:
run:
uv pip install
-e.[test,test-meta,test-numpy,test-schema,test-hatchling,wheels,cov,wheel-free-setuptools]
--system
pytest-xdist --system

- name: Install package (pip)
if: matrix.python-version == 'pypy-3.8'
run:
pip install
-e.[test,test-meta,test-numpy,test-schema,wheels,cov,wheel-free-setuptools]
pytest-xdist

- name: Test package
if: "!contains(matrix.python_version, 'pypy')"
run: >-
pytest -ra --showlocals --cov --cov-report=xml --cov-report=term
--durations=20
pytest -ra --showlocals --cov --cov-report=xml --cov-report=term -n
auto --durations=20

- name: Test package (two attempts)
uses: nick-fields/retry@v3
Expand All @@ -144,7 +145,7 @@ jobs:
timeout_seconds: 5
command: >-
pytest -ra --showlocals --cov --cov-report=xml --cov-report=term
--durations=20
--durations=20 -n auto

- name: Upload coverage report
uses: codecov/codecov-action@v5
Expand Down
2 changes: 2 additions & 0 deletions docs/about/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ CI and testing:
- Update deployment a bit by @henryiii in #922
- Use astral-sh/setup-uv instead by @henryiii in #923
- Simpler noxfile by @henryiii in #924
- Test on Linux ARM & Python 3.14 alphas by @henryiii in #1003
- Support for parallel testing by @henryiii in #1004

Docs:

Expand Down
4 changes: 2 additions & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def _run_tests(
run_args: Sequence[str] = (),
extras: Sequence[str] = (),
) -> None:
posargs = list(session.posargs)
posargs = list(session.posargs) or ["-n", "auto"]
env = {"PIP_DISABLE_PIP_VERSION_CHECK": "1"}

_prepare_cmake_ninja(session)
Expand All @@ -74,7 +74,7 @@ def _run_tests(
posargs.append("--cov-config=pyproject.toml")

install_arg = f"-e.[{','.join(_extras)}]"
session.install(install_arg, *install_args, silent=False)
session.install(install_arg, *install_args, "pytest-xdist", silent=False)
session.run("pytest", *run_args, *posargs, env=env)


Expand Down
2 changes: 1 addition & 1 deletion src/scikit_build_core/program_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __dir__() -> list[str]:


# Make sure we don't wait forever for programs to respond
TIMEOUT = 10 if sys.platform.startswith("win") else 4
TIMEOUT = 10 if sys.platform.startswith("win") else 5


class Program(NamedTuple):
Expand Down
2 changes: 1 addition & 1 deletion src/scikit_build_core/setuptools/build_cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def run(self) -> None:
_validate_settings(settings)

build_tmp_folder = Path(self.build_temp)
build_temp = build_tmp_folder / "_skbuild" # TODO: include python platform
build_temp = build_tmp_folder / "_skbuild"

dist = self.distribution
dist_source_dir = getattr(self.distribution, "cmake_source_dir", None)
Expand Down
3 changes: 0 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,6 @@ def process_package(
package_dir = tmp_path / "pkg"
shutil.copytree(DIR / "packages" / package.name, package_dir)
monkeypatch.chdir(package_dir)
# Just in case this gets littered into the source tree, clear it out
if Path("dist").is_dir():
shutil.rmtree("dist")


@pytest.fixture
Expand Down
9 changes: 6 additions & 3 deletions tests/test_broken_fallback.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@
@pytest.mark.configure
@pytest.mark.usefixtures("broken_fallback")
@pytest.mark.parametrize("broken_define", ["BROKEN_CMAKE", "BROKEN_CODE"])
def test_broken_code(broken_define: str, capfd: pytest.CaptureFixture[str]):
build_wheel("dist", {f"cmake.define.{broken_define}": "1"})
wheel = Path("dist") / "broken_fallback-0.0.1-py3-none-any.whl"
def test_broken_code(
broken_define: str, capfd: pytest.CaptureFixture[str], tmp_path: Path
):
dist = tmp_path / "dist"
build_wheel(str(dist), {f"cmake.define.{broken_define}": "1"})
wheel = dist / "broken_fallback-0.0.1-py3-none-any.whl"
with zipfile.ZipFile(wheel) as f:
file_names = set(f.namelist())

Expand Down
6 changes: 3 additions & 3 deletions tests/test_dynamic_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,9 @@ def test_dual_metadata():
@pytest.mark.compile
@pytest.mark.configure
@pytest.mark.usefixtures("mock_entry_points", "package_dynamic_metadata")
def test_pep517_wheel(virtualenv):
dist = Path("dist")
out = build_wheel("dist")
def test_pep517_wheel(virtualenv, tmp_path: Path) -> None:
dist = tmp_path / "dist"
out = build_wheel(str(dist))
(wheel,) = dist.glob("dynamic-0.0.2-*.whl")
assert wheel == dist / out

Expand Down
3 changes: 0 additions & 3 deletions tests/test_fortran.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@
)
def test_pep517_wheel(tmp_path, monkeypatch, virtualenv):
dist = tmp_path / "dist"
dist.mkdir()
monkeypatch.chdir(FORTRAN_EXAMPLE)
if Path("dist").is_dir():
shutil.rmtree("dist")
out = build_wheel(str(dist))
(wheel,) = dist.glob("fibby-0.0.1-*.whl")
assert wheel == dist / out
Expand Down
14 changes: 8 additions & 6 deletions tests/test_hatchling.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
@pytest.mark.network
@pytest.mark.integration
@pytest.mark.usefixtures("package_hatchling")
def test_hatchling_sdist(isolated) -> None:
def test_hatchling_sdist(isolated, tmp_path: Path) -> None:
dist = tmp_path / "dist"
isolated.install("build[virtualenv]")
isolated.module("build", "--sdist")
(sdist,) = Path("dist").iterdir()
isolated.module("build", "--sdist", f"--outdir={dist}")
(sdist,) = dist.iterdir()
assert sdist.name == "hatchling_example-0.1.0.tar.gz"
with tarfile.open(sdist) as f:
file_names = set(f.getnames())
Expand All @@ -37,12 +38,13 @@ def test_hatchling_sdist(isolated) -> None:
@pytest.mark.parametrize(
"build_args", [(), ("--wheel",)], ids=["sdist_to_wheel", "wheel_directly"]
)
def test_hatchling_wheel(isolated, build_args) -> None:
def test_hatchling_wheel(isolated, build_args, tmp_path: Path) -> None:
dist = tmp_path / "dist"
isolated.install("build[virtualenv]", "scikit-build-core", "hatchling", "pybind11")
isolated.module("build", "--no-isolation", *build_args)
isolated.module("build", "--no-isolation", f"--outdir={dist}", *build_args)
ext_suffix = sysconfig.get_config_var("EXT_SUFFIX")

(wheel,) = Path("dist").glob("*.whl")
(wheel,) = dist.glob("*.whl")
with zipfile.ZipFile(wheel) as f:
file_names = set(f.namelist())
assert file_names == {
Expand Down
4 changes: 1 addition & 3 deletions tests/test_pyproject_abi3.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@ def test_abi3_wheel(tmp_path, monkeypatch, virtualenv, capsys):
dist = tmp_path / "dist"
dist.mkdir()
monkeypatch.chdir(ABI_PKG)
if Path("dist").is_dir():
shutil.rmtree("dist")
if Path("build").is_dir():
shutil.rmtree("build")

out = build_wheel(str(dist))
stdout, stderr = capsys.readouterr()
stdout, _ = capsys.readouterr()
assert "This is a message after success" in stdout
(wheel,) = dist.glob("abi3_example-0.0.1-*.whl")
assert wheel == dist / out
Expand Down
6 changes: 3 additions & 3 deletions tests/test_pyproject_extra_dirs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
@pytest.mark.compile
@pytest.mark.configure
@pytest.mark.usefixtures("package_filepath_pure")
def test_pep517_wheel_extra_dirs(monkeypatch):
def test_pep517_wheel_extra_dirs(monkeypatch, tmp_path: Path):
monkeypatch.setenv("SKBUILD_CMAKE_DEFINE", "SOME_DEFINE3=baz;SOME_DEFINE4=baz")
monkeypatch.setenv("SKBUILD_CMAKE_ARGS", "-DSOME_ARGS1=baz")

dist = Path("dist")
dist = tmp_path / "dist"
out = build_wheel(
"dist",
str(dist),
{"cmake.define.SOME_DEFINE2": "bar", "cmake.define.SOME_DEFINE3": "bar"},
)
(wheel,) = dist.glob("cmake_dirs-0.0.1-*.whl")
Expand Down
76 changes: 38 additions & 38 deletions tests/test_pyproject_pep517.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def compute_uncompressed_hash(inp: Path) -> str:


@pytest.mark.usefixtures("package_simple_pyproject_ext")
def test_pep517_sdist():
def test_pep517_sdist(tmp_path: Path):
expected_metadata = (
inspect.cleandoc(
"""
Expand All @@ -57,8 +57,8 @@ def test_pep517_sdist():
)
+ "\n\n"
)
dist = Path("dist")
out = build_sdist("dist")
dist = tmp_path / "dist"
out = build_sdist(str(dist))

(sdist,) = dist.iterdir()
assert sdist.name == "cmake_example-0.0.1.tar.gz"
Expand All @@ -83,11 +83,11 @@ def test_pep517_sdist():


@mark_hashes_different
def test_pep517_sdist_hash(monkeypatch, package_simple_pyproject_ext):
def test_pep517_sdist_hash(monkeypatch, package_simple_pyproject_ext, tmp_path: Path):
# Unset SOURCE_DATE_EPOCH in order to guarantee the hash match
monkeypatch.delenv("SOURCE_DATE_EPOCH", raising=False)
dist = Path("dist")
out = build_sdist("dist")
dist = tmp_path / "dist"
out = build_sdist(str(dist))
sdist = dist / out
hash = compute_uncompressed_hash(sdist)
assert hash == package_simple_pyproject_ext.sdist_hash
Expand All @@ -99,18 +99,17 @@ def test_pep517_sdist_hash(monkeypatch, package_simple_pyproject_ext):


@pytest.mark.usefixtures("package_simple_pyproject_ext")
def test_pep517_sdist_time_hash():
dist = Path("dist")
def test_pep517_sdist_time_hash(tmp_path: Path):
dist = tmp_path / "dist"

out = build_sdist("dist")
out = build_sdist(str(dist))
sdist = dist / out
hash1 = hashlib.sha256(sdist.read_bytes()).hexdigest()

time.sleep(2)
Path("src/main.cpp").touch()

if Path("dist").is_dir():
shutil.rmtree("dist")
shutil.rmtree(dist)

out = build_sdist(str(dist))
sdist = dist / out
Expand All @@ -121,17 +120,16 @@ def test_pep517_sdist_time_hash():


@pytest.mark.usefixtures("package_simple_pyproject_ext")
def test_pep517_sdist_time_hash_nonreproducable():
dist = Path("dist")
def test_pep517_sdist_time_hash_nonreproducable(tmp_path: Path):
dist = tmp_path / "dist"

out = build_sdist("dist", {"sdist.reproducible": "false"})
out = build_sdist(str(dist), {"sdist.reproducible": "false"})
sdist = dist / out
hash1 = hashlib.sha256(sdist.read_bytes()).hexdigest()

time.sleep(2)

if Path("dist").is_dir():
shutil.rmtree("dist")
shutil.rmtree(dist)

out = build_sdist(str(dist))
sdist = dist / out
Expand All @@ -144,9 +142,9 @@ def test_pep517_sdist_time_hash_nonreproducable():
@mark_hashes_different
@pytest.mark.parametrize("reverse_order", [False, True])
def test_pep517_sdist_time_hash_set_epoch(
monkeypatch, reverse_order, package_simple_pyproject_ext
monkeypatch, reverse_order, package_simple_pyproject_ext, tmp_path: Path
):
dist = Path("dist")
dist = tmp_path / "dist"
monkeypatch.setenv(
"SOURCE_DATE_EPOCH", package_simple_pyproject_ext.source_date_epoch
)
Expand Down Expand Up @@ -176,11 +174,12 @@ def each_unignored_file_ordered(*args, **kwargs):
("SKBUILD_CMAKE_ARGS", "-DCMAKE_C_FLAGS=-DFOO=1 -DBAR="),
],
)
def test_passing_cxx_flags(monkeypatch, env_var, setting):
def test_passing_cxx_flags(monkeypatch, env_var, setting, tmp_path: Path):
# Note: This is sensitive to the types of quotes for SKBUILD_CMAKE_ARGS
monkeypatch.setenv(env_var, setting)
build_wheel("dist", {"cmake.targets": ["cmake_example"]}) # Could leave empty
(wheel,) = Path("dist").glob("cmake_example-0.0.1-py3-none-*.whl")
dist = tmp_path / "dist"
build_wheel(str(dist), {"cmake.targets": ["cmake_example"]}) # Could leave empty
(wheel,) = dist.glob("cmake_example-0.0.1-py3-none-*.whl")
with zipfile.ZipFile(wheel) as f:
file_names = set(f.namelist())

Expand All @@ -198,9 +197,11 @@ def test_passing_cxx_flags(monkeypatch, env_var, setting):
@pytest.mark.compile
@pytest.mark.configure
@pytest.mark.usefixtures("package_simple_pyproject_ext")
def test_pep517_wheel(virtualenv):
dist = Path("dist")
out = build_wheel("dist", {"cmake.targets": ["cmake_example"]}) # Could leave empty
def test_pep517_wheel(virtualenv, tmp_path: Path):
dist = tmp_path / "dist"
out = build_wheel(
str(dist), {"cmake.targets": ["cmake_example"]}
) # Could leave empty
(wheel,) = dist.glob("cmake_example-0.0.1-*.whl")
assert wheel == dist / out

Expand Down Expand Up @@ -248,9 +249,9 @@ def test_pep517_wheel(virtualenv):
@pytest.mark.compile
@pytest.mark.configure
@pytest.mark.usefixtures("package_simple_pyproject_source_dir")
def test_pep517_wheel_source_dir(virtualenv):
dist = Path("dist")
out = build_wheel("dist", config_settings={"skbuild.wheel.build-tag": "1foo"})
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"})
(wheel,) = dist.glob("cmake_example-0.0.1-*.whl")
assert wheel == dist / out

Expand Down Expand Up @@ -306,18 +307,17 @@ def test_pep517_wheel_source_dir(virtualenv):
@pytest.mark.skip(reason="Doesn't work yet")
@pytest.mark.compile
@pytest.mark.configure
def test_pep517_wheel_time_hash(monkeypatch):
def test_pep517_wheel_time_hash(monkeypatch, tmp_path: Path):
monkeypatch.setenv("SOURCE_DATE_EPOCH", "12345")
dist = Path("dist")
out = build_wheel("dist")
dist = tmp_path / "dist"
out = build_wheel(str(dist))
wheel = dist / out
hash1 = hashlib.sha256(wheel.read_bytes()).hexdigest()

time.sleep(2)
Path("src/main.cpp").touch()

if Path("dist").is_dir():
shutil.rmtree("dist")
shutil.rmtree(dist)

out = build_wheel(str(dist))
wheel = dist / out
Expand Down Expand Up @@ -385,7 +385,7 @@ def test_pep639_license_files_metadata():


@pytest.mark.usefixtures("package_pep639_pure")
def test_pep639_license_files_sdist():
def test_pep639_license_files_sdist(tmp_path: Path):
expected_metadata = (
inspect.cleandoc(
"""
Expand All @@ -400,8 +400,8 @@ def test_pep639_license_files_sdist():
+ "\n\n"
)

dist = Path("dist")
out = build_sdist("dist")
dist = tmp_path / "dist"
out = build_sdist(str(dist))

(sdist,) = dist.iterdir()
assert sdist.name == "pep639_pure-0.1.0.tar.gz"
Expand All @@ -425,9 +425,9 @@ def test_pep639_license_files_sdist():


@pytest.mark.usefixtures("package_pep639_pure")
def test_pep639_license_files_wheel():
dist = Path("dist")
out = build_wheel("dist", {})
def test_pep639_license_files_wheel(tmp_path: Path):
dist = tmp_path / "dist"
out = build_wheel(str(dist), {})
(wheel,) = dist.glob("pep639_pure-0.1.0-*.whl")
assert wheel == dist / out

Expand Down
Loading
Loading