diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 936669657..1a172ae4e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 diff --git a/docs/about/changelog.md b/docs/about/changelog.md index a143066e4..3b4a00074 100644 --- a/docs/about/changelog.md +++ b/docs/about/changelog.md @@ -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: diff --git a/noxfile.py b/noxfile.py index f56256a1f..003fcaf00 100644 --- a/noxfile.py +++ b/noxfile.py @@ -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) @@ -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) diff --git a/src/scikit_build_core/program_search.py b/src/scikit_build_core/program_search.py index 48ecae9b8..709503a68 100644 --- a/src/scikit_build_core/program_search.py +++ b/src/scikit_build_core/program_search.py @@ -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): diff --git a/src/scikit_build_core/setuptools/build_cmake.py b/src/scikit_build_core/setuptools/build_cmake.py index cdb48d528..8c37f731f 100644 --- a/src/scikit_build_core/setuptools/build_cmake.py +++ b/src/scikit_build_core/setuptools/build_cmake.py @@ -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) diff --git a/tests/conftest.py b/tests/conftest.py index 42ec3783a..6981e48f8 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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 diff --git a/tests/test_broken_fallback.py b/tests/test_broken_fallback.py index 8473c37af..0c7b6d6bc 100644 --- a/tests/test_broken_fallback.py +++ b/tests/test_broken_fallback.py @@ -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()) diff --git a/tests/test_dynamic_metadata.py b/tests/test_dynamic_metadata.py index 842c14875..359970793 100644 --- a/tests/test_dynamic_metadata.py +++ b/tests/test_dynamic_metadata.py @@ -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 diff --git a/tests/test_fortran.py b/tests/test_fortran.py index 7801baf92..387f50440 100644 --- a/tests/test_fortran.py +++ b/tests/test_fortran.py @@ -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 diff --git a/tests/test_hatchling.py b/tests/test_hatchling.py index b0de07cbd..d4615f65b 100644 --- a/tests/test_hatchling.py +++ b/tests/test_hatchling.py @@ -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()) @@ -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 == { diff --git a/tests/test_pyproject_abi3.py b/tests/test_pyproject_abi3.py index 3e029d9a0..2e1a38a74 100644 --- a/tests/test_pyproject_abi3.py +++ b/tests/test_pyproject_abi3.py @@ -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 diff --git a/tests/test_pyproject_extra_dirs.py b/tests/test_pyproject_extra_dirs.py index e9f159892..2c93ea286 100644 --- a/tests/test_pyproject_extra_dirs.py +++ b/tests/test_pyproject_extra_dirs.py @@ -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") diff --git a/tests/test_pyproject_pep517.py b/tests/test_pyproject_pep517.py index 5c276f502..4d9325800 100644 --- a/tests/test_pyproject_pep517.py +++ b/tests/test_pyproject_pep517.py @@ -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( """ @@ -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" @@ -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 @@ -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 @@ -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 @@ -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 ) @@ -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()) @@ -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 @@ -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 @@ -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 @@ -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( """ @@ -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" @@ -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 diff --git a/tests/test_pyproject_pep518.py b/tests/test_pyproject_pep518.py index 17bd21b7a..831087cc1 100644 --- a/tests/test_pyproject_pep518.py +++ b/tests/test_pyproject_pep518.py @@ -25,7 +25,7 @@ def compute_uncompressed_hash(inp: Path): @pytest.mark.network @pytest.mark.integration -def test_pep518_sdist(isolated, package_simple_pyproject_ext): +def test_pep518_sdist(isolated, package_simple_pyproject_ext, tmp_path: Path): correct_metadata = textwrap.dedent( """\ Metadata-Version: 2.2 @@ -38,9 +38,10 @@ def test_pep518_sdist(isolated, package_simple_pyproject_ext): """ ) + 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 == "cmake_example-0.0.1.tar.gz" if not sys.platform.startswith(("win", "cygwin")): @@ -69,7 +70,7 @@ def test_pep518_sdist(isolated, package_simple_pyproject_ext): @pytest.mark.configure @pytest.mark.integration @pytest.mark.usefixtures("package_sdist_config") -def test_pep518_sdist_with_cmake_config(isolated, cleanup_overwrite): +def test_pep518_sdist_with_cmake_config(isolated, cleanup_overwrite, tmp_path: Path): cleanup_overwrite.write_text("set(MY_VERSION fiddlesticks)") correct_metadata = textwrap.dedent( @@ -81,9 +82,10 @@ def test_pep518_sdist_with_cmake_config(isolated, cleanup_overwrite): """ ) + 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 == "sdist_config-0.1.0.tar.gz" with tarfile.open(sdist) as f: @@ -117,12 +119,14 @@ def test_pep518_sdist_with_cmake_config(isolated, cleanup_overwrite): "build_args", [(), ("--wheel",)], ids=["sdist_to_wheel", "wheel_directly"] ) def test_pep518_wheel_sdist_with_cmake_config( - isolated, build_args, capfd, cleanup_overwrite + isolated, build_args, capfd, cleanup_overwrite, tmp_path: Path ): + dist = tmp_path / "dist" isolated.install("build[virtualenv]") isolated.module( "build", "--config-setting=logging.level=DEBUG", + f"--outdir={dist}", *build_args, ) out, err = capfd.readouterr() @@ -133,7 +137,7 @@ def test_pep518_wheel_sdist_with_cmake_config( else: assert "Using integrated pybind11" in out - (wheel,) = Path("dist").glob("sdist_config-0.1.0-*.whl") + (wheel,) = dist.glob("sdist_config-0.1.0-*.whl") with zipfile.ZipFile(wheel) as zf: file_names = {Path(n).parts[0] for n in zf.namelist()} @@ -165,14 +169,16 @@ def test_pep518_wheel_sdist_with_cmake_config( @pytest.mark.parametrize( "build_args", [(), ("--wheel",)], ids=["sdist_to_wheel", "wheel_directly"] ) -def test_pep518_wheel(isolated, build_args): +def test_pep518_wheel(isolated, build_args, tmp_path: Path): + dist = tmp_path / "dist" isolated.install("build[virtualenv]") isolated.module( "build", "--config-setting=logging.level=DEBUG", + f"--outdir={dist}", *build_args, ) - (wheel,) = Path("dist").glob("cmake_example-0.0.1-*.whl") + (wheel,) = dist.glob("cmake_example-0.0.1-*.whl") with zipfile.ZipFile(wheel) as zf: file_paths = {Path(n) for n in zf.namelist()} @@ -212,13 +218,14 @@ def test_pep518_rebuild_build_dir(isolated, tmp_path, build_args): build_dir.mkdir() build_dir = build_dir.resolve() - dist = Path("dist") + dist = tmp_path / "dist" for _ in range(2): shutil.rmtree(dist, ignore_errors=True) isolated.module( "build", *build_args, + f"--outdir={dist}", "--config-setting=logging.level=DEBUG", f"--config-setting=build-dir={build_dir}", ) diff --git a/tests/test_pyproject_pep660.py b/tests/test_pyproject_pep660.py index 6ba12e3a4..2ab236a08 100644 --- a/tests/test_pyproject_pep660.py +++ b/tests/test_pyproject_pep660.py @@ -23,9 +23,9 @@ def editable_mode(request: pytest.FixtureRequest) -> str: reason="No idea why this fails on Cygwin", ) @pytest.mark.usefixtures("package_simplest_c") -def test_pep660_wheel(editable_mode: str): - dist = Path("dist") - out = build_editable("dist", {"editable.mode": editable_mode}) +def test_pep660_wheel(editable_mode: str, tmp_path: Path): + dist = tmp_path / "dist" + out = build_editable(str(dist), {"editable.mode": editable_mode}) (wheel,) = dist.glob("simplest-0.0.1-*.whl") assert wheel == dist / out diff --git a/tests/test_pyproject_purelib.py b/tests/test_pyproject_purelib.py index e3632c488..710a15421 100644 --- a/tests/test_pyproject_purelib.py +++ b/tests/test_pyproject_purelib.py @@ -8,9 +8,9 @@ @pytest.mark.compile @pytest.mark.configure @pytest.mark.usefixtures("package_simple_purelib_package") -def test_pep517_wheel(virtualenv): - dist = Path("dist") - out = build_wheel("dist", {}) +def test_pep517_wheel(virtualenv, tmp_path: Path): + dist = tmp_path / "dist" + out = build_wheel(str(dist), {}) (wheel,) = dist.glob("purelib_example-0.0.1-*-none-any.whl") assert wheel == dist / out diff --git a/tests/test_setuptools_abi3.py b/tests/test_setuptools_abi3.py index 61231778e..61dd70c3b 100644 --- a/tests/test_setuptools_abi3.py +++ b/tests/test_setuptools_abi3.py @@ -37,8 +37,6 @@ def test_abi3_wheel(tmp_path, monkeypatch, virtualenv): src = tmp_path / "src" shutil.copytree(ABI_PKG, src) monkeypatch.chdir(src) - if Path("dist").is_dir(): - shutil.rmtree("dist") out = build_wheel(str(dist)) (wheel,) = dist.glob("abi3_example-0.0.1-*.whl") diff --git a/tests/test_setuptools_pep517.py b/tests/test_setuptools_pep517.py index b76f3e911..b4eb44473 100644 --- a/tests/test_setuptools_pep517.py +++ b/tests/test_setuptools_pep517.py @@ -14,7 +14,7 @@ @pytest.mark.usefixtures("package_simple_setuptools_ext") -def test_pep517_sdist(): +def test_pep517_sdist(tmp_path: Path): correct_metadata = textwrap.dedent( """\ Name: cmake-example @@ -29,8 +29,8 @@ def test_pep517_sdist(): ) metadata_set = set(correct_metadata.strip().splitlines()) - dist = Path("dist") - out = build_sdist("dist") + dist = tmp_path / "dist" + out = build_sdist(str(dist)) (sdist,) = dist.iterdir() assert sdist.name in {"cmake-example-0.0.1.tar.gz", "cmake_example-0.0.1.tar.gz"} @@ -69,9 +69,9 @@ def test_pep517_sdist(): @pytest.mark.configure @pytest.mark.broken_on_urct @pytest.mark.usefixtures("package_simple_setuptools_ext") -def test_pep517_wheel(virtualenv): - dist = Path("dist") - out = build_wheel("dist") +def test_pep517_wheel(virtualenv, tmp_path: Path): + dist = tmp_path / "dist" + out = build_wheel(str(dist)) (wheel,) = dist.glob("cmake_example-0.0.1-*.whl") assert wheel == dist / out @@ -101,7 +101,7 @@ def test_pep517_wheel(virtualenv): @pytest.mark.skipif( setuptools_version < Version("61.0"), reason="Requires setuptools 61+" ) -def test_toml_pep517_sdist(): +def test_toml_sdist(tmp_path: Path): correct_metadata = textwrap.dedent( """\ Name: cmake-example @@ -113,8 +113,8 @@ def test_toml_pep517_sdist(): ) metadata_set = set(correct_metadata.strip().splitlines()) - dist = Path("dist") - out = build_sdist("dist") + dist = tmp_path / "dist" + out = build_sdist(str(dist)) (sdist,) = dist.iterdir() assert sdist.name in {"cmake-example-0.0.1.tar.gz", "cmake_example-0.0.1.tar.gz"} @@ -152,9 +152,9 @@ def test_toml_pep517_sdist(): @pytest.mark.skipif( setuptools_version < Version("61.0"), reason="Requires setuptools 61+" ) -def test_toml_pep517_wheel(virtualenv): - dist = Path("dist") - out = build_wheel("dist") +def test_toml_wheel(virtualenv, tmp_path: Path): + dist = tmp_path / "dist" + out = build_wheel(str(dist)) (wheel,) = dist.glob("cmake_example-0.0.1-*.whl") assert wheel == dist / out @@ -183,9 +183,9 @@ def test_toml_pep517_wheel(virtualenv): @pytest.mark.compile @pytest.mark.configure @pytest.mark.usefixtures("package_mixed_setuptools") -def test_pep517_mixed_wheel(virtualenv): - dist = Path("dist") - out = build_wheel("dist") +def test_mixed_wheel(virtualenv, tmp_path: Path): + dist = tmp_path / "dist" + out = build_wheel(str(dist)) (wheel,) = dist.glob("mixed_setuptools-3.1.4-*.whl") assert wheel == dist / out diff --git a/tests/test_setuptools_pep518.py b/tests/test_setuptools_pep518.py index 21f9c7f74..cf1d066e2 100644 --- a/tests/test_setuptools_pep518.py +++ b/tests/test_setuptools_pep518.py @@ -18,10 +18,10 @@ strict=False, ) @pytest.mark.usefixtures("package_simple_setuptools_ext") -def test_pep518_wheel(isolated): - dist = Path("dist") +def test_pep518_wheel(isolated, tmp_path: Path): + dist = tmp_path / "dist" isolated.install("build[virtualenv]") - isolated.module("build", "--wheel") + isolated.module("build", "--wheel", f"--outdir={dist}") (wheel,) = dist.iterdir() assert "cmake_example-0.0.1" in wheel.name assert wheel.suffix == ".whl" diff --git a/tests/test_simplest_c.py b/tests/test_simplest_c.py index 8c43cda61..328147e82 100644 --- a/tests/test_simplest_c.py +++ b/tests/test_simplest_c.py @@ -1,4 +1,3 @@ -import shutil import tarfile import zipfile from pathlib import Path @@ -16,8 +15,6 @@ def test_pep517_sdist(tmp_path, monkeypatch): dist = tmp_path.resolve() / "dist" monkeypatch.chdir(SIMPLEST) - if Path("dist").is_dir(): - shutil.rmtree("dist") out = build_sdist(str(dist)) @@ -54,8 +51,6 @@ def test_pep517_wheel(tmp_path, monkeypatch, virtualenv, component): dist = tmp_path / "dist" dist.mkdir() monkeypatch.chdir(SIMPLEST) - if Path("dist").is_dir(): - shutil.rmtree("dist") out = build_wheel(str(dist), config_settings={"install.components": component}) (wheel,) = dist.glob("simplest-0.0.1-*.whl") assert wheel == dist / out @@ -104,8 +99,6 @@ def test_pep517_wheel_incexl(tmp_path, monkeypatch, virtualenv): dist = tmp_path / "dist" dist.mkdir() monkeypatch.chdir(SIMPLEST) - if Path("dist").is_dir(): - shutil.rmtree("dist") out = build_wheel( str(dist),