~ubuntu-branches/ubuntu/quantal/mitmproxy/quantal

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: Package Import Robot
  • Author(s): Sebastien Delafond
  • Date: 2012-02-13 11:46:52 UTC
  • Revision ID: package-import@ubuntu.com-20120213114652-ug49uqn1be6w80h9
Tags: upstream-0.6
ImportĀ upstreamĀ versionĀ 0.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from distutils.core import setup
 
2
import fnmatch, os.path
 
3
from libmproxy import version
 
4
 
 
5
def _fnmatch(name, patternList):
 
6
    for i in patternList:
 
7
        if fnmatch.fnmatch(name, i):
 
8
            return True
 
9
    return False
 
10
 
 
11
 
 
12
def _splitAll(path):
 
13
    parts = []
 
14
    h = path
 
15
    while 1:
 
16
        if not h:
 
17
            break
 
18
        h, t = os.path.split(h)
 
19
        parts.append(t)
 
20
    parts.reverse()
 
21
    return parts
 
22
 
 
23
 
 
24
def findPackages(path, dataExclude=[]):
 
25
    """
 
26
        Recursively find all packages and data directories rooted at path. Note
 
27
        that only data _directories_ and their contents are returned -
 
28
        non-Python files at module scope are not, and should be manually
 
29
        included.
 
30
        
 
31
        dataExclude is a list of fnmatch-compatible expressions for files and
 
32
        directories that should not be included in pakcage_data.
 
33
 
 
34
        Returns a (packages, package_data) tuple, ready to be passed to the
 
35
        corresponding distutils.core.setup arguments.
 
36
    """
 
37
    packages = []
 
38
    datadirs = []
 
39
    for root, dirs, files in os.walk(path, topdown=True):
 
40
        if "__init__.py" in files:
 
41
            p = _splitAll(root)
 
42
            packages.append(".".join(p))
 
43
        else:
 
44
            dirs[:] = []
 
45
            if packages:
 
46
                datadirs.append(root)
 
47
 
 
48
    # Now we recurse into the data directories
 
49
    package_data = {}
 
50
    for i in datadirs:
 
51
        if not _fnmatch(i, dataExclude):
 
52
            parts = _splitAll(i)
 
53
            module = ".".join(parts[:-1])
 
54
            acc = package_data.get(module, [])
 
55
            for root, dirs, files in os.walk(i, topdown=True):
 
56
                sub = os.path.join(*_splitAll(root)[1:])
 
57
                if not _fnmatch(sub, dataExclude):
 
58
                    for fname in files:
 
59
                        path = os.path.join(sub, fname)
 
60
                        if not _fnmatch(path, dataExclude):
 
61
                            acc.append(path)
 
62
                else:
 
63
                    dirs[:] = []
 
64
            package_data[module] = acc
 
65
    return packages, package_data
 
66
 
 
67
 
 
68
 
 
69
 
 
70
long_description = file("README.mkd").read()
 
71
packages, package_data = findPackages("libmproxy")
 
72
setup(
 
73
        name = "mitmproxy",
 
74
        version = version.VERSION,
 
75
        description = "An interactive SSL-capable intercepting HTTP proxy for penetration testers and software developers.",
 
76
        long_description = long_description,
 
77
        author = "Aldo Cortesi",
 
78
        author_email = "aldo@corte.si",
 
79
        url = "http://mitmproxy.org",
 
80
        packages = packages,
 
81
        package_data = package_data,
 
82
        scripts = ["mitmproxy", "mitmdump"],
 
83
        classifiers = [
 
84
            "Development Status :: 4 - Beta",
 
85
            "Programming Language :: Python",
 
86
            "Topic :: Security",
 
87
            "Topic :: Internet :: WWW/HTTP",
 
88
            "Topic :: Software Development :: Testing"
 
89
        ]
 
90
)