diff --git a/private/tests/annotations/BUILD.bazel b/private/tests/annotations/BUILD.bazel index 5b556fb..4255418 100644 --- a/private/tests/annotations/BUILD.bazel +++ b/private/tests/annotations/BUILD.bazel @@ -42,7 +42,9 @@ py_reqs_solution_test( py_test( name = "annotations", srcs = ["annotations.py"], - deps = requirements([ + deps = [ + "@rules_python//python/runfiles", + ] + requirements([ "numpy", "sphinx", ]), diff --git a/private/tests/annotations/annotations.py b/private/tests/annotations/annotations.py index 1aae5ab..d81bbcb 100644 --- a/private/tests/annotations/annotations.py +++ b/private/tests/annotations/annotations.py @@ -1,8 +1,11 @@ """The sdist integration test""" +import platform import unittest +from pathlib import Path from numpy import __version__ as numpy_version # pylint: disable=import-error +from rules_python.python.runfiles import Runfiles # pylint: disable=import-error from sphinx import __version__ as sphinx_version # pylint: disable=import-error @@ -13,6 +16,29 @@ def test_numpy_version(self) -> None: def test_sphinx_version(self) -> None: assert sphinx_version == "7.2.6" + def test_copy_annotations(self) -> None: + runfiles = Runfiles.Create() + assert runfiles, "Failed to locate runfiles" + + expected = [ + "req_compile_test_annotations_{}__numpy/site-packages/numpy/conftest.copy.py", + "req_compile_test_annotations_{}__numpy/site-packages/numpy-1.26.4.dist-info/entry_points.copy.txt", + "req_compile_test_annotations_{}__numpy/site-packages/numpy/testing/setup.copy.py", + ] + + platforms = { + "Darwin": "macos", + "Windows": "windows", + "Linux": "linux", + } + + for rlocationpath in expected: + runfile = runfiles.Rlocation( + rlocationpath.format(platforms[platform.system()]) + ) + assert runfile, f"Failed to find runfile: {rlocationpath}" + assert Path(runfile).exists(), f"Runfile does not exist: {rlocationpath}" + if __name__ == "__main__": unittest.main() diff --git a/private/tests/annotations/annotations_test_deps.bzl b/private/tests/annotations/annotations_test_deps.bzl index 41401ed..3dc810f 100644 --- a/private/tests/annotations/annotations_test_deps.bzl +++ b/private/tests/annotations/annotations_test_deps.bzl @@ -38,6 +38,15 @@ def req_compile_test_annotations_deps(): "numpy": package_annotation( additive_build_file_content = _NUMPY_LIBRARY_TARGET, data = [":pkg.headers"], + copy_srcs = { + "site-packages/numpy/conftest.py": "site-packages/numpy/conftest.copy.py", + }, + copy_files = { + "site-packages/numpy-1.26.4.dist-info/entry_points.txt": "site-packages/numpy-1.26.4.dist-info/entry_points.copy.txt", + }, + copy_executables = { + "site-packages/numpy/testing/setup.py": "site-packages/numpy/testing/setup.copy.py", + }, ), # Sphinx is known to have a circular dependency. The annotations here solve for that. "sphinxcontrib-applehelp": package_annotation(