diff --git a/src/conda_project/project.py b/src/conda_project/project.py index 4130f68..7174b32 100644 --- a/src/conda_project/project.py +++ b/src/conda_project/project.py @@ -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 diff --git a/tests/test_install.py b/tests/test_install.py index 4255542..2cfd930 100644 --- a/tests/test_install.py +++ b/tests/test_install.py @@ -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) @@ -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()}] """ )