From b26507283f9bff6a15f3a6c84c881ae89c36543d Mon Sep 17 00:00:00 2001 From: James Lamb Date: Mon, 10 Jun 2024 14:09:23 -0700 Subject: [PATCH] use more-itertools, specifically setuptools.build_meta --- rapids_build_backend/impls.py | 6 +++--- .../dependencies.yaml | 2 +- .../setuptools-with-imports-in-setup-py/setup.py | 6 +++--- tests/test_packages.py | 12 +++++++----- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/rapids_build_backend/impls.py b/rapids_build_backend/impls.py index 96df1cc..9b8b4e8 100644 --- a/rapids_build_backend/impls.py +++ b/rapids_build_backend/impls.py @@ -264,7 +264,7 @@ def get_requires_for_build_wheel(config_settings): backend := _get_backend(config.build_backend), "get_requires_for_build_wheel", ): - if config.build_backend.startswith("setuptools"): + if config.build_backend == "setuptools.build_meta": _check_setup_py(setup_py_contents=utils._get_setup_py()) # prior to https://github.com/pypa/setuptools/pull/4369 (May 2024), # setuptools.build_meta.get_requires_for_build_wheel() automatically @@ -298,7 +298,7 @@ def get_requires_for_build_sdist(config_settings): backend := _get_backend(config.build_backend), "get_requires_for_build_sdist", ): - if config.build_backend.startswith("setuptools"): + if config.build_backend == "setuptools.build_meta": _check_setup_py(setup_py_contents=utils._get_setup_py()) else: requires.extend( @@ -321,7 +321,7 @@ def get_requires_for_build_editable(config_settings): backend := _get_backend(config.build_backend), "get_requires_for_build_editable", ): - if config.build_backend.startswith("setuptools"): + if config.build_backend == "setuptools.build_meta": _check_setup_py(setup_py_contents=utils._get_setup_py()) else: requires.extend( diff --git a/tests/examples/setuptools-with-imports-in-setup-py/dependencies.yaml b/tests/examples/setuptools-with-imports-in-setup-py/dependencies.yaml index 0feac40..1dae3bd 100644 --- a/tests/examples/setuptools-with-imports-in-setup-py/dependencies.yaml +++ b/tests/examples/setuptools-with-imports-in-setup-py/dependencies.yaml @@ -16,7 +16,7 @@ dependencies: matrices: - matrix: {cuda: "85.*"} packages: - - matplotlib + - more-itertools # keeping this empty means it'll only be filled in if # rapids-build-backend actually resolves one of the CUDA-specific # matrices diff --git a/tests/examples/setuptools-with-imports-in-setup-py/setup.py b/tests/examples/setuptools-with-imports-in-setup-py/setup.py index 97a8a7a..b58653a 100644 --- a/tests/examples/setuptools-with-imports-in-setup-py/setup.py +++ b/tests/examples/setuptools-with-imports-in-setup-py/setup.py @@ -1,11 +1,11 @@ # Copyright (c) 2024, NVIDIA CORPORATION. -# Note that 'matplotlib is not listed anywhere in pyproject.toml. +# Note that more-itertools is not listed anywhere in pyproject.toml. # This import can only succeed if rapids-build-backend successfully identified it as # a build-time dependency via dependencies.yaml. -import matplotlib +import more_itertools from setuptools import setup -print(matplotlib.__version__) +print(more_itertools.__version__) setup() diff --git a/tests/test_packages.py b/tests/test_packages.py index 0af40f3..9d741b3 100644 --- a/tests/test_packages.py +++ b/tests/test_packages.py @@ -100,7 +100,7 @@ def test_setuptools_with_imports_in_setup_py_works( ) assert name == "setuptools-with-imports-in-setup-py-cu85" - assert {"matplotlib"}.issubset(build_requires) + assert {"more-itertools"}.issubset(build_requires) assert requirements == set() @@ -113,19 +113,21 @@ def test_setuptools_with_imports_in_setup_py_fails_on_missing_imports( ) # only the CUDA '85.*' in this example provides required build dependency - # 'matplotlib', so it won't be found if using some other matrix. + # 'more-itertools', so it won't be found if using some other matrix. # # This test confirms that rapids-build-backend fails loudly in that case, instead of # silently ignoring it. # - # It'd also catch the case where other tests accidentally pass because 'matplotlib' - # already existed in the environment where tests run. + # It'd also catch the case where other tests accidentally pass because + # 'more-itertools' already existed in the environment where tests run. with patch_nvcc_if_needed(nvcc_version="25"): with pytest.raises(subprocess.CalledProcessError, match=".*pip.*"): _generate_wheel(env=isolated_env, package_dir=package_dir) captured_output = capfd.readouterr() - assert "ModuleNotFoundError: No module named 'matplotlib'" in captured_output.out + assert ( + "ModuleNotFoundError: No module named 'more_itertools'" in captured_output.out + ) def test_setuptools_with_setup_requires_fails_with_informative_error(