From 0896e2526e4a70d3609e8310e4afde1d5a857a12 Mon Sep 17 00:00:00 2001 From: Logan Pulley Date: Mon, 7 Oct 2024 15:42:35 +0000 Subject: [PATCH 1/2] Pass kwargs env to both update and test targets --- python/private/pypi/pip_compile.bzl | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/python/private/pypi/pip_compile.bzl b/python/private/pypi/pip_compile.bzl index a6cabf70c1..dc5b186a6a 100644 --- a/python/private/pypi/pip_compile.bzl +++ b/python/private/pypi/pip_compile.bzl @@ -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 ) @@ -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) ) From f66e55a81bc7f42db323ec9fc6111bbd6a6a4700 Mon Sep 17 00:00:00 2001 From: Logan Pulley Date: Tue, 8 Oct 2024 14:40:47 +0000 Subject: [PATCH 2/2] Add CHANGELOG entry --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b0807d5c57..67c3477443 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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