#NEWLINE# def findPackages( path , dataExclude = [ ] ) : #NEWLINE# #INDENT# '\n        Recursively find all packages and data directories rooted at path. Note\n        that only data _directories_ and their contents are returned -\n        non-Python files at module scope are not, and should be manually\n        included.\n        \n        dataExclude is a list of fnmatch-compatible expressions for files and\n        directories that should not be included in pakcage_data.\n\n        Returns a (packages, package_data) tuple, ready to be passed to the\n        corresponding distutils.core.setup arguments.\n    ' #NEWLINE# packages = [ ] #NEWLINE# datadirs = [ ] #NEWLINE# for ( root , dirs , files ) in os . walk ( path , topdown = True ) : #NEWLINE# #INDENT# if ( '__init__.py' in files ) : #NEWLINE# #INDENT# p = _splitAll ( root ) #NEWLINE# packages . append ( '.' . join ( p ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# dirs [ : ] = [ ] #NEWLINE# if packages : #NEWLINE# #INDENT# datadirs . append ( root ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# package_data = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for i in datadirs : #NEWLINE# #INDENT# if ( not _fnmatch ( i , dataExclude ) ) : #NEWLINE# #INDENT# parts = _splitAll ( i ) #NEWLINE# module = '.' . join ( parts [ : ( - 1 ) ] ) #NEWLINE# acc = package_data . get ( module , [ ] ) #NEWLINE# for ( root , dirs , files ) in os . walk ( packages , topdown = True ) : #NEWLINE# #INDENT# sub = os . path . join ( * _splitAll ( root ) [ 1 : ] ) #NEWLINE# if ( not _fnmatch ( sub , dataExclude ) ) : #NEWLINE# #INDENT# for fname in files : #NEWLINE# #INDENT# path = os . path . join ( sub , fname ) #NEWLINE# if ( not _fnmatch ( path , dataExclude ) ) : #NEWLINE# #INDENT# acc . append ( path ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# dirs [ : ] = [ ] #NEWLINE# #UNINDENT# #UNINDENT# package_data [ module ] = acc #NEWLINE# #UNINDENT# #UNINDENT# return ( packages , package_data )