Skip to content

Commit

Permalink
fix: detect src layout only if it exists and included by build config
Browse files Browse the repository at this point in the history
Resolve #249

Signed-off-by: Frost Ming <[email protected]>
  • Loading branch information
frostming committed Jul 5, 2024
1 parent fd5eff3 commit 9466c66
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/pdm/backend/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,24 @@ def run_setuptools(self) -> bool:
"""Whether to run setuptools"""
return self.get("run-setuptools", False)

def _get_default_package_dir(self) -> str:
if (
self.root.joinpath("src").is_dir()
and not self.includes
# the first path part must not be a wildcard
or any(Path(p).is_relative_to("src") for p in self.includes)
and "src" not in self.excludes
and "src/" not in self.excludes
):
return "src"
return ""

@property
def package_dir(self) -> str:
"""A directory that will be used to looking for packages."""
default = "src" if self.root.joinpath("src").exists() else ""
return self.get("package-dir", default)
if "package-dir" in self:
return self["package-dir"]
return self._get_default_package_dir()

@property
def is_purelib(self) -> bool:
Expand Down

0 comments on commit 9466c66

Please sign in to comment.