def incompatibilities_for( self, package ): # type: (DependencyPackage) -> List[Incompatibility] """ Returns incompatibilities that encapsulate a given package's dependencies, or that it can't be safely selected. If multiple subsequent versions of this package have the same dependencies, this will return incompatibilities that reflect that. It won't return incompatibilities that have already been returned by a previous call to _incompatibilities_for(). """ if package.is_root(): dependencies = package.all_requires else: dependencies = package.requires if not package.python_constraint.allows_all( self._package.python_constraint ): transitive_python_constraint = get_python_constraint_from_marker( package.dependency.transitive_marker ) intersection = package.python_constraint.intersect( transitive_python_constraint ) difference = transitive_python_constraint.difference(intersection) if ( transitive_python_constraint.is_any() or self._package.python_constraint.intersect( package.dependency.python_constraint ).is_empty() or intersection.is_empty() or not difference.is_empty() ): return [ Incompatibility( [Term(package.to_dependency(), True)], PythonCause( package.python_versions, self._package.python_versions ), ) ] dependencies = [ dep for dep in dependencies if dep.name not in self.UNSAFE_PACKAGES and self._package.python_constraint.allows_any(dep.python_constraint) ] return [ Incompatibility( [Term(package.to_dependency(), True), Term(dep, False)], DependencyCause(), ) for dep in dependencies ]
def incompatibilities_for( self, package: DependencyPackage) -> list[Incompatibility]: """ Returns incompatibilities that encapsulate a given package's dependencies, or that it can't be safely selected. If multiple subsequent versions of this package have the same dependencies, this will return incompatibilities that reflect that. It won't return incompatibilities that have already been returned by a previous call to _incompatibilities_for(). """ if package.is_root(): dependencies = package.all_requires else: dependencies = package.requires if not package.python_constraint.allows_all( self._python_constraint): transitive_python_constraint = get_python_constraint_from_marker( package.dependency.transitive_marker) intersection = package.python_constraint.intersect( transitive_python_constraint) difference = transitive_python_constraint.difference( intersection) # The difference is only relevant if it intersects # the root package python constraint difference = difference.intersect(self._python_constraint) if (transitive_python_constraint.is_any() or self._python_constraint.intersect( package.dependency.python_constraint).is_empty() or intersection.is_empty() or not difference.is_empty()): return [ Incompatibility( [Term(package.to_dependency(), True)], PythonCause(package.python_versions, str(self._python_constraint)), ) ] _dependencies = [ dep for dep in dependencies if dep.name not in self.UNSAFE_PACKAGES and self._python_constraint.allows_any(dep.python_constraint) and ( not self._env or dep.marker.validate(self._env.marker_env)) ] dependencies = self._get_dependencies_with_overrides( _dependencies, package) return [ Incompatibility( [Term(package.to_dependency(), True), Term(dep, False)], DependencyCause(), ) for dep in dependencies ]
def incompatibilities_for( self, package): # type: (Package) -> List[Incompatibility] """ Returns incompatibilities that encapsulate a given package's dependencies, or that it can't be safely selected. If multiple subsequent versions of this package have the same dependencies, this will return incompatibilities that reflect that. It won't return incompatibilities that have already been returned by a previous call to _incompatibilities_for(). """ if package.is_root(): dependencies = package.all_requires else: dependencies = package.requires if not self._package.python_constraint.allows_any( package.python_constraint): return [ Incompatibility( [Term(package.to_dependency(), True)], PythonCause(package.python_versions, self._package.python_versions), ) ] if not self._package.platform_constraint.matches( package.platform_constraint): return [ Incompatibility( [Term(package.to_dependency(), True)], PlatformCause(package.platform), ) ] dependencies = [ dep for dep in dependencies if dep.name not in self.UNSAFE_PACKAGES and self._package. python_constraint.allows_any(dep.python_constraint) and self._package.platform_constraint.matches(dep.platform_constraint) ] return [ Incompatibility( [Term(package.to_dependency(), True), Term(dep, False)], DependencyCause(), ) for dep in dependencies ]
def incompatibilities_for( self, package): # type: (Package) -> List[Incompatibility] """ Returns incompatibilities that encapsulate a given package's dependencies, or that it can't be safely selected. If multiple subsequent versions of this package have the same dependencies, this will return incompatibilities that reflect that. It won't return incompatibilities that have already been returned by a previous call to _incompatibilities_for(). """ if package.source_type in ['git', 'file', 'directory']: dependencies = package.requires elif package.is_root(): dependencies = package.all_requires else: dependencies = self._dependencies_for(package) if not self._package.python_constraint.allows_any( package.python_constraint): return [ Incompatibility([Term(package.to_dependency(), True)], PythonCause(package.python_versions)) ] if not self._package.platform_constraint.matches( package.platform_constraint): return [ Incompatibility([Term(package.to_dependency(), True)], PlatformCause(package.platform)) ] return [ Incompatibility( [Term(package.to_dependency(), True), Term(dep, False)], DependencyCause()) for dep in dependencies ]