未验证 提交 db89b221 编写于 作者: F Frost Ming

Editable version take precedence over non-editable version

上级 673a7ca0
Fix a bug that editable package doesn't override the non-editable version in the working set.
......@@ -20,7 +20,7 @@ if TYPE_CHECKING:
def is_dist_editable(dist: Distribution) -> bool:
return isinstance(dist, EggInfoDistribution)
return isinstance(dist, EggInfoDistribution) or getattr(dist, "editable", False)
def format_dist(dist: Distribution) -> str:
......
......@@ -117,8 +117,11 @@ class Synchronizer:
can = candidates.pop(key)
if can.marker and not can.marker.evaluate(environment):
to_remove.append(key)
elif not is_dist_editable(dist) and dist.version != can.version:
# XXX: An editable distribution is always considered as consistent.
elif not is_dist_editable(dist) and (
dist.version != can.version or can.req.editable
):
to_update.append(key)
elif is_dist_editable(dist) and not can.req.editable:
to_update.append(key)
elif key not in self.all_candidates and key not in self.SEQUENTIAL_PACKAGES:
# Remove package only if it is not required by any section
......
......@@ -237,7 +237,12 @@ class Candidate:
}
project_root = self.environment.project.root.as_posix()
if self.req.is_vcs:
result.update({self.req.vcs: self.req.repo, "revision": self.revision})
result.update(
{
self.req.vcs: self.req.repo,
"ref": self.req.ref if self.req.editable else self.revision,
}
)
elif not self.req.is_named:
if self.req.is_file_or_url and self.req.is_local_dir:
result.update(path=path_replace(project_root, ".", self.req.str_path))
......
......@@ -450,3 +450,15 @@ def test_update_ignore_constraints(project, repository, working_set):
def test_init_validate_python_requires(project_no_init):
with pytest.raises(ValueError):
actions.do_init(project_no_init, python_requires="3.7")
def test_editable_package_override_non_editable(project, repository, working_set, vcs):
project.environment.python_requires = PySpecSet(">=3.6")
actions.do_add(
project, packages=["git+https://github.com/test-root/demo.git#egg=demo"]
)
actions.do_add(
project,
editables=["git+https://github.com/test-root/demo.git#egg=demo"],
)
assert working_set["demo"].editable
......@@ -146,9 +146,10 @@ class TestProject(Project):
class Distribution:
def __init__(self, key, version):
def __init__(self, key, version, editable=False):
self.key = key
self.version = version
self.editable = editable
self.dependencies = []
def requires(self, extras=()):
......@@ -190,7 +191,7 @@ def working_set(mocker, repository):
pip_logging._log_state.indentation = 0
dependencies = repository.get_dependencies(candidate)[0]
key = safe_name(candidate.name).lower()
dist = Distribution(key, candidate.version)
dist = Distribution(key, candidate.version, candidate.req.editable)
dist.dependencies = dependencies
rv.add_distribution(dist)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册