--- setup.py.orig	2005-10-17 09:07:03.000000000 +1000
+++ setup.py	2022-10-20 23:51:20.000000000 +1100
@@ -42,7 +42,7 @@
             dirs = [ '/usr', sys.prefix ] + glob.glob('/opt/libpcap*') + \
                    glob.glob('../libpcap*') + glob.glob('../wpdpack*')
         for d in dirs:
-            for sd in ('include', 'include/pcap', ''):
+            for sd in ('include/pcap', 'include', ''):
                 incdirs = [ os.path.join(d, sd) ]
                 if os.path.exists(os.path.join(d, sd, 'pcap.h')):
                     cfg['include_dirs'] = [ os.path.join(d, sd) ]
@@ -75,9 +75,9 @@
             print "removing '%s'" % pcap_cache
             os.unlink(pcap_cache)
 
-if len(sys.argv) > 1 and sys.argv[1] == 'build':
+if (len(sys.argv) > 1 and ('build' in sys.argv or 'install' in sys.argv)) or "SETUP_PY_LOAD_PCAP_CONFIG" in os.environ:
     try:
-        pcap_config = cPickle.load(open(pcap_cache))
+        pcap_config = cPickle.load(open(pcap_cache, 'rb'))
     except IOError:
         print >>sys.stderr, 'run "%s config" first!' % sys.argv[0]
         sys.exit(1)
