Skip to content

Commit eb8c5eb

Browse files
committed
fix(pypi): inherit proxy env variables in compile_pip_requirements test
Bazel does not pass environment variables implicitly (even running test outside of sandbox). This forces compile_pip_requirements test to fail with timeout when attempting to run it behind the proxy. Also changes test_command in dependency_resolver string helper to use dot instead of underscore following deprecation notice.
1 parent fd29d27 commit eb8c5eb

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ END_UNRELEASED_TEMPLATE
9494
[#2363](https://github.com/bazel-contrib/rules_python/issues/2363).
9595
* (pypi) `whl_library` now infers file names from its `urls` attribute correctly.
9696
* (py_test, py_binary) Allow external files to be used for main
97+
* (pypi) `compile_pip_requirements` test rule works behind the proxy
9798

9899
{#v0-0-0-added}
99100
### Added

python/private/pypi/dependency_resolver/dependency_resolver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def main(
158158
update_command = (
159159
os.getenv("CUSTOM_COMPILE_COMMAND") or f"bazel run {target_label_prefix}.update"
160160
)
161-
test_command = f"bazel test {target_label_prefix}_test"
161+
test_command = f"bazel test {target_label_prefix}.test"
162162

163163
os.environ["CUSTOM_COMPILE_COMMAND"] = update_command
164164
os.environ["PIP_CONFIG_FILE"] = os.getenv("PIP_CONFIG_FILE") or os.devnull

python/private/pypi/pip_compile.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ def pip_compile(
4444
By default this rules generates a filegroup named "[name]" which can be included in the data
4545
of some other compile_pip_requirements rule that references these requirements
4646
(e.g. with `-r ../other/requirements.txt`).
47-
4847
It also generates two targets for running pip-compile:
4948
5049
- validate with `bazel test [name].test`
@@ -178,6 +177,7 @@ def pip_compile(
178177
"@@platforms//os:windows": {"USERPROFILE": "Z:\\FakeSetuptoolsHomeDirectoryHack"},
179178
"//conditions:default": {},
180179
}) | env,
180+
env_inherit = ["https_proxy", "http_proxy", "no_proxy", "HTTPS_PROXY", "HTTP_PROXY", "NO_PROXY"],
181181
# kwargs could contain test-specific attributes like size
182182
**dict(attrs, **kwargs)
183183
)

0 commit comments

Comments
 (0)