Skip to content

Commit

Permalink
Merge branch 'main' into pre-commit-autoupdate
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleFromNVIDIA committed Aug 8, 2024
2 parents 498ae60 + b8791f7 commit 7d8c262
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 14 deletions.
20 changes: 18 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ def wheelhouse(tmp_path_factory, pip_cache):
"""A PEP 517 wheelhouse containing the local copy of rapids-build-backend."""
wheelhouse = tmp_path_factory.mktemp("wheelhouse")

# Build the rapids-builder wheel in a temporary directory where we can bump the
# version to ensure that it is preferred to any other available wheels.
# Build the rapids-build-backend wheel in a temporary directory where we can bump
# the version to ensure that it is preferred to any other available wheels.
rapids_build_backend_build_dir = tmp_path_factory.mktemp(
"rapids_build_backend_build_dir"
)
Expand Down Expand Up @@ -203,6 +203,22 @@ def wheelhouse(tmp_path_factory, pip_cache):
check=True,
)

subprocess.run(
[
sys.executable,
"-m",
"pip",
"wheel",
"--disable-pip-version-check",
"--wheel-dir",
str(wheelhouse),
"--cache-dir",
pip_cache,
f"{DIR}/tests/rapids-test-dummy",
],
check=True,
)

return wheelhouse


Expand Down
5 changes: 5 additions & 0 deletions tests/rapids-test-dummy/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright (c) 2024, NVIDIA CORPORATION.

[project]
name = "rapids-test-dummy"
version = "0.0.1"
3 changes: 3 additions & 0 deletions tests/rapids-test-dummy/rapids_test_dummy/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright (c) 2024, NVIDIA CORPORATION.

__version__ = "0.0.1"
2 changes: 1 addition & 1 deletion tests/templates/dependencies-rbb-only.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies:
matrices:
- matrix: {cuda: "85.*"}
packages:
- more-itertools
- rapids-test-dummy
# keeping this empty means it'll only be filled in if
# rapids-build-backend actually resolves one of the CUDA-specific
# matrices
Expand Down
28 changes: 17 additions & 11 deletions tests/test_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import glob
import os
import re
import subprocess
import zipfile
from email.parser import BytesParser
Expand Down Expand Up @@ -29,6 +30,10 @@ def _generate_wheel(env, package_dir):
break
if "Collecting" in line:
build_requires.add(line.replace("Collecting ", "").replace(" ", ""))
elif re.search(
r"Processing .*/rapids_test_dummy-0\.0\.1-py3-none-any\.whl$", line
):
build_requires.add("rapids-test-dummy")

# Extract metadata from the wheel file.
wheel = glob.glob(str(package_dir / "*.whl"))[0]
Expand Down Expand Up @@ -101,9 +106,9 @@ def test_setuptools_with_imports_in_setup_py_works(
"dependencies-file": '"dependencies-rbb-only.yaml"',
},
"setup_py_lines": [
"import more_itertools",
"import rapids_test_dummy",
"",
"print(more_itertools.__version__)",
"print(rapids_test_dummy.__version__)",
"",
"setup()",
],
Expand All @@ -118,7 +123,7 @@ def test_setuptools_with_imports_in_setup_py_works(
)

assert name == "setuptools-with-imports-in-setup-py-cu85"
assert {"more-itertools"}.issubset(build_requires)
assert {"rapids-test-dummy"}.issubset(build_requires)
assert requirements == set()


Expand All @@ -137,9 +142,9 @@ def test_setuptools_with_imports_in_setup_py_fails_on_missing_imports(
"dependencies-file": '"dependencies-rbb-only.yaml"',
},
"setup_py_lines": [
"import more_itertools",
"import rapids_test_dummy",
"",
"print(more_itertools.__version__)",
"print(rapids_test_dummy.__version__)",
"",
"setup()",
],
Expand All @@ -149,20 +154,21 @@ def test_setuptools_with_imports_in_setup_py_fails_on_missing_imports(
generate_from_template(package_dir, "setup.py", template_args)

# only the CUDA '85.*' in this example provides required build dependency
# 'more-itertools', so it won't be found if using some other matrix.
# 'rapids-test-dummy', 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
# 'more-itertools' already existed in the environment where tests run.
# 'rapids-test-dummy' 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 'more_itertools'" in captured_output.out
"ModuleNotFoundError: No module named 'rapids_test_dummy'"
in captured_output.out
)


Expand All @@ -180,12 +186,12 @@ def test_setuptools_with_setup_requires_fails_with_informative_error(
"dependencies-file": '"dependencies-rbb-only.yaml"',
},
"setup_py_lines": [
"import more_itertools",
"import rapids_test_dummy",
"",
"print(more_itertools.__version__)",
"print(rapids_test_dummy.__version__)",
"",
"setup(",
" setup_requires=['more-itertools'],",
" setup_requires=['rapids-test-dummy'],",
")",
],
}
Expand Down

0 comments on commit 7d8c262

Please sign in to comment.