Commit 2a70d67d by Adrian Garcia Badaracco Committed by GitHub

Always re-solve path dependencies (#6843)

Co-authored-by: Randy Döring <30527984+radoering@users.noreply.github.com>
parent 9df21a72
......@@ -201,10 +201,16 @@ class Installer:
self._io,
)
# Always re-solve directory dependencies, otherwise we can't determine
# if anything has changed (and the lock file contains an invalid version).
use_latest = [
p.name for p in locked_repository.packages if p.source_type == "directory"
]
with solver.provider.use_source_root(
source_root=self._env.path.joinpath("src")
):
ops = solver.solve(use_latest=[]).calculate_operations()
ops = solver.solve(use_latest=use_latest).calculate_operations()
lockfile_repo = LockfileRepository()
self._populate_lockfile_repo(lockfile_repo, ops)
......
......@@ -43,6 +43,7 @@ def _project_factory(
name="foobar",
pyproject_content=pyproject_content,
poetry_lock_content=poetry_lock_content,
source=source,
)
......@@ -68,6 +69,13 @@ def poetry_with_old_lockfile(
@pytest.fixture
def poetry_with_nested_path_deps_old_lockfile(
project_factory: ProjectFactory, fixture_dir: FixtureDirGetter
) -> Poetry:
return _project_factory("old_lock_path_dependency", project_factory, fixture_dir)
@pytest.fixture
def poetry_with_incompatible_lockfile(
project_factory: ProjectFactory, fixture_dir: FixtureDirGetter
) -> Poetry:
......@@ -166,6 +174,36 @@ def test_lock_no_update(
assert locked_repository.find_packages(package.to_dependency())
def test_lock_no_update_path_dependencies(
command_tester_factory: CommandTesterFactory,
poetry_with_nested_path_deps_old_lockfile: Poetry,
repo: TestRepository,
):
"""
The lock file contains a variant of the directory dependency "quix" that does
not depend on "sampleproject". Although the version of "quix" has not been changed,
it should be re-solved because there is always only one valid version
of a directory dependency at any time.
"""
repo.add_package(get_package("sampleproject", "1.3.1"))
locker = Locker(
lock=poetry_with_nested_path_deps_old_lockfile.pyproject.file.path.parent
/ "poetry.lock",
local_config=poetry_with_nested_path_deps_old_lockfile.locker._local_config,
)
poetry_with_nested_path_deps_old_lockfile.set_locker(locker)
tester = command_tester_factory(
"lock", poetry=poetry_with_nested_path_deps_old_lockfile
)
tester.execute("--no-update")
packages = locker.locked_repository().packages
assert {p.name for p in packages} == {"quix", "sampleproject"}
@pytest.mark.parametrize("is_no_update", [False, True])
def test_lock_with_incompatible_lockfile(
command_tester_factory: CommandTesterFactory,
......
# This file is automatically @generated by Poetry and should not be changed by hand.
[[package]]
name = "quix"
version = "1.2.3"
description = "Some description."
category = "main"
optional = false
python-versions = "~2.7 || ^3.4"
files = []
develop = true
[package.source]
type = "directory"
url = "quix"
[metadata]
lock-version = "2.0"
python-versions = "^3.8"
content-hash = "d2e1cf4390093213432fb8b58f90774a5247bfe860dedc2b023b27accc14cfad"
[tool.poetry]
name = "foobar"
version = "0.1.0"
description = ""
authors = ["Poetry Developer <developer@python-poetry.org>"]
[tool.poetry.dependencies]
python = "^3.8"
quix = { path = "./quix", develop = true}
[tool.poetry.dev-dependencies]
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
[tool.poetry]
name = "quix"
version = "1.2.3"
description = "Some description."
authors = ["Poetry Maintainer <tests@python-poetry.org>"]
license = "MIT"
# Requirements
[tool.poetry.dependencies]
python = "~2.7 || ^3.4"
sampleproject = ">=1.3.1"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment