[Python-checkins] python/nondist/sandbox/setuptools/setuptools dist.py, 1.15, 1.16
pje@users.sourceforge.net
pje at users.sourceforge.net
Mon Jul 25 00:47:08 CEST 2005
- Previous message: [Python-checkins] python/nondist/sandbox/setuptools pkg_resources.py, 1.52, 1.53 setup.py, 1.32, 1.33 setuptools.txt, 1.22, 1.23
- Next message: [Python-checkins] python/nondist/sandbox/setuptools/setuptools/command __init__.py, 1.6, 1.7 egg_info.py, 1.8, 1.9
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/python/python/nondist/sandbox/setuptools/setuptools
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6325/setuptools
Modified Files:
dist.py
Log Message:
Implement "entry points" for dynamic discovery of drivers and plugins.
Change setuptools to discover setup commands using an entry point group
called "distutils.commands". Thanks to Ian Bicking for the suggestion that
led to designing this super-cool feature.
Index: dist.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/dist.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- dist.py 24 Jul 2005 17:59:26 -0000 1.15
+++ dist.py 24 Jul 2005 22:47:05 -0000 1.16
@@ -11,6 +11,32 @@
from distutils.errors import DistutilsSetupError
import setuptools, pkg_resources
+def get_command_class(self, command):
+ """Pluggable version of get_command_class()"""
+ if command in self.cmdclass:
+ return self.cmdclass[command]
+
+ for dist in pkg_resources.working_set:
+ if dist.get_entry_info('distutils.commands',command):
+ cmdclass = dist.load_entry_point('distutils.commands',command)
+ self.cmdclass[command] = cmdclass
+ return cmdclass
+ else:
+ return _old_get_command_class(self, command)
+
+def print_commands(self):
+ for dist in pkg_resources.working_set:
+ for cmd,ep in dist.get_entry_map('distutils.commands').items():
+ if cmd not in self.cmdclass:
+ cmdclass = ep.load() # don't require extras, we're not running
+ self.cmdclass[cmd] = cmdclass
+ return _old_print_commands(self)
+
+for meth in 'print_commands', 'get_command_class':
+ if getattr(_Distribution,meth).im_func.func_globals is not globals():
+ globals()['_old_'+meth] = getattr(_Distribution,meth)
+ setattr(_Distribution, meth, globals()[meth])
+
sequence = tuple, list
class Distribution(_Distribution):
@@ -80,6 +106,21 @@
distribution for the included and excluded features.
"""
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
def __init__ (self, attrs=None):
have_package_data = hasattr(self, "package_data")
if not have_package_data:
@@ -93,15 +134,9 @@
self.zip_safe = None
self.namespace_packages = None
self.eager_resources = None
+ self.entry_points = None
_Distribution.__init__(self,attrs)
- if not have_package_data:
- from setuptools.command.build_py import build_py
- self.cmdclass.setdefault('build_py',build_py)
- self.cmdclass.setdefault('build_ext',build_ext)
- self.cmdclass.setdefault('install',install)
- self.cmdclass.setdefault('install_lib',install_lib)
- self.cmdclass.setdefault('sdist',sdist)
def parse_command_line(self):
"""Process features after parsing command line options"""
@@ -121,6 +156,12 @@
+
+
+
+
+
+
def finalize_options(self):
_Distribution.finalize_options(self)
@@ -171,6 +212,12 @@
"namespace package %r" % nsp
)
+ if self.entry_points is not None:
+ try:
+ pkg_resources.EntryPoint.parse_map(self.entry_points)
+ except ValueError, e:
+ raise DistutilsSetupError(e)
+
def _set_global_opts_from_features(self):
"""Add --with-X/--without-X options based on optional features"""
@@ -197,12 +244,6 @@
-
-
-
-
-
-
def _finalize_features(self):
"""Add/remove features and resolve dependencies between them"""
@@ -420,7 +461,7 @@
src,alias = aliases[command]
del aliases[command] # ensure each alias can expand only once!
import shlex
- args[:1] = shlex.split(alias,True)
+ args[:1] = shlex.split(alias,True)
command = args[0]
nargs = _Distribution._parse_command_opts(self, parser, args)
- Previous message: [Python-checkins] python/nondist/sandbox/setuptools pkg_resources.py, 1.52, 1.53 setup.py, 1.32, 1.33 setuptools.txt, 1.22, 1.23
- Next message: [Python-checkins] python/nondist/sandbox/setuptools/setuptools/command __init__.py, 1.6, 1.7 egg_info.py, 1.8, 1.9
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Python-checkins
mailing list