forked from bazel-contrib/rules_python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBUILD
More file actions
134 lines (117 loc) · 3.34 KB
/
Copy pathBUILD
File metadata and controls
134 lines (117 loc) · 3.34 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# Copyright 2017 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@bazel_skylib//rules:diff_test.bzl", "diff_test")
load("@bazel_skylib//rules:write_file.bzl", "write_file")
load("@io_bazel_stardoc//stardoc:stardoc.bzl", "stardoc")
package(default_visibility = ["//visibility:public"])
licenses(["notice"]) # Apache 2.0
_DOCS = {
"packaging": "//docs:packaging-docs",
"pip": "//docs:pip-docs",
"python": "//docs:core-docs",
"whl": "//docs:whl-docs",
}
# We define these bzl_library targets here rather than in the //python package
# because they're only used for doc generation. This way, we avoid requiring
# our users to depend on Skylib.
# Requires Bazel 0.29 onward for public visibility of these .bzl files.
bzl_library(
name = "bazel_python_tools",
srcs = [
"@bazel_tools//tools/python:private/defs.bzl",
"@bazel_tools//tools/python:srcs_version.bzl",
"@bazel_tools//tools/python:toolchain.bzl",
"@bazel_tools//tools/python:utils.bzl",
],
)
bzl_library(
name = "bazel_repo_tools",
srcs = [
"@bazel_tools//tools:bzl_srcs",
],
)
bzl_library(
name = "defs",
srcs = [
"//python:defs.bzl",
"//python:private/reexports.bzl",
],
deps = [":bazel_python_tools"],
)
bzl_library(
name = "pip_install_bzl",
srcs = [
"//python/pip_install:pip_repository.bzl",
"//python/pip_install:repositories.bzl",
"//python/pip_install:requirements.bzl",
],
deps = [
":defs",
],
)
stardoc(
name = "core-docs",
out = "python.md_",
input = "//python:defs.bzl",
deps = [":defs"],
)
# TODO: Consider merging documentation pages for whl and pip. This would
# require re-exporting their symbols from a common .bzl; see
# https://github.com/bazelbuild/skydoc/issues/208.
stardoc(
name = "pip-docs",
out = "pip.md_",
input = "//python:pip.bzl",
deps = [
":bazel_repo_tools",
":pip_install_bzl",
"//third_party/github.com/bazelbuild/bazel-skylib/lib:versions",
],
)
stardoc(
name = "whl-docs",
out = "whl.md_",
input = "//python:whl.bzl",
)
stardoc(
name = "packaging-docs",
out = "packaging.md_",
input = "//python:packaging.bzl",
)
[
diff_test(
name = "check_" + k,
failure_message = "Please run: bazel run //docs:update",
file1 = k + ".md",
file2 = k + ".md_",
)
for k in _DOCS.keys()
]
write_file(
name = "gen_update",
out = "update.sh",
content = [
"#!/usr/bin/env bash",
"cd $BUILD_WORKSPACE_DIRECTORY",
] + [
"cp -fv bazel-bin/docs/{0}.md_ docs/{0}.md".format(k)
for k in _DOCS.keys()
],
)
sh_binary(
name = "update",
srcs = ["update.sh"],
data = _DOCS.values(),
)