/usr/share/pyshared/epsilon/setuphelper.py is in python-epsilon 0.6.0+r2713-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | # -*- test-case-name: epsilon.test.test_setuphelper -*-
# For great justice, take off every zig.
import sys, os, pprint, traceback
from distutils.core import setup
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__)
pprint.pprint(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('.') and p != 'build']
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,
}
print 'Automatically determined setup() args:'
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
|