diff options
author | Martin Robinson <mrobinson@igalia.com> | 2024-12-13 09:47:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-13 08:47:40 +0000 |
commit | 682eba9f7425fb4478207372f5f9e550b467bf7b (patch) | |
tree | 4b84acf9a748ecb09caf949a34e5d723cf75e6c4 /python/servo/platform/base.py | |
parent | 53612dab90d08edc6ee3ba2856628c599a07fd83 (diff) | |
download | servo-682eba9f7425fb4478207372f5f9e550b467bf7b.tar.gz servo-682eba9f7425fb4478207372f5f9e550b467bf7b.zip |
tidy: Use more `cargo-deny` features (#34447)
Instead of parsing the `Cargo.lock` file directly in `tidy.py`. Use
`cargo-deny`, which we already use to detect unapproved licenses in the
dependency chain to detect duplicate and banned crates. In addition,
enable all other `cargo-deny` checks and add exceptions where necessary
for them. This depends on the latest release of `cargo-deny` which
depends on a recent verison of `rust`.
Fixes #34393.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Diffstat (limited to 'python/servo/platform/base.py')
-rw-r--r-- | python/servo/platform/base.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/python/servo/platform/base.py b/python/servo/platform/base.py index 6fb2f535f4e..347aa8e62e3 100644 --- a/python/servo/platform/base.py +++ b/python/servo/platform/base.py @@ -79,13 +79,21 @@ class Base: return True def install_cargo_deny(self, force: bool) -> bool: - if not force and shutil.which("cargo-deny") is not None: + def cargo_deny_installed(): + if force or not shutil.which("cargo-deny"): + return False + # Tidy needs at least version 0.16.3 installed. + result = subprocess.run(["cargo-deny", "--version"], + encoding='utf-8', capture_output=True) + (major, minor, micro) = result.stdout.strip().split(" ")[1].split(".", 2) + return (int(major), int(minor), int(micro)) >= (0, 16, 3) + + if cargo_deny_installed(): return False print(" * Installing cargo-deny...") if subprocess.call(["cargo", "install", "cargo-deny", "--locked"]) != 0: raise EnvironmentError("Installation of cargo-deny failed.") - return True def install_crown(self, force: bool) -> bool: |