summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpje <pje@571e12c6-e1fa-0310-aee7-ff1267fa46bd>2004-03-09 18:29:51 +0000
committerpje <pje@571e12c6-e1fa-0310-aee7-ff1267fa46bd>2004-03-09 18:29:51 +0000
commit097b7f1a823c7b800dbb0a624e56205fe926692e (patch)
tree5e36651a47427c7d1bdae2f2880568b0af348a71
parent671ad4f0084ed52c4881701aa7902a1fc0908c91 (diff)
downloadwsgiref-097b7f1a823c7b800dbb0a624e56205fe926692e.tar.gz
Misc. cleanups: findPackages -> find_packages, use standard paths, don't
include --with/--without options on individual commands. git-svn-id: svn://svn.eby-sarna.com/svnroot/wsgiref@239 571e12c6-e1fa-0310-aee7-ff1267fa46bd
-rw-r--r--setuptools/__init__.py31
-rw-r--r--setuptools/dist.py14
-rw-r--r--setuptools/tests/__init__.py16
3 files changed, 33 insertions, 28 deletions
diff --git a/setuptools/__init__.py b/setuptools/__init__.py
index 6fb8511..576d353 100644
--- a/setuptools/__init__.py
+++ b/setuptools/__init__.py
@@ -4,27 +4,32 @@ import distutils.core, setuptools.command
from setuptools.dist import Distribution, Feature
from setuptools.extension import Extension
from distutils.core import Command
+from distutils.util import convert_path
import os.path
__all__ = [
- 'setup', 'Distribution', 'Feature', 'Command', 'Extension', 'findPackages'
+ 'setup', 'Distribution', 'Feature', 'Command', 'Extension', 'find_packages'
]
-def findPackages(where='.', prefix='', append=None):
- """List all Python packages found within directory 'where'"""
+def find_packages(where='.'):
+ """Return a list all Python packages found within directory 'where'
+
+ 'where' should be supplied as a "cross-platform" (i.e. URL-style) path; it
+ will be converted to the appropriate local path syntax.
+ """
out = []
- if not append:
- append = out.append
-
- for name in os.listdir(where):
- fn = os.path.join(where,name)
- if (os.path.isdir(fn) and
- os.path.isfile(os.path.join(fn,'__init__.py'))
- ):
- append(prefix+name)
- findPackages(fn,prefix+name+'.',append)
+ stack=[(convert_path(where), '')]
+
+ while stack:
+ where,prefix = stack.pop(0)
+ for name in os.listdir(where):
+ fn = os.path.join(where,name)
+ if (os.path.isdir(fn) and
+ os.path.isfile(os.path.join(fn,'__init__.py'))
+ ):
+ out.append(prefix+name); stack.append((fn,prefix+name+'.'))
return out
diff --git a/setuptools/dist.py b/setuptools/dist.py
index ebd1476..bed32e8 100644
--- a/setuptools/dist.py
+++ b/setuptools/dist.py
@@ -101,8 +101,8 @@ class Distribution(_Distribution):
go.append(('without-'+name, None, 'exclude '+descr+excdef))
no['without-'+name] = 'with-'+name
- self.global_options = go + self.global_options
- self.negative_opt = no
+ self.global_options = self.feature_options = go + self.global_options
+ self.negative_opt = self.feature_negopt = no
def _finalize_features(self):
"""Add/remove features and resolve dependencies between them"""
@@ -276,11 +276,11 @@ class Distribution(_Distribution):
map(self.exclude_package, packages)
-
-
-
-
-
+ def _parse_command_opts(self, parser, args):
+ # Remove --with-X/--without-X options when processing command args
+ self.global_options = self.__class__.global_options
+ self.negative_opt = self.__class__.negative_opt
+ return _Distribution._parse_command_opts(self, parser, args)
diff --git a/setuptools/tests/__init__.py b/setuptools/tests/__init__.py
index 0c4a4f1..186310d 100644
--- a/setuptools/tests/__init__.py
+++ b/setuptools/tests/__init__.py
@@ -288,21 +288,21 @@ class FeatureTests(TestCase):
def testFeatureOptions(self):
dist = self.dist
self.failUnless(
- ('with-dwim',None,'include DWIM') in dist.global_options
+ ('with-dwim',None,'include DWIM') in dist.feature_options
)
self.failUnless(
- ('without-dwim',None,'exclude DWIM (default)') in dist.global_options
+ ('without-dwim',None,'exclude DWIM (default)') in dist.feature_options
)
self.failUnless(
- ('with-bar',None,'include bar (default)') in dist.global_options
+ ('with-bar',None,'include bar (default)') in dist.feature_options
)
self.failUnless(
- ('without-bar',None,'exclude bar') in dist.global_options
+ ('without-bar',None,'exclude bar') in dist.feature_options
)
- self.assertEqual(dist.negative_opt['without-foo'],'with-foo')
- self.assertEqual(dist.negative_opt['without-bar'],'with-bar')
- self.assertEqual(dist.negative_opt['without-dwim'],'with-dwim')
- self.failIf('without-baz' in dist.negative_opt)
+ self.assertEqual(dist.feature_negopt['without-foo'],'with-foo')
+ self.assertEqual(dist.feature_negopt['without-bar'],'with-bar')
+ self.assertEqual(dist.feature_negopt['without-dwim'],'with-dwim')
+ self.failIf('without-baz' in dist.feature_negopt)
def testUseFeatures(self):
dist = self.dist