Skip to content

Commit b7e58d1

Browse files
authored
feat: Have pip_compile generate a *.test target; deprecate *_test (bazel-contrib#2812)
Fixes bazel-contrib#2794. The `pip_compile` macro generates `*_test` and `*.update` targets. This pattern does not match with other macros that generate similar targets, namely `gazelle_python_manifest` and uv `lock` (though that's `.run` instead of `.test` but either way, it uses a dot `.` instead of underscore `_`). Adjust the macro so that a `.test` target is made. The `_test` target is aliased with a deprecation warning, to be removed in the next major version.
1 parent e32b08f commit b7e58d1

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ END_UNRELEASED_TEMPLATE
5757
* (rules) On Windows, {obj}`--bootstrap_impl=system_python` is forced. This
5858
allows setting `--bootstrap_impl=script` in bazelrc for mixed-platform
5959
environments.
60+
* (rules) {obj}`pip_compile` now generates a `.test` target. The `_test` target is deprecated
61+
and will be removed in the next major release.
62+
([#2794](https://github.com/bazel-contrib/rules_python/issues/2794)
6063

6164
{#v0-0-0-fixed}
6265
### Fixed

python/private/pypi/pip_compile.bzl

+8-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def pip_compile(
4747
4848
It also generates two targets for running pip-compile:
4949
50-
- validate with `bazel test [name]_test`
50+
- validate with `bazel test [name].test`
5151
- update with `bazel run [name].update`
5252
5353
If you are using a version control system, the requirements.txt generated by this rule should
@@ -166,7 +166,7 @@ def pip_compile(
166166
timeout = kwargs.pop("timeout", "short")
167167

168168
py_test(
169-
name = name + "_test",
169+
name = name + ".test",
170170
timeout = timeout,
171171
# setuptools (the default python build tool) attempts to find user
172172
# configuration in the user's home direcotory. This seems to work fine on
@@ -180,3 +180,9 @@ def pip_compile(
180180
# kwargs could contain test-specific attributes like size
181181
**dict(attrs, **kwargs)
182182
)
183+
184+
native.alias(
185+
name = "{}_test".format(name),
186+
actual = ":{}.test".format(name),
187+
deprecation = "Use '{}.test' instead. The '*_test' target will be removed in the next major release.".format(name),
188+
)

0 commit comments

Comments
 (0)