import toml import subprocess as SP import os def set_version(rev=None): with open("Cargo.toml") as fh: cargo = toml.loads(fh.read()) cargo["dependencies"]["pyo3"]["rev"] = rev if rev is None: del cargo["dependencies"]["pyo3"]["rev"] with open("Cargo.toml", "w") as fh: toml.dump(cargo, fh) for commit in open("ch.txt").readlines(): set_version(commit.strip()) if os.system("cargo check") == 0: break