def _find_conda_deviations(self, prefix, env_spec): try: installed = conda_api.installed(prefix) except conda_api.CondaError as e: raise CondaManagerError( "Conda failed while listing installed packages in %s: %s" % (prefix, str(e))) missing = set() wrong_version = set() for spec_string in env_spec.conda_packages_for_create: spec = conda_api.parse_spec(spec_string) name = spec.name if name not in installed: missing.add(name) else: def version_match(wanted, installed): if wanted == installed: return True else: return installed.startswith(wanted + ".") # The only constraint we are smart enough to understand is # the one we put in the lock file, which is plain =. # We can't do version comparisons, which is a bug. # We won't notice if non-= constraints are unmet. (_, installed_version, installed_build) = installed[name] if spec.exact_version is not None and not version_match( spec.exact_version, installed_version): wrong_version.add(name) elif spec.exact_build_string is not None and not version_match( spec.exact_build_string, installed_build): wrong_version.add(name) return (sorted(list(missing)), sorted(list(wrong_version)))
def check_installed(dirname): installed = conda_api.installed(dirname) assert dict() == installed
def test_installed_on_nonexistent_prefix(): installed = conda_api.installed("/this/does/not/exist") assert dict() == installed