Fixes for getting package version

Older versions of Python's subprocess do not have capture_output, so
just get stdout directly.

Also pass the full path to cargo in case it is not on PATH.

Test: Run
Change-Id: I368e905a93b344bca6635c6ab7a60def809e88d5
This commit is contained in:
Joel Galenson
2021-08-16 11:22:47 -07:00
parent e203a54627
commit c51865074b

View File

@@ -483,8 +483,9 @@ class Crate(object):
and where the package name does not match the emitted crate_name
(e.g. [lib.name] is set).
"""
cargo_metadata = subprocess.run(['cargo', 'metadata', '--no-deps'],
cwd=os.path.abspath(self.cargo_dir), capture_output=True)
cargo_metadata = subprocess.run([self.runner.cargo_path, 'metadata', '--no-deps'],
cwd=os.path.abspath(self.cargo_dir),
stdout=subprocess.PIPE)
if cargo_metadata.returncode:
self.errors += ('ERROR: unable to get cargo metadata for package version; ' +
'return code ' + cargo_metadata.returncode + '\n')