我在用cargo
, maturin
and pytest
构建混合 Python/Rust 项目。在开发过程中,我经常循环使用命令:
$ cargo test -p mypkg --release
$ maturin develop --release
$ python -m pytest --failed-first my_pkg
看起来,cargo 和 maturin 正在编译依赖项,而没有理由这样做。经过一些实验,我发现如果我运行
cargo ...
maturin ...
cargo ...
maturin ...
第二次运行cargo
and maturin
即使我没有手动更改任何源文件,也会重新编译依赖项。
我没有一个小例子来重现这个问题,所以我尝试用完整的系统来调试它。为此,我想知道 Cargo 和/或 Maturin 认为哪些文件已经过时。一旦我知道了这一点,完整的解决方案可能就会显而易见。
但是,似乎没有我可以传递的标志来向我提供该信息。cargo -vv test ...
产生大量关于正在编译的内容和方式的输出,但不包括原因。maturin
甚至似乎没有-v
可用标志。
I found cargo-outdated
,但这似乎与依赖版本有关。
我有两个 Rust 包,每个包都有 5-10 个直接依赖项和大约 100 个总依赖项。
我怎样才能找出是什么文件造成的cargo
/maturin
重建依赖关系?
您可以要求 Cargo 输出与以下内容相关的日志信息指纹。对于 Cargo 1.56.0,适当的环境变量是CARGO_LOG=cargo::core::compiler::fingerprint=info
.
举个例子:
% CARGO_LOG=cargo::core::compiler::fingerprint=info cargo build
Finished dev [unoptimized + debuginfo] target(s) in 0.00s
% touch src/main.rs
% CARGO_LOG=cargo::core::compiler::fingerprint=info cargo build
[2021-11-30T18:13:54Z INFO cargo::core::compiler::fingerprint] stale: changed "/private/tmp/xxx/src/main.rs"
[2021-11-30T18:13:54Z INFO cargo::core::compiler::fingerprint] (vs) "/private/tmp/xxx/target/debug/.fingerprint/xxx-3af563e7d679143a/dep-bin-xxx"
[2021-11-30T18:13:54Z INFO cargo::core::compiler::fingerprint] FileTime { seconds: 1638295984, nanos: 344057437 } != FileTime { seconds: 1638296033, nanos: 750100000 }
[2021-11-30T18:13:54Z INFO cargo::core::compiler::fingerprint] fingerprint error for xxx v0.1.0 (/private/tmp/xxx)/Build/TargetInner { name: "xxx", doc: true, ..: with_path("/private/tmp/xxx/src/main.rs", Edition2021) }
[2021-11-30T18:13:54Z INFO cargo::core::compiler::fingerprint] err: current filesystem status shows we're outdated
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)