Skip to content

Commit 89987b2

Browse files
fix: Hide stacktrace on resolution failure
1 parent e0c2715 commit 89987b2

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ Unreleased changes template.
102102
* (packaging) An empty `requires_file` is treated as if it were omitted, resulting in a valid `METADATA` file.
103103
* (rules) py_wheel and sphinxdocs rules now propagate `target_compatible_with` to all targets they create.
104104
[PR #2788](https://github.com/bazel-contrib/rules_python/pull/2788).
105+
* (pypi) Dependency resolution failures no longer show the full exception traceback in the output
105106

106107
{#v0-0-0-added}
107108
### Added

python/private/pypi/dependency_resolver/dependency_resolver.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
import click
2626
import piptools.writer as piptools_writer
27+
from pip._internal.exceptions import DistributionNotFound
28+
from pip._vendor.resolvelib.resolvers import ResolutionImpossible
2729
from piptools.scripts.compile import cli
2830

2931
from python.runfiles import runfiles
@@ -201,6 +203,7 @@ def main(
201203
requirements_file_relative_path.write_text(content)
202204
else:
203205
print("Checking " + requirements_file)
206+
sys.stdout.flush()
204207
_run_pip_compile()
205208
golden = open(_locate(bazel_runfiles, requirements_file)).readlines()
206209
out = open(requirements_out).readlines()
@@ -223,6 +226,14 @@ def run_pip_compile(
223226
) -> None:
224227
try:
225228
cli(args, standalone_mode=False)
229+
except DistributionNotFound as e:
230+
if isinstance(e.__cause__, ResolutionImpossible):
231+
# pip logs an informative error to stderr already
232+
# just render the error and exit
233+
print(e)
234+
sys.exit(1)
235+
else:
236+
raise
226237
except SystemExit as e:
227238
if e.code == 0:
228239
return # shouldn't happen, but just in case

0 commit comments

Comments
 (0)