Skip to content

Commit

Permalink
fix: installation of missing directory dependencies with --skip-direc…
Browse files Browse the repository at this point in the history
…tory (#7923)

Co-authored-by: Randy Döring <30527984+radoering@users.noreply.github.com>
  • Loading branch information
adriangb and radoering committed May 18, 2023
1 parent 0af3f1e commit 3602b21
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
9 changes: 9 additions & 0 deletions src/poetry/installation/installer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

from typing import TYPE_CHECKING
from typing import cast

from cleo.io.null_io import NullIO
from packaging.utils import canonicalize_name
Expand All @@ -21,6 +22,7 @@

from cleo.io.io import IO
from packaging.utils import NormalizedName
from poetry.core.packages.path_dependency import PathDependency
from poetry.core.packages.project_package import ProjectPackage

from poetry.config.config import Config
Expand Down Expand Up @@ -336,6 +338,13 @@ def _do_install(self) -> int:
# or optional and not requested, are dropped
self._filter_operations(ops, lockfile_repo)

# Validate the dependencies
for op in ops:
dep = op.package.to_dependency()
if dep.is_file() or dep.is_directory():
dep = cast("PathDependency", dep)
dep.validate(raise_error=True)

# Execute operations
status = self._execute(ops)

Expand Down
6 changes: 0 additions & 6 deletions src/poetry/puzzle/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
from poetry.core.packages.directory_dependency import DirectoryDependency
from poetry.core.packages.file_dependency import FileDependency
from poetry.core.packages.package import Package
from poetry.core.packages.path_dependency import PathDependency
from poetry.core.packages.url_dependency import URLDependency
from poetry.core.packages.vcs_dependency import VCSDependency
from poetry.core.version.markers import BaseMarker
Expand Down Expand Up @@ -560,11 +559,6 @@ def complete_package(
if locked is not None and locked.package.is_same_package_as(dep):
continue
self.search_for_direct_origin_dependency(dep)
else:
for dep in _dependencies:
if dep.is_file() or dep.is_directory():
dep = cast("PathDependency", dep)
dep.validate(raise_error=True)

dependencies = self._get_dependencies_with_overrides(
_dependencies, dependency_package
Expand Down
20 changes: 20 additions & 0 deletions tests/console/commands/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,3 +437,23 @@ def test_install_path_dependency_does_not_exist(
else:
with pytest.raises(ValueError, match="does not exist"):
tester.execute(options)


@pytest.mark.parametrize("options", ["", "--no-directory"])
def test_install_missing_directory_dependency_with_no_directory(
command_tester_factory: CommandTesterFactory,
project_factory: ProjectFactory,
fixture_dir: FixtureDirGetter,
options: str,
) -> None:
poetry = _project_factory(
"missing_directory_dependency", project_factory, fixture_dir
)
assert isinstance(poetry.locker, TestLocker)
poetry.locker.locked(True)
tester = command_tester_factory("install", poetry=poetry)
if options:
tester.execute(options)
else:
with pytest.raises(ValueError, match="does not exist"):
tester.execute(options)

0 comments on commit 3602b21

Please sign in to comment.