def _get_operations_from_lock( self, locked_repository: Repository) -> List[Operation]: installed_repo = self._installed_repository ops = [] extra_packages = [ p.name for p in self._get_extra_packages(locked_repository) ] for locked in locked_repository.packages: is_installed = False for installed in installed_repo.packages: if locked.name == installed.name: is_installed = True if locked.category == 'dev' and not self.is_dev_mode(): ops.append(Uninstall(locked)) elif locked.optional and locked.name not in extra_packages: # Installed but optional and not requested in extras ops.append(Uninstall(locked)) elif locked.version != installed.version: ops.append(Update(installed, locked)) if not is_installed: # If it's optional and not in required extras # we do not install if locked.optional and locked.name not in extra_packages: continue ops.append(Install(locked)) return ops
def _get_operations_from_lock( self, locked_repository # type: Repository ): # type: (...) -> List[Operation] installed_repo = self._installed_repository ops = [] extra_packages = [ p.name for p in self._get_extra_packages(locked_repository) ] for locked in locked_repository.packages: is_installed = False for installed in installed_repo.packages: if locked.name == installed.name: is_installed = True if locked.category == "dev" and not self.is_dev_mode(): ops.append(Uninstall(locked)) elif locked.optional and locked.name not in extra_packages: # Installed but optional and not requested in extras ops.append(Uninstall(locked)) elif locked.version != installed.version: ops.append(Update(installed, locked)) # If it's optional and not in required extras # we do not install if locked.optional and locked.name not in extra_packages: continue op = Install(locked) if is_installed: op.skip("Already installed") ops.append(op) return ops
def _get_operations_from_lock( self, locked_repository: Repository) -> List[Operation]: installed_repo = InstalledRepository.load(self._io.venv) ops = [] extras = [] for extra_name, packages in self._locker.lock_data.get( 'extras').items(): if extra_name in self._extras: for package in packages: extras.append(package.lower()) for locked in locked_repository.packages: is_installed = False for installed in installed_repo.packages: if locked.name == installed.name: is_installed = True if locked.category == 'dev' and not self.is_dev_mode(): ops.append(Uninstall(locked)) elif locked.is_optional() and locked.name not in extras: # Installed but optional and not requested in extras ops.append(Uninstall(locked)) elif locked.version != installed.version: ops.append(Update(installed, locked)) if not is_installed: # If it's optional and not in required extras # we do not install if locked.is_optional() and locked.name not in extras: continue ops.append(Install(locked)) return ops