Skip to content

Commit 6797654

Browse files
authored
Make dependencies.py generate fail on cargo-deny error (#1366)
## Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123. --> - Related to #1325. ## What changes are included in this PR? <!-- Provide a summary of the modifications in this PR. List the main changes such as new features, bug fixes, refactoring, or any other updates. --> `DEPENDENCIES.rust.tsv` files were accidentally removed as part of the 0.5.0 prep PR (#1345). It was added back and updated in the follow up PR (#1363). I realized this happened because I did not install `cargo-deny` in my env and the dependency generation script did not error. This PR changes generation script (`python3 ./scripts/dependencies.py generate`) to error when the underlying subprocess call (`cargo deny`) errors. I also ran `uvx ruff format scripts/dependencies.py` to format the script ## Are these changes tested? <!-- Specify what test covers (unit test, integration test, etc.). If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? --> Yes, manually I was also able to install `cargo-deny` and confirm #1363 changes are all correct ``` cargo install --locked cargo-deny ```
1 parent aa24cf4 commit 6797654

File tree

1 file changed

+26
-20
lines changed

1 file changed

+26
-20
lines changed

scripts/dependencies.py

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,34 +22,41 @@
2222

2323
DIRS = [
2424
"crates/iceberg",
25-
26-
"crates/catalog/glue", "crates/catalog/hms",
27-
"crates/catalog/memory", "crates/catalog/rest",
25+
"crates/catalog/glue",
26+
"crates/catalog/hms",
27+
"crates/catalog/memory",
28+
"crates/catalog/rest",
2829
"crates/catalog/sql",
29-
3030
"crates/integrations/datafusion",
31-
32-
"bindings/python"
31+
"bindings/python",
3332
]
3433

3534

3635
def check_deps():
3736
cargo_dirs = DIRS
3837
for root in cargo_dirs:
3938
print(f"Checking dependencies of {root}")
40-
subprocess.run(["cargo", "deny", "check", "license"], cwd=root)
39+
subprocess.run(["cargo", "deny", "check", "license"], cwd=root, check=True)
4140

4241

4342
def generate_deps():
4443
cargo_dirs = DIRS
4544
for root in cargo_dirs:
4645
print(f"Generating dependencies {root}")
47-
result = subprocess.run(
48-
["cargo", "deny", "list", "-f", "tsv", "-t", "0.6"],
49-
cwd=root,
50-
capture_output=True,
51-
text=True,
52-
)
46+
try:
47+
result = subprocess.run(
48+
["cargo", "deny", "list", "-f", "tsv", "-t", "0.6"],
49+
cwd=root,
50+
capture_output=True,
51+
text=True,
52+
check=True,
53+
)
54+
except subprocess.CalledProcessError as e:
55+
raise RuntimeError(
56+
f"Failed to run 'cargo deny' in '{root}'. "
57+
f"Is it installed?\n\nSTDERR:\n{e.stderr}"
58+
) from e
59+
5360
with open(f"{root}/DEPENDENCIES.rust.tsv", "w") as f:
5461
f.write(result.stdout)
5562

@@ -59,18 +66,17 @@ def generate_deps():
5966
parser.set_defaults(func=parser.print_help)
6067
subparsers = parser.add_subparsers()
6168

62-
parser_check = subparsers.add_parser('check',
63-
description="Check dependencies",
64-
help="Check dependencies")
69+
parser_check = subparsers.add_parser(
70+
"check", description="Check dependencies", help="Check dependencies"
71+
)
6572
parser_check.set_defaults(func=check_deps)
6673

6774
parser_generate = subparsers.add_parser(
68-
'generate',
69-
description="Generate dependencies",
70-
help="Generate dependencies")
75+
"generate", description="Generate dependencies", help="Generate dependencies"
76+
)
7177
parser_generate.set_defaults(func=generate_deps)
7278

7379
args = parser.parse_args()
7480
arg_dict = dict(vars(args))
75-
del arg_dict['func']
81+
del arg_dict["func"]
7682
args.func(**arg_dict)

0 commit comments

Comments
 (0)