Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/poetry/core/packages/directory_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def __init__(
raise ValueError(f"Directory {self._path} does not exist")

self._develop = develop
self._supports_poetry = False

if not self._full_path.exists():
raise ValueError(f"Directory {self._path} does not exist")
Expand All @@ -45,12 +44,17 @@ def __init__(
raise ValueError(f"{self._path} is a file, expected a directory")

# Checking content to determine actions
setup = self._full_path / "setup.py"
self._supports_poetry = PyProjectTOML(
self._full_path / "pyproject.toml"
).is_poetry_project()
setup_py = self._full_path / "setup.py"
setup_cfg = self._full_path / "setup.cfg"
setuptools_project = setup_py.exists() or setup_cfg.exists()
pyproject = PyProjectTOML(self._full_path / "pyproject.toml")

if not setup.exists() and not self._supports_poetry:
self._supports_pep517 = (
setuptools_project or pyproject.is_build_system_defined()
)
self._supports_poetry = pyproject.is_poetry_project()

if not (self._supports_pep517 or self._supports_poetry):
raise ValueError(
f"Directory {self._full_path} does not seem to be a Python package"
)
Expand Down
3 changes: 3 additions & 0 deletions src/poetry/core/pyproject/toml.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ def data(self) -> TOMLDocument:

return self._data

def is_build_system_defined(self) -> bool:
return self._file.exists() and "build-system" in self.data

@property
def build_system(self) -> BuildSystem:
from poetry.core.pyproject.tables import BuildSystem
Expand Down
13 changes: 13 additions & 0 deletions tests/fixtures/project_with_pep517_non_poetry/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[build-system]
requires = ["flit_core >=3.7.1,<4"]
build-backend = "flit_core.buildapi"

[project]
name = "flit"
authors = []
dependencies = [
"flit_core >=3.7.1",
]
requires-python = ">=3.6"
readme = "README.rst"
dynamic = ['version', 'description']
18 changes: 18 additions & 0 deletions tests/fixtures/project_with_setup_cfg_only/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[metadata]
name = my_package
version = attr: my_package.VERSION
description = My package description
long_description = file: README.rst, CHANGELOG.rst, LICENSE.rst
keywords = one, two
license = BSD 3-Clause License
classifiers =
Framework :: Django
Programming Language :: Python :: 3

[options]
zip_safe = False
include_package_data = True
packages = find:
install_requires =
requests
importlib-metadata; python_version<"3.8"
18 changes: 18 additions & 0 deletions tests/packages/test_directory_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,21 @@ def test_directory_dependency_pep_508_extras() -> None:
requirement = f"demo[foo,bar] @ file://{path.as_posix()}"
requirement_expected = f"demo[bar,foo] @ file://{path.as_posix()}"
_test_directory_dependency_pep_508("demo", path, requirement, requirement_expected)


@pytest.mark.parametrize(
("fixture", "name"),
[
("project_with_pep517_non_poetry", "PEP 517"),
("project_with_setup_cfg_only", "setup.cfg"),
],
)
def test_directory_dependency_non_poetry_pep517(fixture: str, name: str) -> None:
path = Path(__file__).parent.parent / "fixtures" / fixture

try:
DirectoryDependency("package", path)
except ValueError as e:
if "does not seem to be a Python package" not in str(e):
raise e from e
pytest.fail(f"A {name} project not recognized as valid directory dependency")