diff options
| author | PJ Eby <distutils-sig@python.org> | 2005-07-24 17:59:27 +0000 |
|---|---|---|
| committer | PJ Eby <distutils-sig@python.org> | 2005-07-24 17:59:27 +0000 |
| commit | 8618cfa8ac93431ffcede4f3987b559449bbbcb8 (patch) | |
| tree | 3bd7809dc2d8c5a5dbdf01fc82229a8eea463319 /setuptools | |
| parent | 68b9a791009af00f1fb16fc3c59b0cc4de8ea7c9 (diff) | |
| download | python-setuptools-git-8618cfa8ac93431ffcede4f3987b559449bbbcb8.tar.gz | |
Fix eager resource extraction. Add eager_resources setup() argument. Add
support for obtaining project-level resources by making get_provider()
accept Requirement objects.
--HG--
branch : setuptools
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041151
Diffstat (limited to 'setuptools')
| -rwxr-xr-x | setuptools/command/egg_info.py | 20 | ||||
| -rw-r--r-- | setuptools/dist.py | 69 | ||||
| -rw-r--r-- | setuptools/tests/test_resources.py | 4 |
3 files changed, 67 insertions, 26 deletions
diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 5e5686a3..a5418568 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -96,13 +96,13 @@ class egg_info(Command): finally: metadata.name, metadata.version = oldname, oldver - self.write_namespace_packages() self.write_requirements() self.write_toplevel_names() - + self.write_or_delete_dist_arg('namespace_packages') + self.write_or_delete_dist_arg('eager_resources') if os.path.exists(os.path.join(self.egg_info,'depends.txt')): log.warn( - "WARNING: 'depends.txt' will not be used by setuptools 0.6!\n" + "WARNING: 'depends.txt' is not used by setuptools 0.6!\n" "Use the install_requires/extras_require setup() args instead." ) @@ -162,18 +162,19 @@ class egg_info(Command): - def write_namespace_packages(self): - nsp = getattr(self.distribution,'namespace_packages',None) - if nsp is None: + def write_or_delete_dist_arg(self, argname, filename=None): + value = getattr(self.distribution, argname, None) + if value is None: return - filename = os.path.join(self.egg_info,"namespace_packages.txt") + filename = filename or argname+'.txt' + filename = os.path.join(self.egg_info,filename) - if nsp: + if value: log.info("writing %s", filename) if not self.dry_run: f = open(filename, 'wt') - f.write('\n'.join(nsp)) + f.write('\n'.join(value)) f.write('\n') f.close() @@ -202,4 +203,3 @@ class egg_info(Command): - diff --git a/setuptools/dist.py b/setuptools/dist.py index 73627752..3c7ff852 100644 --- a/setuptools/dist.py +++ b/setuptools/dist.py @@ -92,6 +92,7 @@ class Distribution(_Distribution): self.dist_files = [] self.zip_safe = None self.namespace_packages = None + self.eager_resources = None _Distribution.__init__(self,attrs) if not have_package_data: from setuptools.command.build_py import build_py @@ -120,16 +121,18 @@ class Distribution(_Distribution): - def finalize_options(self): _Distribution.finalize_options(self) + if self.features: self._set_global_opts_from_features() + if self.extra_path: raise DistutilsSetupError( "The 'extra_path' parameter is not needed when using " "setuptools. Please remove it from your setup script." ) + try: list(pkg_resources.parse_requirements(self.install_requires)) except (TypeError,ValueError): @@ -137,6 +140,7 @@ class Distribution(_Distribution): "'install_requires' must be a string or list of strings " "containing valid project/version requirement specifiers" ) + try: for k,v in self.extras_require.items(): list(pkg_resources.parse_requirements(v)) @@ -146,22 +150,27 @@ class Distribution(_Distribution): "strings or lists of strings containing valid project/version " "requirement specifiers." ) - if self.namespace_packages is not None: - try: - assert ''.join(self.namespace_packages)!=self.namespace_packages - except (TypeError,ValueError,AttributeError,AssertionError): - raise DistutilsSetupError( - "'namespace_packages' must be a sequence of strings" - ) - for nsp in self.namespace_packages: - for name in iter_distribution_names(self): - if name.startswith(nsp+'.'): break - else: + + for attr in 'namespace_packages','eager_resources': + value = getattr(self,attr,None) + if value is not None: + try: + assert ''.join(value)!=value + except (TypeError,ValueError,AttributeError,AssertionError): raise DistutilsSetupError( - "Distribution contains no modules or packages for " + - "namespace package %r" % nsp + "%r must be a list of strings (got %r)" % (attr,value) ) + + for nsp in self.namespace_packages or (): + for name in iter_distribution_names(self): + if name.startswith(nsp+'.'): break + else: + raise DistutilsSetupError( + "Distribution contains no modules or packages for " + + "namespace package %r" % nsp + ) + def _set_global_opts_from_features(self): """Add --with-X/--without-X options based on optional features""" @@ -186,6 +195,14 @@ class Distribution(_Distribution): 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""" @@ -203,6 +220,30 @@ class Distribution(_Distribution): feature.exclude_from(self) self._set_feature(name,0) + + + + + + + + + + + + + + + + + + + + + + + + def _set_feature(self,name,status): """Set feature's inclusion status""" setattr(self,self._feature_attrname(name),status) diff --git a/setuptools/tests/test_resources.py b/setuptools/tests/test_resources.py index 8e4dbf07..3345311a 100644 --- a/setuptools/tests/test_resources.py +++ b/setuptools/tests/test_resources.py @@ -146,7 +146,7 @@ class DistroTests(TestCase): # Request an extra that causes an unresolved dependency for "Baz" self.assertRaises( DistributionNotFound, ws.resolve,parse_requirements("Foo[bar]"), ad - ) + ) Baz = Distribution.from_filename( "/foo_dir/Baz-2.1.egg", metadata=Metadata(('depends.txt', "Foo")) ) @@ -332,7 +332,7 @@ class ParseTests(TestCase): self.assertEqual(safe_version("2.3.4 20050521"), "2.3.4.20050521") self.assertEqual(safe_version("Money$$$Maker"), "Money-Maker") self.assertEqual(safe_version("peak.web"), "peak.web") - + def testSimpleRequirements(self): self.assertEqual( list(parse_requirements('Twis-Ted>=1.2-1')), |
