xref: /aosp_15_r20/external/bazelbuild-rules_python/tests/whl_filegroup/BUILD.bazel (revision 60517a1edbc8ecf509223e9af94a7adec7d736b8)
1load("@bazel_skylib//rules:write_file.bzl", "write_file")
2load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
3load("//python:defs.bzl", "py_library", "py_test")
4load("//python:packaging.bzl", "py_package", "py_wheel")
5load("//python:pip.bzl", "whl_filegroup")
6load(":whl_filegroup_tests.bzl", "whl_filegroup_test_suite")
7
8whl_filegroup_test_suite(name = "whl_filegroup_tests")
9
10py_test(
11    name = "extract_wheel_files_test",
12    size = "small",
13    srcs = ["extract_wheel_files_test.py"],
14    data = ["//examples/wheel:minimal_with_py_package"],
15    deps = ["//python/private/whl_filegroup:extract_wheel_files"],
16)
17
18write_file(
19    name = "header",
20    out = "include/whl_headers/header.h",
21    content = [
22        "#pragma once",
23        "#include <Python.h>",
24        "#define CUSTOM_ZERO ((Py_ssize_t) 0)",
25    ],
26)
27
28write_file(
29    name = "lib_py",
30    out = "lib.py",
31)
32
33py_library(
34    name = "lib",
35    srcs = ["lib.py"],
36    data = [":header"],
37)
38
39py_package(
40    name = "pkg",
41    deps = [":lib"],
42)
43
44py_wheel(
45    name = "wheel",
46    distribution = "wheel",
47    python_tag = "py3",
48    version = "0.0.1",
49    deps = [":pkg"],
50)
51
52whl_filegroup(
53    name = "filegroup",
54    pattern = "tests/whl_filegroup/include/.*\\.h",
55    whl = ":wheel",
56)
57
58cc_library(
59    name = "whl_headers",
60    hdrs = [":filegroup"],
61    includes = ["filegroup/tests/whl_filegroup/include"],
62    deps = ["@rules_python//python/cc:current_py_cc_headers"],
63)
64
65cc_test(
66    name = "whl_headers_test",
67    srcs = ["whl_headers_test.c"],
68    deps = [":whl_headers"],
69)
70