Commit 032cfa98 by Sébastien Eustace

Fix missing uninstall operation after resolution

parent d85c8125
...@@ -187,13 +187,32 @@ class Installer: ...@@ -187,13 +187,32 @@ class Installer:
): ):
# We resolve again by only using the lock file # We resolve again by only using the lock file
pool = Pool() pool = Pool()
pool.add_repository(local_repo)
# Making a new repo containing the packages
# newly resolved and the ones from the current lock file
locked_repository = self._locker.locked_repository(True)
repo = Repository()
for package in local_repo.packages + locked_repository.packages:
if not repo.has_package(package):
repo.add_package(package)
pool.add_repository(repo)
# We whitelist all packages to be sure
# that the latest ones are picked up
whitelist = []
for pkg in locked_repository.packages:
whitelist.append(pkg.name)
solver = Solver( solver = Solver(
self._package, pool, self._installed_repository, Repository(), NullIO() self._package,
pool,
self._installed_repository,
locked_repository,
NullIO(),
) )
ops = solver.solve() + [o for o in ops if o.job_type == "uninstall"] ops = solver.solve(use_latest=whitelist)
# We need to filter operations so that packages # We need to filter operations so that packages
# not compatible with the current system, # not compatible with the current system,
......
...@@ -962,6 +962,67 @@ def test_run_install_duplicate_dependencies_different_constraints_with_lock( ...@@ -962,6 +962,67 @@ def test_run_install_duplicate_dependencies_different_constraints_with_lock(
assert len(removals) == 0 assert len(removals) == 0
def test_run_update_uninstalls_after_removal_transient_dependency(
installer, locker, repo, package, installed
):
locker.locked(True)
locker.mock_lock_data(
{
"package": [
{
"name": "A",
"version": "1.0",
"category": "main",
"optional": False,
"platform": "*",
"python-versions": "*",
"checksum": [],
"dependencies": {"B": {"version": "^1.0", "python": "<2.0"}},
},
{
"name": "B",
"version": "1.0",
"category": "dev",
"optional": False,
"platform": "*",
"python-versions": "*",
"checksum": [],
},
],
"metadata": {
"python-versions": "*",
"platform": "*",
"content-hash": "123456789",
"hashes": {"A": [], "B": []},
},
}
)
package.add_dependency("A")
package_a = get_package("A", "1.0")
package_a.add_dependency("B", {"version": "^1.0", "python": "<2.0"})
package_b10 = get_package("B", "1.0")
repo.add_package(package_a)
repo.add_package(package_b10)
installed.add_package(get_package("A", "1.0"))
installed.add_package(get_package("B", "1.0"))
installer.update(True)
installer.run()
print(locker.written_data)
installs = installer.installer.installs
assert len(installs) == 0
updates = installer.installer.updates
assert len(updates) == 0
removals = installer.installer.removals
assert len(removals) == 1
def test_run_install_duplicate_dependencies_different_constraints_with_lock_update( def test_run_install_duplicate_dependencies_different_constraints_with_lock_update(
installer, locker, repo, package, installed installer, locker, repo, package, installed
): ):
......
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