mitmproxy/setup.py

110 lines
3.2 KiB
Python
Raw Normal View History

2012-06-23 01:49:57 +00:00
from distutils.core import setup
import fnmatch, os.path
from netlib import version
2014-09-08 16:58:07 +00:00
2012-06-23 01:49:57 +00:00
def _fnmatch(name, patternList):
for i in patternList:
if fnmatch.fnmatch(name, i):
return True
return False
def _splitAll(path):
parts = []
h = path
while 1:
if not h:
break
h, t = os.path.split(h)
parts.append(t)
parts.reverse()
return parts
def findPackages(path, dataExclude=[]):
"""
Recursively find all packages and data directories rooted at path. Note
that only data _directories_ and their contents are returned -
non-Python files at module scope are not, and should be manually
included.
dataExclude is a list of fnmatch-compatible expressions for files and
directories that should not be included in pakcage_data.
Returns a (packages, package_data) tuple, ready to be passed to the
corresponding distutils.core.setup arguments.
"""
packages = []
datadirs = []
for root, dirs, files in os.walk(path, topdown=True):
if "__init__.py" in files:
p = _splitAll(root)
packages.append(".".join(p))
else:
dirs[:] = []
if packages:
datadirs.append(root)
# Now we recurse into the data directories
package_data = {}
for i in datadirs:
if not _fnmatch(i, dataExclude):
parts = _splitAll(i)
module = ".".join(parts[:-1])
acc = package_data.get(module, [])
for root, dirs, files in os.walk(i, topdown=True):
sub = os.path.join(*_splitAll(root)[1:])
if not _fnmatch(sub, dataExclude):
for fname in files:
path = os.path.join(sub, fname)
if not _fnmatch(path, dataExclude):
acc.append(path)
else:
dirs[:] = []
package_data[module] = acc
return packages, package_data
2014-09-08 16:58:07 +00:00
with open("README.mkd", "rb") as f:
long_description = f.read()
packages, package_data = findPackages("netlib")
2012-06-23 01:49:57 +00:00
setup(
2014-09-08 16:58:07 +00:00
name="netlib",
version=version.VERSION,
description="A collection of network utilities used by pathod and mitmproxy.",
long_description=long_description,
author="Aldo Cortesi",
author_email="aldo@corte.si",
url="http://github.com/mitmproxy/netlib",
packages=packages,
package_data=package_data,
classifiers=[
"License :: OSI Approved :: MIT License",
"Development Status :: 3 - Alpha",
"Operating System :: POSIX",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Topic :: Internet",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: HTTP Servers",
"Topic :: Software Development :: Testing",
"Topic :: Software Development :: Testing :: Traffic Generation",
],
install_requires=[
"pyasn1>=0.1.7",
"pyOpenSSL>=0.14",
"passlib>=1.6.2"
],
extras_require={
'dev': [
"mock>=1.0.1",
"nose>=1.3.0",
"nose-cov>=1.6",
"coveralls>=0.4.1",
"pathod>=0.10"
]
}
2012-06-23 01:49:57 +00:00
)