|
4 | 4 | import functools
|
5 | 5 | import glob
|
6 | 6 | import logging
|
| 7 | +import subprocess |
7 | 8 | import tempfile
|
8 | 9 |
|
9 | 10 | from pathlib import Path
|
@@ -542,7 +543,33 @@ def get_pep517_metadata(path: Path) -> PackageInfo:
|
542 | 543 | info = PackageInfo.from_metadata_directory(dest)
|
543 | 544 | except BuildBackendException as e:
|
544 | 545 | logger.debug("PEP517 build failed: %s", e)
|
545 |
| - raise PackageInfoError(path, e, "PEP517 build failed") |
| 546 | + |
| 547 | + if isinstance(e.exception, subprocess.CalledProcessError): |
| 548 | + inner_traceback = ( |
| 549 | + e.exception.output.decode() |
| 550 | + if type(e.exception.output) is bytes |
| 551 | + else e.exception.output |
| 552 | + ) |
| 553 | + inner_reason = "\n | ".join( |
| 554 | + ["", str(e.exception), "", *inner_traceback.split("\n")] |
| 555 | + ) |
| 556 | + reasons = [ |
| 557 | + f"<warning>{inner_reason}</warning>", |
| 558 | + ( |
| 559 | + "<info>" |
| 560 | + "<options=bold>Note:</> This error originates from the build backend, and is likely not a " |
| 561 | + f"problem with poetry but with the package at {path}\n\n" |
| 562 | + " (a) not supporting PEP 517 builds\n" |
| 563 | + " (b) not specifying PEP 517 build requirements correctly; or\n" |
| 564 | + " (c) the build requirement not being successfully installed in your system environment.\n\n" |
| 565 | + f'You can verify this by running <c1>pip wheel --no-cache-dir --use-pep517 "{path}"</c1>.' |
| 566 | + "</info>" |
| 567 | + ), |
| 568 | + ] |
| 569 | + else: |
| 570 | + reasons = [e, "PEP517 build failed"] |
| 571 | + |
| 572 | + raise PackageInfoError(path, *reasons) from None |
546 | 573 |
|
547 | 574 | if info:
|
548 | 575 | return info
|
|
0 commit comments