-
-
Notifications
You must be signed in to change notification settings - Fork 706
Expand file tree
/
Copy pathWORKSPACE
More file actions
77 lines (63 loc) · 2.4 KB
/
Copy pathWORKSPACE
File metadata and controls
77 lines (63 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
workspace(name = "pip_repository_annotations_example")
local_repository(
name = "rules_python",
path = "../..",
)
load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")
py_repositories()
python_register_toolchains(
name = "python39",
python_version = "3.9",
)
load("@rules_python//python:pip.bzl", "package_annotation", "pip_parse")
# Here we can see an example of annotations being applied to an arbitrary
# package. For details on `package_annotation` and it's uses, see the
# docs at @rules_python//docs:pip.md`.
ANNOTATIONS = {
# This annotation verifies that annotations work correctly for pip packages with extras
# specified, in this case requests[security].
"requests": package_annotation(
additive_build_content = """\
load("@bazel_skylib//rules:write_file.bzl", "write_file")
write_file(
name = "generated_file",
out = "generated_file.txt",
content = ["Hello world from requests"],
)
""",
data = [":generated_file"],
),
"wheel": package_annotation(
additive_build_content = """\
load("@bazel_skylib//rules:write_file.bzl", "write_file")
write_file(
name = "generated_file",
out = "generated_file.txt",
content = ["Hello world from build content file"],
)
""",
copy_executables = {"@pip_repository_annotations_example//:data/copy_executable.py": "copied_content/executable.py"},
copy_files = {"@pip_repository_annotations_example//:data/copy_file.txt": "copied_content/file.txt"},
data = [":generated_file"],
data_exclude_glob = ["site-packages/*.dist-info/WHEEL"],
),
}
# For a more thorough example of `pip_parse`. See `@rules_python//examples/pip_parse`
pip_parse(
name = "pip",
annotations = ANNOTATIONS,
python_interpreter_target = "@python39_host//:python",
requirements_lock = "//:requirements.txt",
)
load("@pip//:requirements.bzl", "install_deps")
install_deps()
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "rules_shell",
sha256 = "410e8ff32e018b9efd2743507e7595c26e2628567c42224411ff533b57d27c28",
strip_prefix = "rules_shell-0.2.0",
url = "https://github.com/bazelbuild/rules_shell/releases/download/v0.2.0/rules_shell-v0.2.0.tar.gz",
)
load("@rules_shell//shell:repositories.bzl", "rules_shell_dependencies", "rules_shell_toolchains")
rules_shell_dependencies()
rules_shell_toolchains()