|
13 | 13 | # limitations under the License.
|
14 | 14 |
|
15 | 15 | load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
|
16 |
| -load("@bazel_skylib//rules:write_file.bzl", "write_file") |
17 | 16 | load("@dev_pip//:requirements.bzl", "requirement")
|
18 |
| -load("//python:py_binary.bzl", "py_binary") |
19 | 17 | load("//python/private:bzlmod_enabled.bzl", "BZLMOD_ENABLED") # buildifier: disable=bzl-visibility
|
20 | 18 | load("//python/private:util.bzl", "IS_BAZEL_7_OR_HIGHER") # buildifier: disable=bzl-visibility
|
| 19 | +load("//python/uv/private:lock.bzl", "lock") # buildifier: disable=bzl-visibility |
21 | 20 | load("//sphinxdocs:readthedocs.bzl", "readthedocs_install")
|
22 | 21 | load("//sphinxdocs:sphinx.bzl", "sphinx_build_binary", "sphinx_docs")
|
23 | 22 | load("//sphinxdocs:sphinx_stardoc.bzl", "sphinx_stardoc", "sphinx_stardocs")
|
@@ -140,71 +139,12 @@ sphinx_build_binary(
|
140 | 139 | ],
|
141 | 140 | )
|
142 | 141 |
|
143 |
| -_REQUIREMENTS_TARGET_COMPATIBLE_WITH = select({ |
144 |
| - "@platforms//os:linux": [], |
145 |
| - "@platforms//os:macos": [], |
146 |
| - "@platforms//os:windows": [], |
147 |
| - "//conditions:default": ["@platforms//:incompatible"], |
148 |
| -}) if BZLMOD_ENABLED else ["@platforms//:incompatible"] |
149 |
| - |
150 | 142 | # Run bazel run //docs:requirements.update
|
151 |
| -genrule( |
| 143 | +lock( |
152 | 144 | name = "requirements",
|
153 | 145 | srcs = ["pyproject.toml"],
|
154 |
| - outs = ["_requirements.txt"], |
155 |
| - cmd = "$(UV_BIN) pip compile " + " ".join([ |
156 |
| - "--custom-compile-command='bazel run //docs:requirements.update'", |
157 |
| - "--generate-hashes", |
158 |
| - "--universal", |
159 |
| - "--emit-index-url", |
160 |
| - "--no-strip-extras", |
161 |
| - "--no-build", |
162 |
| - "--python=$(PYTHON3)", |
163 |
| - "$<", |
164 |
| - "--output-file=$@", |
165 |
| - # Always try upgrading |
166 |
| - "--upgrade", |
167 |
| - ]), |
168 |
| - tags = [ |
169 |
| - "local", |
170 |
| - "manual", |
171 |
| - "no-cache", |
172 |
| - ], |
173 |
| - target_compatible_with = _REQUIREMENTS_TARGET_COMPATIBLE_WITH, |
174 |
| - toolchains = [ |
175 |
| - "//python/uv:current_toolchain", |
176 |
| - "//python:current_py_toolchain", |
177 |
| - ], |
178 |
| -) |
179 |
| - |
180 |
| -# Write a script that can be used for updating the in-tree version of the |
181 |
| -# requirements file |
182 |
| -write_file( |
183 |
| - name = "gen_update_requirements", |
184 |
| - out = "requirements.update.py", |
185 |
| - content = [ |
186 |
| - "from os import environ", |
187 |
| - "from pathlib import Path", |
188 |
| - "from sys import stderr", |
189 |
| - "", |
190 |
| - 'src = Path(environ["REQUIREMENTS_FILE"])', |
191 |
| - 'dst = Path(environ["BUILD_WORKSPACE_DIRECTORY"]) / "docs" / "requirements.txt"', |
192 |
| - 'print(f"Writing requirements contents from {src} to {dst}", file=stderr)', |
193 |
| - "dst.write_text(src.read_text())", |
194 |
| - 'print("Success!", file=stderr)', |
195 |
| - ], |
196 |
| - target_compatible_with = _REQUIREMENTS_TARGET_COMPATIBLE_WITH, |
197 |
| -) |
198 |
| - |
199 |
| -py_binary( |
200 |
| - name = "requirements.update", |
201 |
| - srcs = ["requirements.update.py"], |
202 |
| - data = [":requirements"], |
203 |
| - env = { |
204 |
| - "REQUIREMENTS_FILE": "$(location :requirements)", |
205 |
| - }, |
206 |
| - tags = ["manual"], |
207 |
| - target_compatible_with = _REQUIREMENTS_TARGET_COMPATIBLE_WITH, |
| 146 | + out = "requirements.txt", |
| 147 | + upgrade = True, |
208 | 148 | )
|
209 | 149 |
|
210 | 150 | licenses(["notice"]) # Apache 2.0
|
|
0 commit comments