Skip to content

Commit

Permalink
Find pyproject.toml in parent directories of Cargo.toml
Browse files Browse the repository at this point in the history
When `--manifest-path` is supplied via cli, lookup `pyproject.toml`
in its parent directories until current working directory.
  • Loading branch information
messense committed Aug 10, 2022
1 parent e27200d commit 8ba713b
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/project_layout.rs
Original file line number Diff line number Diff line change
@@ -129,14 +129,24 @@ impl ProjectResolver {

/// Get cargo manifest file path and pyproject.toml path
fn resolve_manifest_paths(cargo_manifest_path: Option<PathBuf>) -> Result<(PathBuf, PathBuf)> {
let current_dir = env::current_dir()
.context("Failed to detect current directory ಠ_ಠ")?
.canonicalize()?;
// use command line argument if specified
if let Some(path) = cargo_manifest_path {
let manifest_file = path.canonicalize()?;
for parent in manifest_file.ancestors().skip(1) {
if !parent.starts_with(&current_dir) {
break;
}
let pyproject_file = parent.join(PYPROJECT_TOML);
if pyproject_file.is_file() {
return Ok((manifest_file, pyproject_file));
}
}
return Ok((path.clone(), path.parent().unwrap().join(PYPROJECT_TOML)));
}
// check `manifest-path` option in pyproject.toml
let current_dir = env::current_dir()
.context("Failed to detect current directory ಠ_ಠ")?
.canonicalize()?;
let pyproject_file = current_dir.join(PYPROJECT_TOML);
if pyproject_file.is_file() {
let pyproject =

0 comments on commit 8ba713b

Please sign in to comment.