def get_intersphinx_version(pyproj, dep): deps = pyproj["project"]["dependencies"] for d in deps: req = Requirement(d) if req.name not in dep: continue if req.specifier: return next(iter(req.specifier)).version else: return "latest" with open("../pyproject.toml", "rb") as fp: pyproj = tomllib.load(fp) am_ver = get_intersphinx_version(pyproj, "amaranth")