Skip to content

Commit 9770dab

Browse files
committed
Refine Cargo machete checks and dependencies
- Run `cargo machete --with-metadata` in pre-commit - Remove unused Betfair, IB, and system dev deps - Add machete ignores for feature-gated build deps - Gate serialization schema build deps behind `capnp`
1 parent 5d43844 commit 9770dab

11 files changed

Lines changed: 37 additions & 40 deletions

File tree

.pre-commit-hooks/cargo_machete.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# lists in each crate's Cargo.toml. Known categories:
66
# - Feature-graph plumbing (optional deps referenced only in [features])
77
# - Macro-expansion-only deps (brought into scope by a derive elsewhere)
8-
# - Build-script deps (handled by default invocation; do not use --with-metadata)
8+
# - Build-script deps (cargo-machete cannot always see feature-gated build.rs uses)
99

1010
set -euo pipefail
1111

@@ -24,8 +24,8 @@ if [ "$installed_version" != "$PINNED_VERSION" ]; then
2424
echo " cargo install --locked cargo-machete@${PINNED_VERSION}"
2525
fi
2626

27-
echo "Running cargo machete..."
28-
if ! cargo machete; then
27+
echo "Running cargo machete --with-metadata..."
28+
if ! cargo machete --with-metadata; then
2929
echo ""
3030
echo "If a flagged dependency is a false positive (feature-gate plumbing,"
3131
echo "macro expansion, etc.), add it to the crate's Cargo.toml with a"

Cargo.lock

Lines changed: 0 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ members = [
88
"crates/adapters/bitmex",
99
"crates/adapters/blockchain",
1010
"crates/adapters/bybit",
11+
"crates/adapters/coinbase",
1112
"crates/adapters/databento",
1213
"crates/adapters/deribit",
1314
"crates/adapters/dydx",
14-
"crates/adapters/coinbase",
1515
"crates/adapters/hyperliquid",
16-
"crates/adapters/kraken",
17-
"crates/adapters/polymarket",
1816
"crates/adapters/interactive_brokers",
17+
"crates/adapters/kraken",
1918
"crates/adapters/okx",
19+
"crates/adapters/polymarket",
2020
"crates/adapters/sandbox",
2121
"crates/adapters/tardis",
2222
"crates/analysis",
@@ -32,9 +32,9 @@ members = [
3232
"crates/infrastructure",
3333
"crates/live",
3434
"crates/model",
35-
"crates/persistence/macros",
3635
"crates/network",
3736
"crates/persistence",
37+
"crates/persistence/macros",
3838
"crates/plugin",
3939
"crates/portfolio",
4040
"crates/pyo3",
@@ -372,7 +372,6 @@ pretty_assertions = "1.4.1"
372372
proptest = { version = "1.11.0", default-features = false, features = ["std"] }
373373
rstest = "0.26.1"
374374
tempfile = "3.27.0"
375-
tracing-test = "0.2.6"
376375
turmoil = "0.7.2"
377376

378377
# -----------------------------------------------------------------------------

crates/adapters/betfair/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ pyo3-stub-gen = { workspace = true, optional = true }
7676

7777
[dev-dependencies]
7878
nautilus-backtest = { workspace = true }
79-
nautilus-execution = { workspace = true }
8079
nautilus-testkit = { workspace = true }
8180
nautilus-trading = { workspace = true }
8281

crates/adapters/interactive_brokers/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ nautilus-trading = { workspace = true }
100100
rstest = { workspace = true }
101101
rust_decimal_macros = { workspace = true }
102102
tempfile = { workspace = true }
103-
tracing-test = { workspace = true }
104103

105104
# Run live smoke with `cargo run --example ib-data-tester --package nautilus-interactive-brokers --features examples`.
106105
# Run embedded config unit tests with `cargo test --example ib-data-tester --package nautilus-interactive-brokers --features examples`.

crates/backtest/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ python = [
5757
"streaming",
5858
]
5959

60+
[package.metadata.cargo-machete]
61+
ignored = [
62+
"cbindgen", # Used by build.rs when the `ffi` feature is enabled
63+
]
64+
6065
[package.metadata.docs.rs]
6166
all-features = true
6267
rustdoc-args = ["--cfg", "docsrs"]

crates/common/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ high-precision = ["nautilus-model/high-precision"]
4646
capnp = ["nautilus-serialization/capnp"]
4747
tracing-bridge = ["tracing", "tracing-subscriber"]
4848

49+
[package.metadata.cargo-machete]
50+
ignored = [
51+
"cbindgen", # Used by build.rs when the `ffi` feature is enabled
52+
]
53+
4954
[package.metadata.docs.rs]
5055
all-features = true
5156
rustdoc-args = ["--cfg", "docsrs"]

crates/core/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ extension-module = ["python", "pyo3/extension-module"]
2727
ffi = ["cbindgen"]
2828
python = ["pyo3", "pyo3-stub-gen", "strum"]
2929

30+
[package.metadata.cargo-machete]
31+
ignored = [
32+
"cbindgen", # Used by build.rs when the `ffi` feature is enabled
33+
"toml", # Used by build.rs to read pyproject.toml version metadata
34+
]
35+
3036
[package.metadata.docs.rs]
3137
all-features = true
3238
rustdoc-args = ["--cfg", "docsrs"]

crates/model/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ high-precision = []
3737
defi = ["alloy-primitives", "high-precision"]
3838
cython-compat = []
3939

40+
[package.metadata.cargo-machete]
41+
ignored = [
42+
"cbindgen", # Used by build.rs when the `ffi` feature is enabled
43+
]
44+
4045
[package.metadata.docs.rs]
4146
all-features = true
4247
rustdoc-args = ["--cfg", "docsrs"]

crates/serialization/Cargo.toml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ crate-type = ["rlib"]
3434
[features]
3535
default = []
3636
arrow = ["dep:arrow", "nautilus-model/arrow"]
37-
capnp = ["dep:capnp"]
37+
capnp = ["dep:capnp", "dep:capnpc", "dep:walkdir"]
3838
display = ["arrow"]
3939
sbe = []
4040
extension-module = [
@@ -51,6 +51,12 @@ python = [
5151
]
5252
high-precision = ["nautilus-model/high-precision"]
5353

54+
[package.metadata.cargo-machete]
55+
ignored = [
56+
"capnpc", # Used by build.rs when the `capnp` feature is enabled
57+
"walkdir", # Used by build.rs when the `capnp` feature is enabled
58+
]
59+
5460
[package.metadata.docs.rs]
5561
all-features = true
5662
rustdoc-args = ["--cfg", "docsrs"]
@@ -80,8 +86,8 @@ pretty_assertions = { workspace = true }
8086
rstest = { workspace = true }
8187

8288
[build-dependencies]
83-
capnpc = { workspace = true }
84-
walkdir = { workspace = true }
89+
capnpc = { workspace = true, optional = true }
90+
walkdir = { workspace = true, optional = true }
8591

8692
[[bench]]
8793
name = "capnp_serialization"

0 commit comments

Comments
 (0)