Anonymous avatar Anonymous committed 527be35

release 0.1.1 and cleanup setup.py

Comments (0)

Files changed (2)

 """
 
 try:
-    # Load setuptools, to build a specific source package
-    import setuptools
+    from setuptools import setup, find_packages
 except ImportError:
-    pass
-
-# For great justice, take off every zig.
-import sys, os, pprint, traceback
+    from ez_setup import use_setuptools
+    use_setuptools()
+    from setuptools import setup, find_packages
 
 import turtl
 version = turtl.__version__
 
 install_requires = ["Twisted>=8.0.1", "PyYAML>=3.0.8"]
 
-setup = setuptools.setup
-find_packages = setuptools.find_packages
-
-# Most of the following code is from Divmod Epsilon, (C) 2008 Divmod, Inc.
-# under MIT license, see http://divmod.org/trac/wiki/DivmodEpsilon
-# since I only need this to install turtl correctly with Twisted
-# Plugins I'd rather copy this few lines than actually add another
-# dependency. Also this version uses the setuptools setup() function.
-
-def pluginModules(moduleNames):
-    from twisted.python.reflect import namedAny
-    for moduleName in moduleNames:
-        try:
-            yield namedAny(moduleName)
-        except ImportError:
-            pass
-        except ValueError, ve:
-            if ve.args[0] != 'Empty module name':
-                traceback.print_exc()
-        except:
-            traceback.print_exc()
-
-def _regeneratePluginCache(pluginPackages):
-    ## print 'Regenerating cache with path: ',
-    ## pprint.pprint(sys.path)
-    from twisted import plugin
-    for pluginModule in pluginModules([
-        p + ".plugins" for p in pluginPackages]):
-        # Not just *some* zigs, mind you - *every* zig:
-        #print 'Full plugin list for %r: ' % (pluginModule.__name__)
-        list(plugin.getPlugins(plugin.IPlugin, pluginModule))
-
-def regeneratePluginCache(dist, pluginPackages):
-    if 'install' in dist.commands:
-        sys.path.insert(0, os.path.abspath(dist.command_obj['install'].install_lib))
-        _regeneratePluginCache(pluginPackages)
-
-def autosetup(**kw):
-    packages = []
-    datafiles = {}
-    pluginPackages = []
-
-    for (dirpath, dirnames, filenames) in os.walk(os.curdir):
-        dirnames[:] = [p for p in dirnames if not p.startswith('.')]
-        pkgName = dirpath[2:].replace('/', '.')
-        if '__init__.py' in filenames:
-            # The current directory is a Python package
-            packages.append(pkgName)
-        elif 'plugins' in dirnames:
-            # The current directory is for the Twisted plugin system
-            pluginPackages.append(pkgName)
-            packages.append(pkgName)
-
-    for package in packages:
-        if '.' in package:
-            continue
-        D = datafiles[package] = []
-        #print 'Files in package %r:' % (package,)
-        #pprint.pprint(os.listdir(package))
-        for (dirpath, dirnames, filenames) in os.walk(package):
-            dirnames[:] = [p for p in dirnames if not p.startswith('.')]
-            for filename in filenames:
-                if filename == 'dropin.cache':
-                    continue
-                if (os.path.splitext(filename)[1] not in ('.py', '.pyc', '.pyo')
-                    or '__init__.py' not in filenames):
-                    D.append(os.path.join(dirpath[len(package)+1:], filename))
-    autoresult = {
-        'packages': packages,
-        'package_data': datafiles,
-        }
-    #pprint.pprint(autoresult, indent=4)
-    assert 'packages' not in kw
-    assert 'package_data' not in kw
-    kw.update(autoresult)
-    distobj = setup(**kw)
-    regeneratePluginCache(distobj, pluginPackages)
-    return distobj
-
 description = """\
 Turtl is an HTTP proxy whose purpose is to throttle connections to
 specific hostnames to avoid breaking terms of usage of those API
 providers (like del.icio.us, technorati and so on).
 """
 
-autosetup(
-    name = "turtl",
-    author = "Valentino Volonghi",
-    author_email = "valentino@adroll.com",
-    url = "http://adroll.com/labs",
-    description = description,
-    license = "MIT License",
-    version=version,
-    install_requires=install_requires,
-    classifiers = [
-        'Development Status :: 4 - Beta',
-        'Environment :: Web Environment',
-        'Intended Audience :: Developers',
-        'License :: OSI Approved :: MIT License',
-        'Natural Language :: English',
-        'Programming Language :: Python',
-        'Topic :: Internet',
-    ],
-    include_package_data=True,
-    zip_safe=False
-)
+setup(package_data={'turtl': [], 'twisted': ['plugins/turtl_plugin.py']},
+      description=description,
+      license='MIT License',
+      author='Valentino Volonghi',
+      author_email='valentino@adroll.com',
+      include_package_data=True,
+      url='http://adroll.com/labs',
+      version='0.1.1',
+      zip_safe=False,
+      install_requires=['Twisted>=8.0.1', 'PyYAML>=3.0.8'],
+      packages=['turtl', 'turtl.test', 'twisted'],
+      classifiers=['Development Status :: 4 - Beta',
+                   'Environment :: Web Environment',
+                   'Intended Audience :: Developers',
+                   'License :: OSI Approved :: MIT License',
+                   'Natural Language :: English',
+                   'Programming Language :: Python',
+                   'Topic :: Internet'],
+      name='turtl')
 from twisted.internet import defer, task
 
 class _ConcurrencyPrimitive(object):
+    """
+    This code was taken from Twisted project with some minor changes.
+    Twisted is available at http://twistedmatrix.com/trac/
+    """
     _execute = defer.maybeDeferred
 
     def __init__(self):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.