summaryrefslogtreecommitdiff
path: root/setuptools
diff options
context:
space:
mode:
authorPJ Eby <distutils-sig@python.org>2005-07-25 03:12:51 +0000
committerPJ Eby <distutils-sig@python.org>2005-07-25 03:12:51 +0000
commit54bb8e4003534a9af54028ef719eda5ba6088bac (patch)
treebdae8c0810e7a1a4ecf7e93669cbba45f0de9fcb /setuptools
parent1c40632b88d76aea178e751483645ec3d32c81d9 (diff)
downloadpython-setuptools-git-54bb8e4003534a9af54028ef719eda5ba6088bac.tar.gz
Misc. bug fixes and doc additions. Add 'iter_entry_points()' API.
--HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041153
Diffstat (limited to 'setuptools')
-rw-r--r--setuptools/dist.py20
-rw-r--r--setuptools/tests/test_resources.py12
2 files changed, 16 insertions, 16 deletions
diff --git a/setuptools/dist.py b/setuptools/dist.py
index a603ade0..40234b4e 100644
--- a/setuptools/dist.py
+++ b/setuptools/dist.py
@@ -16,20 +16,17 @@ def get_command_class(self, command):
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
+ for ep in pkg_resources.iter_entry_points('distutils.commands',command):
+ self.cmdclass[command] = cmdclass = ep.load()
+ 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
+ for ep in pkg_resources.iter_entry_points('distutils.commands'):
+ if ep.name not in self.cmdclass:
+ cmdclass = ep.load(False) # don't require extras, we're not running
+ self.cmdclass[ep.name] = cmdclass
return _old_print_commands(self)
for meth in 'print_commands', 'get_command_class':
@@ -39,6 +36,9 @@ for meth in 'print_commands', 'get_command_class':
sequence = tuple, list
+
+
+
class Distribution(_Distribution):
"""Distribution with support for features, tests, and package data
diff --git a/setuptools/tests/test_resources.py b/setuptools/tests/test_resources.py
index 5392e59f..865065c2 100644
--- a/setuptools/tests/test_resources.py
+++ b/setuptools/tests/test_resources.py
@@ -216,16 +216,20 @@ class EntryPointTests(TestCase):
"foo = setuptools.tests.test_resources:EntryPointTests [x]"
)
+ def setUp(self):
+ self.dist = Distribution.from_filename(
+ "FooPkg-1.2-py2.4.egg", metadata=Metadata(('requires.txt','[x]')))
+
def testBasics(self):
ep = EntryPoint(
"foo", "setuptools.tests.test_resources", ["EntryPointTests"],
- ["x"]
+ ["x"], self.dist
)
self.assertfields(ep)
def testParse(self):
s = "foo = setuptools.tests.test_resources:EntryPointTests [x]"
- ep = EntryPoint.parse(s)
+ ep = EntryPoint.parse(s, self.dist)
self.assertfields(ep)
ep = EntryPoint.parse("bar baz= spammity[PING]")
@@ -240,10 +244,6 @@ class EntryPointTests(TestCase):
self.assertEqual(ep.attrs, ("foo",))
self.assertEqual(ep.extras, ())
-
-
-
-
def testRejects(self):
for ep in [
"foo", "x=1=2", "x=a:b:c", "q=x/na", "fez=pish:tush-z", "x=f[a]>2",