Skip to content

Commit 370901f

Browse files
fix: Hide stacktrace on resolution failure
1 parent 538e4fe commit 370901f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

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
@@ -203,6 +205,7 @@ def main(
203205
requirements_file_relative_path.write_text(content)
204206
else:
205207
print("Checking " + requirements_file)
208+
sys.stdout.flush()
206209
_run_pip_compile()
207210
golden = open(_locate(bazel_runfiles, requirements_file)).readlines()
208211
out = open(requirements_out).readlines()
@@ -225,6 +228,14 @@ def run_pip_compile(
225228
) -> None:
226229
try:
227230
cli(args, standalone_mode=False)
231+
except DistributionNotFound as e:
232+
if isinstance(e.__cause__, ResolutionImpossible):
233+
# pip logs an informative error to stderr already
234+
# just render the error and exit
235+
print(e)
236+
sys.exit(1)
237+
else:
238+
raise
228239
except SystemExit as e:
229240
if e.code == 0:
230241
return # shouldn't happen, but just in case

0 commit comments

Comments
 (0)