From aee8acbec672a918bb8733159654f57a0c3ab8e2 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Wed, 1 Oct 2014 23:22:53 +0200 Subject: [PATCH] distutils -> setuptools --- MANIFEST.in | 6 ++-- setup.py | 84 +++++++++-------------------------------------------- 2 files changed, 16 insertions(+), 74 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 52d3398f3..bd59f0032 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,3 @@ -include README.mkd +include LICENSE README.mkd recursive-include test * -recursive-include netlib * -recursive-exclude * *.pyc *.pyo -prune */__pycache__ +recursive-exclude * *.pyc *.pyo *.swo *.swp \ No newline at end of file diff --git a/setup.py b/setup.py index d144855fe..ad3073fc6 100644 --- a/setup.py +++ b/setup.py @@ -1,85 +1,25 @@ -from distutils.core import setup -import fnmatch, os.path +from setuptools import setup, find_packages +from codecs import open +import os from netlib import version +# Based on https://github.com/pypa/sampleproject/blob/master/setup.py +# and https://python-packaging-user-guide.readthedocs.org/ -def _fnmatch(name, patternList): - for i in patternList: - if fnmatch.fnmatch(name, i): - return True - return False +here = os.path.abspath(os.path.dirname(__file__)) - -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 - - -with open("README.mkd", "rb") as f: +with open(os.path.join(here, 'README.mkd'), encoding='utf-8') as f: long_description = f.read() -packages, package_data = findPackages("netlib") setup( name="netlib", version=version.VERSION, description="A collection of network utilities used by pathod and mitmproxy.", long_description=long_description, + url="http://github.com/mitmproxy/netlib", author="Aldo Cortesi", author_email="aldo@corte.si", - url="http://github.com/mitmproxy/netlib", - packages=packages, - package_data=package_data, + license="MIT", classifiers=[ "License :: OSI Approved :: MIT License", "Development Status :: 3 - Alpha", @@ -92,6 +32,10 @@ setup( "Topic :: Software Development :: Testing", "Topic :: Software Development :: Testing :: Traffic Generation", ], + + packages=find_packages(), + include_package_data=True, + install_requires=[ "pyasn1>=0.1.7", "pyOpenSSL>=0.14", @@ -106,4 +50,4 @@ setup( "pathod>=0.%s" % version.MINORVERSION ] } -) +) \ No newline at end of file