import setuptools

# MONKEYPATCH: Stop egg_info from stupidly traversing the entire
# development directory.
import setuptools.command.egg_info
import os
class FileList(setuptools.command.egg_info.FileList):
    def findall(self, dir=os.curdir):
        """Find all files under 'dir' and return the list of full filenames
        (relative to 'dir').
        """
        from stat import ST_MODE, S_ISREG, S_ISDIR, S_ISLNK

        list = []
        stack = [dir]
        pop = stack.pop
        push = stack.append

        while stack:
            dir = pop()
            # BEGIN MODIFICATION
            if dir in ("tests", "srv", ".git"):
                continue
            # END MODIFICATION
            names = os.listdir(dir)

            for name in names:
                if dir != os.curdir:        # avoid the dreaded "./" syndrome
                    fullname = os.path.join(dir, name)
                else:
                    fullname = name

                # Avoid excess stat calls -- just one will do, thank you!
                stat = os.stat(fullname)
                mode = stat[ST_MODE]
                if S_ISREG(mode):
                    list.append(fullname)
                elif S_ISDIR(mode) and not S_ISLNK(mode):
                    push(fullname)
        self.allfiles = list
setuptools.command.egg_info.FileList = FileList
# END MONKEYPATCH

setuptools.setup(
    name = 'wizard',
    version = '0.1.dev',
    author = 'The Wizard Team',
    author_email = 'scripts-team@mit.edu',
    description = ('A next-generation autoinstall management system'),
    license = 'MIT',
    url = 'http://scripts.mit.edu/wizard',
    packages = setuptools.find_packages(exclude=["tests", "plugins"]),
    install_requires = ['decorator'], # versions?
    keywords = "autoinstall webapp deploy",
)
