1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
import subprocess
import sys
from .command import RustCommand
from .extension import RustExtension
class clean_rust(RustCommand):
"""Clean Rust extensions."""
description = "clean Rust extensions (compile/link to build directory)"
def initialize_options(self) -> None:
super().initialize_options()
self.inplace = False
def run_for_extension(self, ext: RustExtension) -> None:
# build cargo command
args = ["cargo", "clean", "--manifest-path", ext.path]
if ext.cargo_manifest_args:
args.extend(ext.cargo_manifest_args)
if not ext.quiet:
print(" ".join(args), file=sys.stderr)
# Execute cargo command
try:
subprocess.check_output(args)
except Exception:
pass
|