#NEWLINE# def find( self , requirement , meta_extras = None , prereleases = False ) : #NEWLINE# #INDENT# "\n        Find a distribution and all distributions it depends on.\n\n        :param requirement: The requirement specifying the distribution to\n                            find, or a Distribution instance.\n        :param meta_extras: A list of meta extras such as :test:, :build: and\n                            so on.\n        :param prereleases: If ``True``, allow pre-release versions to be\n                            returned - otherwise, don't return prereleases\n                            unless they're all that's available.\n\n        Return a set of :class:`Distribution` instances and a set of\n        problems.\n\n        The distributions returned should be such that they have the\n        :attr:`required` attribute set to ``True`` if they were\n        from the ``requirement`` passed to ``find()``, and they have the\n        :attr:`build_time_dependency` attribute set to ``True`` unless they\n        are post-installation dependencies of the ``requirement``.\n\n        The problems should be a tuple consisting of the string\n        ``'unsatisfied'`` and the requirement which couldn't be satisfied\n        by any distribution known to the locator.\n        " #NEWLINE# self . provided = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# self . dists = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# self . dists_by_name = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# self . reqts = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# meta_extras = set ( ( meta_extras or [ ] ) ) #NEWLINE# if ( ':*:' in meta_extras ) : #NEWLINE# #INDENT# meta_extras . remove ( ':*:' ) #NEWLINE# meta_extras |= set ( [ ':test:' , ':build:' , ':dev:' ] ) #NEWLINE# #UNINDENT# if isinstance ( requirement , Distribution ) : #NEWLINE# #INDENT# dist = odist = requirement #NEWLINE# logger . debug ( 'passed %s as requirement' , odist ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# dist = odist = self . locator . locate ( requirement , prereleases = prereleases ) #NEWLINE# if ( dist is None ) : #NEWLINE# #INDENT# raise DistlibException ( ( 'Unable to locate %r' % requirement ) ) #NEWLINE# #UNINDENT# logger . debug ( 'located %s' , odist ) #NEWLINE# #UNINDENT# dist . requested = True #NEWLINE# problems = set ( ) #NEWLINE# todo = set ( [ dist ] ) #NEWLINE# install_dists = set ( [ odist ] ) #NEWLINE# while todo : #NEWLINE# #INDENT# dist = todo . pop ( ) #NEWLINE# name = dist . key #NEWLINE# if ( name not in self . dists_by_name ) : #NEWLINE# #INDENT# self . add_distribution ( dist ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# other = self . dists_by_name [ name ] #NEWLINE# if ( other != dist ) : #NEWLINE# #INDENT# self . try_to_replace ( dist , other , problems ) #NEWLINE# #UNINDENT# #UNINDENT# ireqts = ( dist . run_requires | dist . meta_requires ) #NEWLINE# sreqts = dist . build_requires #NEWLINE# ereqts = set ( ) #NEWLINE# if ( dist in install_dists ) : #NEWLINE# #INDENT# for key in ( 'test' , 'build' , 'dev' ) : #NEWLINE# #INDENT# e = ( ':%s:' % key ) #NEWLINE# if ( e in meta_extras ) : #NEWLINE# #INDENT# ereqts |= getattr ( dist , ( '%s_requires' % key ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# all_reqts = ( ( ireqts | sreqts ) | ereqts ) #NEWLINE# for r in all_reqts : #NEWLINE# #INDENT# providers = self . find_providers ( r ) #NEWLINE# if ( not providers ) : #NEWLINE# #INDENT# logger . debug ( 'No providers found for %r' , r ) #NEWLINE# provider = self . locator . locate ( r , prereleases = prereleases ) #NEWLINE# if ( ( provider is None ) and ( not prereleases ) ) : #NEWLINE# #INDENT# provider = self . locator . locate ( r , prereleases = True ) #NEWLINE# #UNINDENT# if ( provider is None ) : #NEWLINE# #INDENT# logger . debug ( 'Cannot satisfy %r' , r ) #NEWLINE# problems . add ( ( 'unsatisfied' , r ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ( n , v ) = ( provider . key , provider . version ) #NEWLINE# if ( ( n , v ) not in self . dists ) : #NEWLINE# #INDENT# todo . add ( provider ) #NEWLINE# #UNINDENT# providers . add ( provider ) #NEWLINE# if ( ( r in ireqts ) and ( dist in install_dists ) ) : #NEWLINE# #INDENT# install_dists . add ( provider ) #NEWLINE# logger . debug ( 'Adding %s to install_dists' , provider . name_and_version ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# for p in providers : #NEWLINE# #INDENT# name = p . key #NEWLINE# if ( name not in self . dists_by_name ) : #NEWLINE# #INDENT# self . reqts . setdefault ( p , set ( ) ) . add ( r ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# other = self . dists_by_name [ name ] #NEWLINE# if ( other != p ) : #NEWLINE# #INDENT# self . try_to_replace ( p , other , problems ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# dists = set ( self . dists . values ( ) ) #NEWLINE# for dist in dists : #NEWLINE# #INDENT# dist . build_time_dependency = ( dist not in install_dists ) #NEWLINE# if dist . build_time_dependency : #NEWLINE# #INDENT# logger . debug ( '%s is a build-time dependency only.' , dist . name_and_version ) #NEWLINE# #UNINDENT# #UNINDENT# logger . debug ( 'find done for %s' , odist ) #NEWLINE# return ( dists , problems )