Skip to content

Commit 83eb5e8

Browse files
authored
fix: pass kwargs env to both update and test targets (#2277)
Fixes #2270.
1 parent bf4978c commit 83eb5e8

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ A brief description of the categories of changes:
4444
wheel is created
4545
* (whl_library) truncate progress messages from the repo rule to better handle
4646
case where a requirement has many `--hash=sha256:...` flags
47+
* (rules) `compile_pip_requirements` passes `env` to the `X.update` target (and
48+
not only to the `X_test` target, a bug introduced in
49+
[#1067](https://github.com/bazelbuild/rules_python/pull/1067)).
4750

4851
### Added
4952
* (py_wheel) Now supports `compress = (True|False)` to allow disabling

python/private/pypi/pip_compile.bzl

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -154,18 +154,11 @@ def pip_compile(
154154
"visibility": visibility,
155155
}
156156

157-
# setuptools (the default python build tool) attempts to find user
158-
# configuration in the user's home direcotory. This seems to work fine on
159-
# linux and macOS, but fails on Windows, so we conditionally provide a fake
160-
# USERPROFILE env variable to allow setuptools to proceed without finding
161-
# user-provided configuration.
162-
kwargs["env"] = select({
163-
"@@platforms//os:windows": {"USERPROFILE": "Z:\\FakeSetuptoolsHomeDirectoryHack"},
164-
"//conditions:default": {},
165-
}) | kwargs.get("env", {})
157+
env = kwargs.pop("env", {})
166158

167159
py_binary(
168160
name = name + ".update",
161+
env = env,
169162
**attrs
170163
)
171164

@@ -174,6 +167,15 @@ def pip_compile(
174167
py_test(
175168
name = name + "_test",
176169
timeout = timeout,
177-
# kwargs could contain test-specific attributes like size or timeout
170+
# setuptools (the default python build tool) attempts to find user
171+
# configuration in the user's home direcotory. This seems to work fine on
172+
# linux and macOS, but fails on Windows, so we conditionally provide a fake
173+
# USERPROFILE env variable to allow setuptools to proceed without finding
174+
# user-provided configuration.
175+
env = select({
176+
"@@platforms//os:windows": {"USERPROFILE": "Z:\\FakeSetuptoolsHomeDirectoryHack"},
177+
"//conditions:default": {},
178+
}) | env,
179+
# kwargs could contain test-specific attributes like size
178180
**dict(attrs, **kwargs)
179181
)

0 commit comments

Comments
 (0)