From 970e0bad9c38f6f606be7f1cd4537eb3400bda1d Mon Sep 17 00:00:00 2001 From: ijl Date: Thu, 27 Jun 2019 12:21:49 +0000 Subject: [PATCH] Error messages for bad cargo/rust environment during PEP517 install MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The error output from pip is otherwise not understandable by a user who does not know this package needs Rust or what Rust is. Installing build dependencies ... done Getting requirements to build wheel ... done Preparing wheel metadata ... error ERROR: Complete output from command ... pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel ... ERROR: 💥 pyo3-pack failed Cargo metadata failed: No such file or directory (os error 2) ... subprocess.CalledProcessError: Command '['pyo3-pack', 'pep517', 'write-dist-info', ... ' returned non-zero exit status 1 --- pyo3_pack/__init__.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pyo3_pack/__init__.py b/pyo3_pack/__init__.py index 97a7c9227..f64d8643d 100644 --- a/pyo3_pack/__init__.py +++ b/pyo3_pack/__init__.py @@ -100,6 +100,16 @@ def get_requires_for_build_sdist(config_settings=None): # noinspection PyUnusedLocal def prepare_metadata_for_build_wheel(metadata_directory, config_settings=None): + print("Checking for Rust toolchain....") + output = subprocess.check_output(["cargo", "--version"]).decode("utf-8", "ignore") + if not "cargo" in output: + sys.stderr.write( + "cargo, the Rust language build tool, is not installed or is not on PATH.\n" + "This package requires Rust to compile extensions. Install it through\n" + "the system's package manager or via https://rustup.rs/\n" + ) + sys.exit(1) + command = [ "pyo3-pack", "pep517",