From e1dddc80e40d942ec17f802a5b1b56c284cfdcb6 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Tue, 9 Jan 2024 17:41:07 +0100 Subject: [PATCH] FIX: handle packages that are defined with `setup.cfg` --- src/repoma/utilities/project_info.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/repoma/utilities/project_info.py b/src/repoma/utilities/project_info.py index 5520a130..0b74d72d 100644 --- a/src/repoma/utilities/project_info.py +++ b/src/repoma/utilities/project_info.py @@ -88,13 +88,18 @@ def get_project_info(pyproject: TOMLDocument | None = None) -> ProjectInfo: def _load_project_info(pyproject: TOMLDocument | None = None) -> ProjectInfo | None: - if pyproject is not None or os.path.exists(CONFIG_PATH.pyproject): - if pyproject is None: - pyproject = load_pyproject() + if pyproject is not None: return ProjectInfo.from_pyproject_toml(pyproject) + candidates: list[ProjectInfo] = [] + if os.path.exists(CONFIG_PATH.pyproject): + pyproject = load_pyproject() + candidates.append(ProjectInfo.from_pyproject_toml(pyproject)) if os.path.exists(CONFIG_PATH.setup_cfg): cfg = open_config(CONFIG_PATH.setup_cfg) - return ProjectInfo.from_setup_cfg(cfg) + candidates.append(ProjectInfo.from_setup_cfg(cfg)) + for project_info in candidates: + if not project_info.is_empty(): + return project_info return None