diff --git a/src/poetry/core/packages/dependency.py b/src/poetry/core/packages/dependency.py index f5f559a85..c9cca8cd5 100644 --- a/src/poetry/core/packages/dependency.py +++ b/src/poetry/core/packages/dependency.py @@ -406,8 +406,7 @@ def create_from_pep_508( if os.path.isdir(p) and (os.path.sep in name or name.startswith(".")): if not is_python_project(Path(name)): raise ValueError( - f"Directory {name!r} is not installable. File 'setup.[py|cfg]' " - "not found." + f"Directory {name!r} is not installable. Not a Python project." ) link = Link(path_to_url(p)) elif is_archive_file(p): diff --git a/src/poetry/core/packages/utils/utils.py b/src/poetry/core/packages/utils/utils.py index 97229517b..55e124912 100644 --- a/src/poetry/core/packages/utils/utils.py +++ b/src/poetry/core/packages/utils/utils.py @@ -18,7 +18,6 @@ from poetry.core.constraints.version import Version from poetry.core.constraints.version import VersionRange from poetry.core.constraints.version import parse_marker_version_constraint -from poetry.core.pyproject.toml import PyProjectTOML from poetry.core.version.markers import SingleMarker from poetry.core.version.markers import SingleMarkerLike from poetry.core.version.markers import dnf @@ -129,12 +128,9 @@ def is_python_project(path: Path) -> bool: setup_cfg = path / "setup.cfg" setuptools_project = setup_py.exists() or setup_cfg.exists() - pyproject = PyProjectTOML(path / "pyproject.toml") + pyproject = (path / "pyproject.toml").exists() - supports_pep517 = setuptools_project or pyproject.is_build_system_defined() - supports_poetry = pyproject.is_poetry_project() - - return supports_pep517 or supports_poetry + return pyproject or setuptools_project def is_archive_file(name: str) -> bool: diff --git a/src/poetry/core/pyproject/toml.py b/src/poetry/core/pyproject/toml.py index 45a2d9d87..bc10113b1 100644 --- a/src/poetry/core/pyproject/toml.py +++ b/src/poetry/core/pyproject/toml.py @@ -33,9 +33,6 @@ def data(self) -> dict[str, Any]: return self._data - def is_build_system_defined(self) -> bool: - return "build-system" in self.data - @property def build_system(self) -> BuildSystem: if self._build_system is None: diff --git a/tests/fixtures/project_minimal/pyproject.toml b/tests/fixtures/project_minimal/pyproject.toml new file mode 100644 index 000000000..cb1731fc6 --- /dev/null +++ b/tests/fixtures/project_minimal/pyproject.toml @@ -0,0 +1,3 @@ +[project] +name = "minimal" +version = "1" diff --git a/tests/packages/test_directory_dependency.py b/tests/packages/test_directory_dependency.py index 3d3533633..72d7ae65a 100644 --- a/tests/packages/test_directory_dependency.py +++ b/tests/packages/test_directory_dependency.py @@ -66,6 +66,12 @@ def test_directory_dependency_is_not_a_python_project( dep.validate(raise_error=True) +def test_directory_dependency_minimal() -> None: + path = Path(__file__).parent.parent / "fixtures" / "project_minimal" + dep = DirectoryDependency("demo", path) + dep.validate(raise_error=True) + + def _test_directory_dependency_pep_508( name: str, path: Path, pep_508_input: str, pep_508_output: str | None = None ) -> None: