File: clean.py

package info (click to toggle)
python-setuptools-rust 1.9.0%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 648 kB
  • sloc: python: 1,703; javascript: 95; sh: 14; makefile: 13
file content (30 lines) | stat: -rw-r--r-- 801 bytes parent folder | download | duplicates (2)
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