Skip to content

Commit c53d075

Browse files
authored
fix: use only-binary for download_only pip download (#1219)
[`wheel_installer` assumes that if the pip command succeeded, there must be at least one `*.whl` file](https://github.com/lpulley/rules_python/blob/fdec44120aa45d748ab804f1d019002c6949b449/python/pip_install/tools/wheel_installer/wheel_installer.py#L439), but this is not currently true when `download_only` is enabled and the package provides no wheel; a `.tar.gz` will happily be downloaded, pip will succeed, and the `next(iter(glob.glob("*.whl")))` call will fail, producing a mysterious `StopIteration`: ``` Saved ./artifactory-0.1.17.tar.gz Successfully downloaded artifactory (Traceback (most recent call last): File "[redacted]/lib/python3.8/runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "[redacted]/lib/python3.8/runpy.py", line 87, in _run_code exec(code, run_globals) File "[redacted]/external/rules_python/python/pip_install/tools/wheel_installer/wheel_installer.py", line 450, in <module> main() File "[redacted]/external/rules_python/python/pip_install/tools/wheel_installer/wheel_installer.py", line 438, in main whl = next(iter(glob.glob("*.whl"))) StopIteration ) ``` By using `--only-binary=:all:` when using `pip download`, the pip command will fail if there is no suitable wheel to be downloaded. This should make the error much more obvious, since with `--only-binary=:all:` and no suitable wheel, pip fails and reports an error like this: ``` ERROR: Could not find a version that satisfies the requirement artifactory (from versions: none) ERROR: No matching distribution found for artifactory ```
1 parent 32b0053 commit c53d075

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

python/pip_install/tools/wheel_installer/wheel_installer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,8 @@ def main() -> None:
406406
pip_args = (
407407
[sys.executable, "-m", "pip"]
408408
+ (["--isolated"] if args.isolated else [])
409-
+ ["download" if args.download_only else "wheel", "--no-deps"]
409+
+ (["download", "--only-binary=:all:"] if args.download_only else ["wheel"])
410+
+ ["--no-deps"]
410411
+ deserialized_args["extra_pip_args"]
411412
)
412413

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy