Skip to content

Commit

Permalink
fix: pass kwargs env to both update and test targets (bazelbuild#2277)
Browse files Browse the repository at this point in the history
  • Loading branch information
lpulley authored Oct 9, 2024
1 parent bf4978c commit 83eb5e8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ A brief description of the categories of changes:
wheel is created
* (whl_library) truncate progress messages from the repo rule to better handle
case where a requirement has many `--hash=sha256:...` flags
* (rules) `compile_pip_requirements` passes `env` to the `X.update` target (and
not only to the `X_test` target, a bug introduced in
[#1067](https://github.com/bazelbuild/rules_python/pull/1067)).

### Added
* (py_wheel) Now supports `compress = (True|False)` to allow disabling
Expand Down
22 changes: 12 additions & 10 deletions python/private/pypi/pip_compile.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -154,18 +154,11 @@ def pip_compile(
"visibility": visibility,
}

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

py_binary(
name = name + ".update",
env = env,
**attrs
)

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

0 comments on commit 83eb5e8

Please sign in to comment.