from distutils.core import setup from distutils.extension import Extension from Pyrex.Distutils import build_ext import os ''' Note that libxml2 is linked by using xml2 as the library name. The include path needs to be able to find libxml2 and the lib path needs to be able to find libxml2. ''' extensions = [ Extension("vlibxml2_mod", ["src/extensions/vlibxml2_mod.pyx"], libraries = ['xml2'], include_dirs = ['/usr/include', '/usr/include/libxml2',], library_dirs = ['/usr/lib'],) ] # We have to snoop for file types that distutils doesn't copy correctly when # doing a non-build-in-place. EXTS = ['.conf', '.css', '.dtd', '.gif', '.jpg', '.html', '.js', '.mo', '.png', '.pt', '.stx', '.ref', '.txt', '.xml', '.zcml', '.mar', '.in', '.sample', ] class Finder(object): def __init__(self, exts, prefix): self._files = [] self._pkgs = {} self._exts = exts # We're finding packages in lib/python in the source dir, but we're # copying them directly under build/lib.. So we need to lop off # the prefix when calculating the package names from the file names. self._plen = len(prefix) def visit(self, ignore, dir, files): for file in files: # First see if this is one of the packages we want to add, or if # we're really skipping this package. if '__init__.py' in files: aspkg = dir[self._plen:].replace(os.sep, '.') self._pkgs[aspkg] = True # Add any extra files we're interested in base, ext = os.path.splitext(file) if ext in self._exts: self._files.append(os.path.join(dir, file)) def copy_files(self, cmd, outputbase): for file in self._files: dest = os.path.join(outputbase, file[self._plen:]) # Make sure the destination directory exists dir = os.path.dirname(dest) if not os.path.exists(dir): dir_util.mkpath(dir) cmd.copy_file(file, dest) def getPackages(self): return self._pkgs.keys() def getModules(): import os basedir = 'src/' finder = Finder(EXTS, basedir) os.path.walk(basedir, finder.visit, None) packages = finder.getPackages() print packages return packages os.system("rm -rf MANIFEST") setup( name = 'lxml', package_dir = {'': 'src',}, # the package directory packages = getModules(), ext_modules=extensions, cmdclass = {'build_ext': build_ext}, version='0.1.177', )