Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised that we need the fake USERPROFILE only for _test and not for .update too.

Why is that the case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well... X_test runs as a Bazel action. X.update is only expected to be invoked by the user directly, in a normal environment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a possible source of confusion to have different behavior here, but I trust your (and @aignas's) judgement on this.

**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)
)