Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix is_consistent again #140

Merged
merged 1 commit into from
Aug 24, 2023
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
14 changes: 10 additions & 4 deletions src/conda_project/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,17 +501,23 @@ def is_consistent(self) -> bool:
# We only include locked packages for the current platform, and don't
# include optional dependencies (e.g. compile/build)
lock = parse_conda_lock_file(self.lockfile)
current_platform_packages = [
p
for p in lock.package
if p.platform == current_platform() and p.category == "main"
]

# When an environment is installed pypi packages take precedence
deduped_lock = dedupe_list_of_dicts(
lock.package, key=lambda x: x.name, keep=lambda x: x.manager == "pip"
current_platform_packages,
key=lambda x: x.name,
keep=lambda x: x.manager == "pip",
)

locked_pkgs = set()
for p in deduped_lock:
if p.platform == current_platform() and p.category == "main":
hash = p.hash.md5 if p.manager == "conda" else p.hash.sha256
locked_pkgs.add((p.name, p.version, p.manager, hash))
hash = p.hash.md5 if p.manager == "conda" else p.hash.sha256
locked_pkgs.add((p.name, p.version, p.manager, hash))

# Compare the sets
# We can do this because the tuples are hashable. Also we don't need to
Expand Down
6 changes: 2 additions & 4 deletions tests/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,9 @@ def test_install_no_dependencies(project_directory_factory):
@pytest.mark.slow
def test_is_installed(project_directory_factory):
env_yaml = dedent(
f"""\
"""\
name: test
dependencies: [python=3.8]
platforms: [{current_platform()}]
"""
)
project_path = project_directory_factory(env_yaml=env_yaml)
Expand All @@ -61,12 +60,11 @@ def test_is_installed(project_directory_factory):
assert project.default_environment.is_consistent

updated_yaml = dedent(
f"""\
"""\
name: test
dependencies:
- python=3.8
- requests
platforms: [{current_platform()}]
"""
)

Expand Down
Loading