From dc3a59f43ebd2f97f511dbe499d0e08ebae7b482 Mon Sep 17 00:00:00 2001 From: messense Date: Sun, 7 Aug 2022 21:27:39 +0800 Subject: [PATCH] Find python module next to `pyproject.toml` if `pyproject.toml` exists --- Changelog.md | 3 +++ src/project_layout.rs | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Changelog.md b/Changelog.md index b27c29ef1..6fd1814f7 100644 --- a/Changelog.md +++ b/Changelog.md @@ -13,6 +13,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Add Linux sparc64 architecture support in [#1027](https://github.com/PyO3/maturin/pull/1027) * Add PEP 440 local version identifier support in [#1037](https://github.com/PyO3/maturin/pull/1037) * Fix inconsistent `Cargo.toml` and `pyproject.toml` path handling in [#1043](https://github.com/PyO3/maturin/pull/1043) +* Find python module next to `pyproject.toml` if `pyproject.toml` exists in [#1044](https://github.com/PyO3/maturin/pull/1044). + It's technically a **breaking change**, but previously it doesn't work properly + if the directory containing `pyproject.toml` isn't recognized as project root. ## [0.13.1] - 2022-07-26 diff --git a/src/project_layout.rs b/src/project_layout.rs index fe643d861..6a236a85b 100644 --- a/src/project_layout.rs +++ b/src/project_layout.rs @@ -52,7 +52,7 @@ impl ProjectResolver { let manifest_dir = manifest_file.parent().unwrap(); let pyproject_toml: Option = if pyproject_file.is_file() { let pyproject = - PyProjectToml::new(pyproject_file).context("pyproject.toml is invalid")?; + PyProjectToml::new(&pyproject_file).context("pyproject.toml is invalid")?; pyproject.warn_missing_maturin_version(); pyproject.warn_missing_build_backend(); Some(pyproject) @@ -89,8 +89,13 @@ impl ProjectResolver { let data = pyproject .and_then(|x| x.data()) .or_else(|| extra_metadata.data.as_ref().map(Path::new)); + let project_root = if pyproject_file.is_file() { + pyproject_file.parent().unwrap_or(manifest_dir) + } else { + manifest_dir + }; let project_layout = ProjectLayout::determine( - manifest_dir, + project_root, extension_name, extra_metadata.python_source.as_deref(), data,