Skip to content

Commit

Permalink
use more-itertools, specifically setuptools.build_meta
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslamb committed Jun 10, 2024
1 parent 3a7d2a1 commit b265072
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
6 changes: 3 additions & 3 deletions rapids_build_backend/impls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tests/examples/setuptools-with-imports-in-setup-py/setup.py
Original file line number Diff line number Diff line change
@@ -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()
12 changes: 7 additions & 5 deletions tests/test_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand All @@ -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(
Expand Down

0 comments on commit b265072

Please sign in to comment.