aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README12
-rw-r--r--netlib/version.py4
-rw-r--r--setup.py92
3 files changed, 106 insertions, 2 deletions
diff --git a/README b/README
index 1c86738c..958a0302 100644
--- a/README
+++ b/README
@@ -1,2 +1,10 @@
-Netlib is a collection of common utility functions, used by the pathod and
-mitmproxy projects.
+
+Netlib is a collection of network utility classes, used by pathod and mitmproxy
+projects. It differs from other projects in some fundamental respects, because
+both pathod and mitmproxy often need to violate standards. This means that
+protocols are implemented as small, well-contained and flexible functions, and
+servers are implemented to allow misbehaviour when needed.
+
+At this point, I have no plans to make netlib useful beyond mitmproxy and
+pathod. Please get in touch if you think parts of netlib might have broader
+utility.
diff --git a/netlib/version.py b/netlib/version.py
new file mode 100644
index 00000000..1c4a4b66
--- /dev/null
+++ b/netlib/version.py
@@ -0,0 +1,4 @@
+IVERSION = (0, 1)
+VERSION = ".".join(str(i) for i in IVERSION)
+NAME = "netlib"
+NAMEVERSION = NAME + " " + VERSION
diff --git a/setup.py b/setup.py
new file mode 100644
index 00000000..06ac8aea
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,92 @@
+from distutils.core import setup
+import fnmatch, os.path
+from netlib import version
+
+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
+
+
+long_description = file("README").read()
+packages, package_data = findPackages("libpathod")
+setup(
+ 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://cortesi.github.com/netlib",
+ packages = packages,
+ package_data = package_data,
+ classifiers = [
+ "License :: OSI Approved :: MIT License",
+ "Development Status :: 3 - Alpha",
+ "Operating System :: POSIX",
+ "Programming Language :: Python",
+ "Topic :: Internet",
+ "Topic :: Internet :: WWW/HTTP :: HTTP Servers",
+ "Topic :: Software Development :: Testing",
+ "Topic :: Software Development :: Testing :: Traffic Generation",
+ "Topic :: Internet :: WWW/HTTP",
+ ],
+ install_requires=["pyasn1>0.1.2", "pyopenssl>=0.12"],
+)