<s> from distutils . core import setup , Extension <EOL> from distutils . command import config , clean <EOL> import cPickle , glob , os , sys <EOL> pcap_config = { } <EOL> pcap_cache = '<STR_LIT>' <EOL> class config_pcap ( config . config ) : <EOL> description = '<STR_LIT>' <EOL> user_options = [ ( '<STR_LIT>' , None , <EOL> '<STR_LIT>' ) ] <EOL> def initialize_options ( self ) : <EOL> config . config . initialize_options ( self ) <EOL> self . dump_source = <NUM_LIT:0> <EOL> self . with_pcap = None <EOL> def _write_config_h ( self , cfg ) : <EOL> d = { } <EOL> if os . path . exists ( os . path . join ( cfg [ '<STR_LIT>' ] [ <NUM_LIT:0> ] , '<STR_LIT>' ) ) : <EOL> d [ '<STR_LIT>' ] = <NUM_LIT:1> <EOL> buf = open ( os . path . join ( cfg [ '<STR_LIT>' ] [ <NUM_LIT:0> ] , '<STR_LIT>' ) ) . read ( ) <EOL> if buf . find ( '<STR_LIT>' ) != - <NUM_LIT:1> : <EOL> d [ '<STR_LIT>' ] = <NUM_LIT:1> <EOL> if buf . find ( '<STR_LIT>' ) != - <NUM_LIT:1> : <EOL> d [ '<STR_LIT>' ] = <NUM_LIT:1> <EOL> if buf . find ( '<STR_LIT>' ) != - <NUM_LIT:1> : <EOL> d [ '<STR_LIT>' ] = <NUM_LIT:1> <EOL> f = open ( '<STR_LIT>' , '<STR_LIT:w>' ) <EOL> for k , v in d . iteritems ( ) : <EOL> f . write ( '<STR_LIT>' % ( k , v ) ) <EOL> def _pcap_config ( self , dirs = [ None ] ) : <EOL> cfg = { } <EOL> if not dirs [ <NUM_LIT:0> ] : <EOL> dirs = [ '<STR_LIT>' , sys . prefix ] + glob . glob ( '<STR_LIT>' ) + glob . glob ( '<STR_LIT>' ) + glob . glob ( '<STR_LIT>' ) <EOL> for d in dirs : <EOL> for sd in ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) : <EOL> incdirs = [ os . path . join ( d , sd ) ] <EOL> if os . path . exists ( os . path . join ( d , sd , '<STR_LIT>' ) ) : <EOL> cfg [ '<STR_LIT>' ] = [ os . path . join ( d , sd ) ] <EOL> for sd in ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) : <EOL> for lib in ( ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) ) : <EOL> if os . path . exists ( os . path . join ( d , sd , lib [ <NUM_LIT:1> ] ) ) : <EOL> cfg [ '<STR_LIT>' ] = [ os . path . join ( d , sd ) ] <EOL> cfg [ '<STR_LIT>' ] = [ lib [ <NUM_LIT:0> ] ] <EOL> if lib [ <NUM_LIT:0> ] == '<STR_LIT>' : <EOL> cfg [ '<STR_LIT>' ] . append ( '<STR_LIT>' ) <EOL> cfg [ '<STR_LIT>' ] = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> print '<STR_LIT>' , cfg <EOL> self . _write_config_h ( cfg ) <EOL> return cfg <EOL> raise Exception ( "<STR_LIT>" ) <EOL> def run ( self ) : <EOL> cPickle . dump ( self . _pcap_config ( [ self . with_pcap ] ) , <EOL> open ( pcap_cache , '<STR_LIT:wb>' ) ) <EOL> self . temp_files . append ( pcap_cache ) <EOL> class clean_pcap ( clean . clean ) : <EOL> def run ( self ) : <EOL> clean . clean . run ( self ) <EOL> if self . all and os . path . exists ( pcap_cache ) : <EOL> print "<STR_LIT>" % pcap_cache <EOL> os . unlink ( pcap_cache ) <EOL> if len ( sys . argv ) > <NUM_LIT:1> and sys . argv [ <NUM_LIT:1> ] == '<STR_LIT>' : <EOL> try : <EOL> pcap_config = cPickle . load ( open ( pcap_cache ) ) <EOL> except IOError : <EOL> print >> sys . stderr , '<STR_LIT>' % sys . argv [ <NUM_LIT:0> ] <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> pcap = Extension ( name = '<STR_LIT>' , <EOL> sources = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> include_dirs = pcap_config . get ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> library_dirs = pcap_config . get ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> libraries = pcap_config . get ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> extra_compile_args = pcap_config . get ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> pcap_cmds = { '<STR_LIT>' : config_pcap , '<STR_LIT>' : clean_pcap } <EOL> setup ( name = '<STR_LIT>' , <EOL> version = '<STR_LIT>' , <EOL> author = '<STR_LIT>' , <EOL> author_email = '<STR_LIT>' , <EOL> url = '<STR_LIT>' , <EOL> description = '<STR_LIT>' , <EOL> cmdclass = pcap_cmds , <EOL> ext_modules = [ pcap ] ) </s>
