[Python-checkins]
python/dist/src/Lib/distutils/command checkdep.py, NONE,
1.1 __init__.py, 1.18, 1.19 install.py, 1.67, 1.68
anthonybaxter at users.sourceforge.net
anthonybaxter at users.sourceforge.net
Mon Mar 22 17:22:07 EST 2004
Update of /cvsroot/python/python/dist/src/Lib/distutils/command
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11533/command
Modified Files:
__init__.py install.py
Added Files:
checkdep.py
Log Message:
Basic dependency checking. setup() has two new optional arguments
requires and provides. requires is a sequence of strings, of the
form 'packagename-version'. The dependency checking so far merely
does an '__import__(packagename)' and checks for packagename.__version__
You can also leave off the version, and any version of the package
will be installed.
There's a special case for the package 'python' - sys.version_info
is used, so
requires= ( 'python-2.3', )
just works.
Provides is of the same format as requires - but if it's not supplied,
a provides is generated by adding the version to each entry in packages,
or modules if packages isn't there.
Provides is currently only used in the PKG-INFO file. Shortly, PyPI
will grow the ability to accept these lines, and register will be
updated to send them.
There's a new command 'checkdep' command that runs these checks.
For this version, only greater-than-or-equal checking is done. We'll
add the ability to specify an optional operator later.
--- NEW FILE: checkdep.py ---
"""distutils.command.x
Implements the Distutils 'x' command.
"""
# created 2000/mm/dd, John Doe
__revision__ = "$Id: checkdep.py,v 1.1 2004/03/22 22:22:05 anthonybaxter Exp $"
from distutils.core import Command
class DependencyFailure(Exception): pass
class VersionTooOld(DependencyFailure): pass
class VersionNotKnown(DependencyFailure): pass
class checkdep (Command):
# Brief (40-50 characters) description of the command
description = "check package dependencies"
# List of option tuples: long name, short name (None if no short
# name), and help string.
# Later on, we might have auto-fetch and the like here. Feel free.
user_options = []
def initialize_options (self):
self.debug = None
# initialize_options()
def finalize_options (self):
pass
# finalize_options()
def run (self):
from distutils.version import LooseVersion
failed = []
for pkg, ver in self.distribution.metadata.requires:
if pkg == 'python':
if ver is not None:
# Special case the 'python' package
import sys
thisver = LooseVersion('%d.%d.%d'%sys.version_info[:3])
if thisver < ver:
failed.append(((pkg,ver), VersionTooOld(thisver)))
continue
# Kinda hacky - we should do more here
try:
mod = __import__(pkg)
except Exception, e:
failed.append(((pkg,ver), e))
continue
if ver is not None:
if hasattr(mod, '__version__'):
thisver = LooseVersion(mod.__version__)
if thisver < ver:
failed.append(((pkg,ver), VersionTooOld(thisver)))
else:
failed.append(((pkg,ver), VersionNotKnown()))
if failed:
raise DependencyFailure, failed
# run()
# class x
Index: __init__.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/__init__.py,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** __init__.py 3 Mar 2003 18:37:16 -0000 1.18
--- __init__.py 22 Mar 2004 22:22:05 -0000 1.19
***************
*** 25,28 ****
--- 25,29 ----
'bdist_rpm',
'bdist_wininst',
+ 'checkdep',
# These two are reserved for future use:
#'bdist_sdux',
Index: install.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/install.py,v
retrieving revision 1.67
retrieving revision 1.68
diff -C2 -d -r1.67 -r1.68
*** install.py 19 Nov 2002 13:12:28 -0000 1.67
--- install.py 22 Mar 2004 22:22:05 -0000 1.68
***************
*** 127,130 ****
--- 127,132 ----
('skip-build', None,
"skip rebuilding everything (for testing/debugging)"),
+ ('skip-checkdep', None,
+ "skip checking dependencies (use at own risk)"),
# Where to install documentation (eventually!)
***************
*** 184,188 ****
# 'force' forces installation, even if target files are not
# out-of-date. 'skip_build' skips running the "build" command,
! # handy if you know it's not necessary. 'warn_dir' (which is *not*
# a user option, it's just there so the bdist_* commands can turn
# it off) determines whether we warn about installing to a
--- 186,192 ----
# 'force' forces installation, even if target files are not
# out-of-date. 'skip_build' skips running the "build" command,
! # handy if you know it's not necessary. 'skip_checkdep' skips
! # the 'checkdep' command, if you are sure you can work around the
! # dependency failure in another way. 'warn_dir' (which is *not*
# a user option, it's just there so the bdist_* commands can turn
# it off) determines whether we warn about installing to a
***************
*** 190,193 ****
--- 194,198 ----
self.force = 0
self.skip_build = 0
+ self.skip_checkdep = 0
self.warn_dir = 1
***************
*** 501,504 ****
--- 506,515 ----
self.run_command('build')
+ # We check dependencies before we install
+ # For now, this is disabled. Before 2.4 is released, this will
+ # be turned on.
+ #if not self.skip_checkdep:
+ # self.run_command('checkdep')
+
# Run all sub-commands (at least those that need to be run)
for cmd_name in self.get_sub_commands():
More information about the Python-checkins
mailing list