--- setup.py.orig	2013-04-19 15:36:20.000000000 +0800
+++ setup.py	2014-01-09 17:29:08.000000000 +0800
@@ -1,4 +1,4 @@
-#!/usr/bin/python -u
+#!/usr/bin/env python -u
 #
 # Setup script for libxml2 and libxslt if found
 #
@@ -56,18 +56,14 @@
 # - iconv.h 
 # - libxslt/xsltconfig.h
 includes_dir = [
-"/usr/include",
-"/usr/local/include",
-"/opt/include",
-os.path.join(ROOT,'include'),
-HOME
-];
+"@PREFIX@/include"
+]
 
 xml_includes=""
 for dir in includes_dir:
     if not missing(dir + "/libxml2/libxml/tree.h"):
         xml_includes=dir + "/libxml2"
-	break;
+    break
 
 if xml_includes == "":
     print("failed to find headers for libxml2: update includes_dir")
@@ -77,7 +73,7 @@
 for dir in includes_dir:
     if not missing(dir + "/iconv.h"):
         iconv_includes=dir
-	break;
+    break
 
 if iconv_includes == "":
     print("failed to find headers for libiconv: update includes_dir")
@@ -85,27 +81,27 @@
 
 # those are added in the linker search path for libraries
 libdirs = [
-os.path.join(ROOT,'lib'),
+"@PREFIX@/lib"
 ]
 
 xml_files = ["libxml2-api.xml", "libxml2-python-api.xml",
-             "libxml.c", "libxml.py", "libxml_wrap.h", "types.c",
-	     "xmlgenerator.py", "README", "TODO", "drv_libxml2.py"]
+            "libxml.c", "libxml.py", "libxml_wrap.h", "types.c",
+            "xmlgenerator.py", "README", "TODO", "drv_libxml2.py"]
 
 xslt_files = ["libxslt-api.xml", "libxslt-python-api.xml",
-             "libxslt.c", "libxsl.py", "libxslt_wrap.h",
-	     "xsltgenerator.py"]
+            "libxslt.c", "libxsl.py", "libxslt_wrap.h",
+            "xsltgenerator.py"]
 
 if missing("libxml2-py.c") or missing("libxml2.py"):
     try:
-	try:
-	    import xmlgenerator
-	except:
-	    import generator
+        try:
+            import xmlgenerator
+        except:
+            import generator
     except:
-	print("failed to find and generate stubs for libxml2, aborting ...")
-	print(sys.exc_info()[0], sys.exc_info()[1])
-	sys.exit(1)
+        print("failed to find and generate stubs for libxml2, aborting ...")
+        print(sys.exc_info()[0], sys.exc_info()[1])
+        sys.exit(1)
 
     head = open("libxml.py", "r")
     generated = open("libxml2class.py", "r")
@@ -116,49 +112,23 @@
         else:
             result.write(line)
     for line in generated.readlines():
-	result.write(line)
+        result.write(line)
     head.close()
     generated.close()
     result.close()
 
 with_xslt=0
-if missing("libxslt-py.c") or missing("libxslt.py"):
-    if missing("xsltgenerator.py") or missing("libxslt-api.xml"):
-        print("libxslt stub generator not found, libxslt not built")
-    else:
-	try:
-	    import xsltgenerator
-	except:
-	    print("failed to generate stubs for libxslt, aborting ...")
-	    print(sys.exc_info()[0], sys.exc_info()[1])
-	else:
-	    head = open("libxsl.py", "r")
-	    generated = open("libxsltclass.py", "r")
-	    result = open("libxslt.py", "w")
-	    for line in head.readlines():
-                if WITHDLLS:
-                    result.write(altImport(line))
-                else:
-                    result.write(line)
-	    for line in generated.readlines():
-		result.write(line)
-	    head.close()
-	    generated.close()
-	    result.close()
-	    with_xslt=1
-else:
-    with_xslt=1
 
 if with_xslt == 1:
     xslt_includes=""
     for dir in includes_dir:
-	if not missing(dir + "/libxslt/xsltconfig.h"):
-	    xslt_includes=dir + "/libxslt"
-	    break;
+        if not missing(dir + "/libxslt/xsltconfig.h"):
+            xslt_includes=dir + "/libxslt"
+            break
 
     if xslt_includes == "":
-	print("failed to find headers for libxslt: update includes_dir")
-	with_xslt = 0
+        print("failed to find headers for libxslt: update includes_dir")
+        with_xslt = 0
 
 
 descr = "libxml2 package"
@@ -194,22 +164,21 @@
 
 
 extens=[Extension('libxml2mod', c_files, include_dirs=includes,
-                  library_dirs=libdirs, 
-                  libraries=libs, define_macros=macros)] 
+                library_dirs=libdirs, 
+                libraries=libs, define_macros=macros)] 
 if with_xslt == 1:
     extens.append(Extension('libxsltmod', xslt_c_files, include_dirs=includes,
-			    library_dirs=libdirs, 
-                            libraries=libs, define_macros=macros))
+                library_dirs=libdirs, 
+                libraries=libs, define_macros=macros))
 
 if missing("MANIFEST"):
-
     manifest = open("MANIFEST", "w")
     manifest.write("setup.py\n")
     for file in xml_files:
         manifest.write(file + "\n")
     if with_xslt == 1:
-	for file in xslt_files:
-	    manifest.write(file + "\n")
+        for file in xslt_files:
+            manifest.write(file + "\n")
     manifest.close()
 
 if WITHDLLS:
