[Python-checkins] python/nondist/sandbox/setuptools/setuptools/command alias.py, NONE, 1.1 __init__.py, 1.5, 1.6 saveopts.py, 1.1, 1.2 sdist.py, 1.2, 1.3 setopt.py, 1.1, 1.2

pje@users.sourceforge.net pje at users.sourceforge.net
Fri Jul 8 07:09:26 CEST 2005


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

Modified Files:
	__init__.py saveopts.py sdist.py setopt.py 
Added Files:
	alias.py 
Log Message:
Added support for defining command aliases in distutils configuration
files, under the "[aliases]" section.  To prevent recursion and to allow
aliases to call the command of the same name, a given alias can be expanded
only once per command-line invocation.  You can define new aliases with the
"alias" command, either for the local, global, or per-user configuration.


--- NEW FILE: alias.py ---
import distutils, os
from setuptools import Command
from distutils.util import convert_path
from distutils import log
from distutils.errors import *
from setuptools.command.setopt import edit_config, option_base

class alias(option_base):
    """Abstract base class for commands that mess with config files"""
    
    description = "set an option in setup.cfg or another config file"

    user_options = [
        ('alias=',  'a',  'the name of the new pseudo-command'),
        ('command=', 'c', 'command(s) and options to invoke when used'),
        ('remove',   'r', 'remove (unset) the alias'), 
    ] + option_base.user_options

    boolean_options = option_base.boolean_options + ['remove']

    def initialize_options(self):
        option_base.initialize_options(self)
        self.alias = None
        self.command = None
        self.remove = None

    def finalize_options(self):
        option_base.finalize_options(self)
        if self.alias is None:
            raise DistutilsOptionError("Must specify name (--alias/-a)")
        if self.command is None and not self.remove:
            raise DistutilsOptionError("Must specify --command or --remove")

    def run(self):
        edit_config(
            self.filename, {'aliases': {self.alias:self.command}},
            self.dry_run
        )


Index: __init__.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/command/__init__.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- __init__.py	8 Jul 2005 04:48:20 -0000	1.5
+++ __init__.py	8 Jul 2005 05:09:23 -0000	1.6
@@ -1,6 +1,8 @@
 import distutils.command
 
-__all__ = ['test', 'develop', 'bdist_egg', 'saveopts', 'setopt', 'rotate']
+__all__ = [
+    'test', 'develop', 'bdist_egg', 'saveopts', 'setopt', 'rotate', 'alias'
+]
 
 
 # Make our commands available as though they were part of the distutils

Index: saveopts.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/command/saveopts.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- saveopts.py	8 Jul 2005 04:48:20 -0000	1.1
+++ saveopts.py	8 Jul 2005 05:09:23 -0000	1.2
@@ -7,21 +7,19 @@
 
     description = "save supplied options to setup.cfg or other config file"
 
-    user_options = option_base.user_options + [
-    ]
-
-    boolean_options = option_base.boolean_options + [
-    ]    
-
     def run(self):
         dist = self.distribution
         commands = dist.command_options.keys()
         settings = {}
+
         for cmd in commands:
+
             if cmd=='saveopts':
-                continue
+                continue    # don't save our own options!
+
             for opt,(src,val) in dist.get_option_dict(cmd).items():
                 if src=="command line":
                     settings.setdefault(cmd,{})[opt] = val
+
         edit_config(self.filename, settings, self.dry_run)
 

Index: sdist.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/command/sdist.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- sdist.py	7 Jul 2005 16:28:43 -0000	1.2
+++ sdist.py	8 Jul 2005 05:09:23 -0000	1.3
@@ -84,6 +84,7 @@
     """Smart sdist that finds anything supported by revision control"""
 
     def run(self):
+        self.run_command('egg_info')
         _sdist.run(self)
         dist_files = getattr(self.distribution,'dist_files',[])
         for file in self.archive_files:
@@ -120,4 +121,3 @@
 
 
 
-

Index: setopt.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/command/setopt.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- setopt.py	8 Jul 2005 04:48:20 -0000	1.1
+++ setopt.py	8 Jul 2005 05:09:23 -0000	1.2
@@ -84,12 +84,12 @@
     """Abstract base class for commands that mess with config files"""
     
     user_options = [
-        ('filename=', 'f',
-                 "set the file to use (default=setup.cfg)"),
         ('global-config', 'g',
                  "save options to the site-wide distutils.cfg file"),
         ('user-config', 'u',
                  "save options to the current user's pydistutils.cfg file"),
+        ('filename=', 'f',
+                 "configuration file to use (default=setup.cfg)"),
     ]
 
     boolean_options = [
@@ -126,12 +126,12 @@
 
     description = "set an option in setup.cfg or another config file"
 
-    user_options = option_base.user_options + [
+    user_options = [
         ('command=', 'c', 'command to set an option for'),
         ('option=',  'o',  'option to set'),
         ('set-value=',   's', 'value of the option'),
-        ('remove',   'r', 'unset the value'), 
-    ]
+        ('remove',   'r', 'remove (unset) the value'), 
+    ] + option_base.user_options
 
     boolean_options = option_base.boolean_options + ['remove']
 



More information about the Python-checkins mailing list