[Python-checkins] python/dist/src/Lib/plat-mac pimp.py,1.21,1.22
jackjansen@users.sourceforge.net
jackjansen@users.sourceforge.net
Wed, 28 May 2003 11:56:33 -0700
Update of /cvsroot/python/python/dist/src/Lib/plat-mac
In directory sc8-pr-cvs1:/tmp/cvs-serv24804
Modified Files:
pimp.py
Log Message:
- Added a scheme whereby pimp can update itself, by importing a module
pimp_update if it exists. Upped the version number to indicate this.
Fixes #731626.
- Added -V (print version) and -u (specify database URL) options when run
as a command line tool.
Index: pimp.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/pimp.py,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** pimp.py 6 May 2003 13:07:32 -0000 1.21
--- pimp.py 28 May 2003 18:56:30 -0000 1.22
***************
*** 27,31 ****
import shutil
! __all__ = ["PimpPreferences", "PimpDatabase", "PimpPackage", "main"]
_scriptExc_NotInstalled = "pimp._scriptExc_NotInstalled"
--- 27,32 ----
import shutil
! __all__ = ["PimpPreferences", "PimpDatabase", "PimpPackage", "main",
! "PIMP_VERSION", "main"]
_scriptExc_NotInstalled = "pimp._scriptExc_NotInstalled"
***************
*** 35,39 ****
NO_EXECUTE=0
! PIMP_VERSION="0.1"
# Flavors:
--- 36,40 ----
NO_EXECUTE=0
! PIMP_VERSION="0.2"
# Flavors:
***************
*** 253,260 ****
dict = plistlib.Plist.fromFile(fp)
# Test here for Pimp version, etc
! if not included:
! self._version = dict.get('Version', '0.1')
! if self._version != PIMP_VERSION:
! sys.stderr.write("Warning: database version %s does not match %s\n"
% (self._version, PIMP_VERSION))
self._maintainer = dict.get('Maintainer', '')
--- 254,268 ----
dict = plistlib.Plist.fromFile(fp)
# Test here for Pimp version, etc
! if included:
! version = dict.get('Version')
! if version and version > self._version:
! sys.stderr.write("Warning: included database %s is for pimp version %s\n" %
! (url, version))
! else:
! self._version = dict.get('Version')
! if not self._version:
! sys.stderr.write("Warning: database has no Version information\n")
! elif self._version > PIMP_VERSION:
! sys.stderr.write("Warning: database version %s newer than pimp version %s\n"
% (self._version, PIMP_VERSION))
self._maintainer = dict.get('Maintainer', '')
***************
*** 886,898 ****
print " pimp [options] -i package ... Install packages"
print " pimp -d Dump database to stdout"
print "Options:"
print " -v Verbose"
print " -f Force installation"
! print " -D dir Set destination directory (default: site-packages)"
sys.exit(1)
try:
! opts, args = getopt.getopt(sys.argv[1:], "slifvdD:")
! except getopt.Error:
_help()
if not opts and not args:
--- 894,910 ----
print " pimp [options] -i package ... Install packages"
print " pimp -d Dump database to stdout"
+ print " pimp -V Print version number"
print "Options:"
print " -v Verbose"
print " -f Force installation"
! print " -D dir Set destination directory"
! print " (default: %s)" % DEFAULT_INSTALLDIR
! print " -u url URL for database"
! print " (default: %s)" % DEFAULT_PIMPDATABASE
sys.exit(1)
try:
! opts, args = getopt.getopt(sys.argv[1:], "slifvdD:Vu:")
! except getopt.GetoptError:
_help()
if not opts and not args:
***************
*** 915,918 ****
--- 927,934 ----
_help()
mode = 'dump'
+ if o == '-V':
+ if mode:
+ _help()
+ mode = 'version'
if o == '-i':
mode = 'install'
***************
*** 923,930 ****
if o == '-D':
prefargs['installDir'] = a
if not mode:
_help()
! _run(mode, verbose, force, args, prefargs)
!
if __name__ == '__main__':
main()
--- 939,968 ----
if o == '-D':
prefargs['installDir'] = a
+ if o == '-u':
+ prefargs['pimpDatabase'] = a
if not mode:
_help()
! if mode == 'version':
! print 'Pimp version %s; module name is %s' % (PIMP_VERSION, __name__)
! else:
! _run(mode, verbose, force, args, prefargs)
!
! # Finally, try to update ourselves to a newer version.
! # If the end-user updates pimp through pimp the new version
! # will be called pimp_update and live in site-packages
! # or somewhere similar
! if __name__ != 'pimp_update':
! try:
! import pimp_update
! except ImportError:
! pass
! else:
! if pimp_update.PIMP_VERSION <= PIMP_VERSION:
! import warnings
! warnings.warn("pimp_update is version %s, not newer than pimp version %s" %
! (pimp_update.PIMP_VERSION, PIMP_VERSION))
! else:
! from pimp_update import *
!
if __name__ == '__main__':
main()