[Python-checkins] python/nondist/sandbox/setuptools/setuptools depends.py, 1.1, 1.2 dist.py, 1.1, 1.2

pje at users.sourceforge.net pje at users.sourceforge.net
Sat Mar 20 15:52:13 EST 2004


Update of /cvsroot/python/python/nondist/sandbox/setuptools/setuptools
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27800/setuptools

Modified Files:
	depends.py dist.py 
Log Message:
Flesh out 'depends' command to display dependencies' status, and halt if
all requirements aren't met.  (Also, check planned install location for
the dependencies, as well as checking sys.path.)  Also:

* Allow 'Feature()' objects to include 'Require()' objects, so that
  dependencies can be optional

* 'Require()' objects can set a homepage, whose URL will be displayed by 
  the 'depends' command if the dependency needs to be installed.
  
* Misc. fixes/refactoring of version validation to properly handle 
  "unknown" versions, and to decouple version fetching from version
  checking.

* Updated TODO to remove various completed items.


Index: depends.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/depends.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** depends.py	19 Mar 2004 20:53:14 -0000	1.1
--- depends.py	20 Mar 2004 20:52:11 -0000	1.2
***************
*** 11,15 ****
      """A prerequisite to building or installing a distribution"""
  
!     def __init__(self,name,requested_version,module,attribute=None,format=None):
  
          if format is None and requested_version is not None:
--- 11,17 ----
      """A prerequisite to building or installing a distribution"""
  
!     def __init__(self,name,requested_version,module,homepage='',
!         attribute=None,format=None
!     ):
  
          if format is None and requested_version is not None:
***************
*** 21,41 ****
                  attribute = '__version__'
  
!         self.name = name
!         self.requested_version = requested_version
!         self.module = module
!         self.attribute = attribute
!         self.format = format
! 
! 
! 
! 
! 
! 
! 
! 
  
  
  
  
  
  
--- 23,41 ----
                  attribute = '__version__'
  
!         self.__dict__.update(locals())
!         del self.self
  
  
+     def full_name(self):
+         """Return full package/distribution name, w/version"""
+         if self.requested_version is not None:
+             return '%s-%s' % (self.name,self.requested_version)
+         return self.name
  
  
+     def version_ok(self,version):
+         """Is 'version' sufficiently up-to-date?"""
+         return self.attribute is None or self.format is None or \
+             str(version)<>"unknown" and version >= self.requested_version
  
  
***************
*** 67,74 ****
--- 67,76 ----
          return v
  
+ 
      def is_present(self,paths=None):
          """Return true if dependency is present on 'paths'"""
          return self.get_version(paths) is not None
  
+ 
      def is_current(self,paths=None):
          """Return true if dependency is present and up-to-date on 'paths'"""
***************
*** 76,82 ****
          if version is None:
              return False
!         return self.attribute is None or self.format is None or \
!             version >= self.requested_version
! 
  
  
--- 78,82 ----
          if version is None:
              return False
!         return self.version_ok(version)
  
  

Index: dist.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/dist.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** dist.py	19 Mar 2004 20:53:14 -0000	1.1
--- dist.py	20 Mar 2004 20:52:11 -0000	1.2
***************
*** 1,6 ****
  __all__ = ['Distribution', 'Feature']
- 
  from distutils.core import Distribution as _Distribution
  from distutils.core import Extension
  from setuptools.command.build_py import build_py
  from setuptools.command.build_ext import build_ext
--- 1,6 ----
  __all__ = ['Distribution', 'Feature']
  from distutils.core import Distribution as _Distribution
  from distutils.core import Extension
+ from setuptools.depends import Require
  from setuptools.command.build_py import build_py
  from setuptools.command.build_ext import build_ext
***************
*** 12,16 ****
  
  class Distribution(_Distribution):
- 
      """Distribution with support for features, tests, and package data
  
--- 12,15 ----
***************
*** 68,72 ****
          self.cmdclass.setdefault('install',install)
          self.cmdclass.setdefault('install_lib',install_lib)
- 
          if self.features:
              self._set_global_opts_from_features()
--- 67,70 ----
***************
*** 289,293 ****
  
  class Feature:
- 
      """A subset of the distribution that can be excluded if unneeded/wanted
  
--- 287,290 ----
***************
*** 313,316 ****
--- 310,315 ----
        'requires' -- a string or sequence of strings naming features that should
           also be included if this feature is included.  Defaults to empty list.
+          May also contain 'Require' objects that should be added/removed from
+          the distribution.
  
        'remove' -- a string or list of strings naming packages to be removed
***************
*** 346,358 ****
          self.available = available
          self.optional = optional
! 
!         if isinstance(requires,str):
              requires = requires,
  
!         self.requires = requires
  
          if isinstance(remove,str):
              remove = remove,
- 
          self.remove = remove
          self.extras = extras
--- 345,357 ----
          self.available = available
          self.optional = optional
!         if isinstance(requires,(str,Require)):
              requires = requires,
  
!         self.requires = [r for r in requires if isinstance(r,str)]
!         er = [r for r in requires if not isinstance(r,str)]
!         if er: extras['requires'] = er
  
          if isinstance(remove,str):
              remove = remove,
          self.remove = remove
          self.extras = extras
***************
*** 369,373 ****
          return self.available and self.standard
  
- 
      def include_in(self,dist):
  
--- 368,371 ----




More information about the Python-checkins mailing list