forked from aip-dev/site-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BUILD.bazel
86 lines (80 loc) · 2.66 KB
/
BUILD.bazel
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
78
79
80
81
82
83
84
85
86
load("//:requirements.bzl", "requirement")
load("@bazel_skylib//rules:diff_test.bzl", "diff_test")
load("@bazel_skylib//rules:write_file.bzl", "write_file")
# The requirements.bzl file is generated with a reference to the interpreter for the host platform.
# In order to check in a platform-agnostic file, we have to replace that reference with the symbol
# loaded from our python toolchain.
genrule(
name = "make_platform_agnostic",
srcs = ["@pip//:requirements.bzl"],
outs = ["requirements.clean.bzl"],
cmd = " | ".join([
"cat $<",
# Insert our load statement after the existing one so we don't produce a file with buildifier warnings
"""sed -e '/^load.*/i\\'$$'\\n''load("@python39//:defs.bzl", "interpreter")'""",
"""tr "'" '"' """,
"""sed 's#"@python39_.*//:bin/python3"#interpreter#' >$@""",
]),
)
write_file(
name = "gen_update",
out = "update.sh",
content = [
# This depends on bash, would need tweaks for Windows
"#!/usr/bin/env bash",
# Bazel gives us a way to access the source folder!
"cd $BUILD_WORKSPACE_DIRECTORY",
"cp -fv bazel-bin/requirements.clean.bzl requirements.bzl",
],
)
sh_binary(
name = "vendor_requirements",
srcs = ["update.sh"],
data = [":make_platform_agnostic"],
)
# Similarly ensures that the requirements.bzl file is updated
# based on the requirements.txt lockfile.
diff_test(
name = "test_vendored",
failure_message = "Please run: bazel run //:vendor_requirements",
file1 = "requirements.bzl",
file2 = ":make_platform_agnostic",
)
filegroup(
name = "data",
srcs = glob([
"aip_site/support/assets/js/**/*.js",
"aip_site/support/scss/**/*.scss",
"aip_site/support/templates/**/*.j2",
]) + [
"aip_site/support/assets/favicon.ico",
"aip_site/support/assets/images/glue-icons.svg",
"aip_site/support/assets/images/github.png",
] + [
"VERSION",
"README.md",
],
)
py_binary(
name = "site-generator",
srcs = glob(["aip_site/**/*.py"]) + ["//internal:main.py"],
data = [":data"],
main = "//internal:main.py",
visibility = ["//visibility:public"],
deps = [
requirement("click"),
requirement("flask"),
requirement("itsdangerous"),
requirement("jinja2"),
requirement("markdown"),
requirement("markupsafe"),
requirement("pygments"),
requirement("pymdown-extensions"),
requirement("pyscss"),
requirement("pyyaml"),
requirement("six"),
requirement("types-Markdown"),
requirement("types-PyYAML"),
requirement("werkzeug"),
],
)