diff --git a/README.rst b/README.rst
index 8bacf7f..f499739 100644
--- a/README.rst
+++ b/README.rst
@@ -2,7 +2,9 @@
commando - argparse in style
============================
-**Version 0.3.2a**
+**Version 0.4**
+
+Requires python 3.3 or later.
A simple wrapper for ``argparse`` that allows commands and arguments
to be defined declaratively using decorators. Note that this does
diff --git a/commando/__init__.py b/commando/__init__.py
index 2b6e730..a12310a 100644
--- a/commando/__init__.py
+++ b/commando/__init__.py
@@ -1 +1 @@
-from commando.application import *
+from .application import *
diff --git a/commando/application.py b/commando/application.py
index 2c17522..3a7d1dc 100644
--- a/commando/application.py
+++ b/commando/application.py
@@ -4,7 +4,7 @@
"""
from argparse import ArgumentParser
from collections import namedtuple
-from commando.util import getLoggerWithConsoleHandler
+from .util import getLoggerWithConsoleHandler
import logging
@@ -38,13 +38,13 @@ class Commando(type):
"""
def __new__(mcs, name, bases, attrs):
- instance = super(Commando, mcs).__new__(mcs, name, bases, attrs)
+ instance = super().__new__(mcs, name, bases, attrs)
subcommands = []
main_command = None
main_parser = None
# Collect commands based on decorators
- for member in attrs.itervalues():
+ for member in attrs.values():
if hasattr(member, "command"):
main_command = member
elif hasattr(member, "subcommand"):
@@ -63,22 +63,26 @@ def add_subparser(func):
# Sub of main
func.parent = main_command
else:
+ parent = func.parent
# Sub of something else
- if not getattr(func.parent, 'parser', None):
+ if not getattr(parent, 'parser', None):
# Parser doesn't exist for the parent.
- add_subparser(func.parent)
- if not getattr(func.parent, 'subparsers', None):
+ add_subparser(parent)
+ if not getattr(parent, 'subparsers', None):
# Subparser collection doesn't exist for the parent.
- func.parent.subparsers = func.parent.parser.add_subparsers()
+ parent.subparsers = parent.parser.add_subparsers()
func.parser = func.parent.subparsers.add_parser(
- *func.subcommand.args,
- **func.subcommand.kwargs)
+ *func.subcommand.args,
+ **func.subcommand.kwargs
+ )
add_arguments(func)
if main_command:
- main_parser = ArgumentParser(*main_command.command.args,
- **main_command.command.kwargs)
+ main_parser = ArgumentParser(
+ *main_command.command.args,
+ **main_command.command.kwargs
+ )
main_command.parser = main_parser
add_arguments(main_command)
@@ -142,7 +146,7 @@ def __init__(self, *args, **kwargs):
del kwargs['parent']
except KeyError:
pass
- super(subcommand, self).__init__(*args, **kwargs)
+ super().__init__(*args, **kwargs)
def __call__(self, func):
func.parent = self.parent
@@ -166,7 +170,7 @@ class version(param):
"""
def __init__(self, *args, **kwargs):
- super(version, self).__init__(*args, action='version', **kwargs)
+ super().__init__(*args, action='version', **kwargs)
class store(param):
@@ -175,7 +179,7 @@ class store(param):
"""
def __init__(self, *args, **kwargs):
- super(store, self).__init__(*args, action='store', **kwargs)
+ super().__init__(*args, action='store', **kwargs)
class true(param):
@@ -184,7 +188,7 @@ class true(param):
"""
def __init__(self, *args, **kwargs):
- super(true, self).__init__(*args, action='store_true', **kwargs)
+ super().__init__(*args, action='store_true', **kwargs)
class false(param):
@@ -193,7 +197,7 @@ class false(param):
"""
def __init__(self, *args, **kwargs):
- super(false, self).__init__(*args, action='store_false', **kwargs)
+ super().__init__(*args, action='store_false', **kwargs)
class const(param):
@@ -202,7 +206,7 @@ class const(param):
"""
def __init__(self, *args, **kwargs):
- super(const, self).__init__(*args, action='store_const', **kwargs)
+ super().__init__(*args, action='store_const', **kwargs)
class append(param):
@@ -211,7 +215,7 @@ class append(param):
"""
def __init__(self, *args, **kwargs):
- super(append, self).__init__(*args, action='append', **kwargs)
+ super().__init__(*args, action='append', **kwargs)
class append_const(param):
@@ -220,16 +224,13 @@ class append_const(param):
"""
def __init__(self, *args, **kwargs):
- super(append_const, self).__init__(*args,
- action='append_const',
- **kwargs)
+ super().__init__(*args, action='append_const', **kwargs)
-class Application(object):
+class Application(object, metaclass=Commando):
"""
Barebones base class for command line applications.
"""
- __metaclass__ = Commando
def __init__(self, raise_exceptions=False, logger=None):
self.raise_exceptions = raise_exceptions
@@ -258,7 +259,7 @@ def run(self, args=None):
args.run(self, args)
else:
self.__main__(args) # pylint: disable-msg=E1101
- except Exception, e:
+ except Exception as e:
if self.raise_exceptions:
raise
elif self.__parser__:
diff --git a/commando/conf.py b/commando/conf.py
index c38a213..100c8a2 100644
--- a/commando/conf.py
+++ b/commando/conf.py
@@ -2,11 +2,12 @@
seqs = (tuple, list, set, frozenset)
+
class ConfigDict(defaultdict):
def __init__(self, initial=None):
super(ConfigDict, self).__init__(ConfigDict)
initial = initial or {}
- for key, value in initial.iteritems():
+ for key, value in initial.items():
self.__setitem__(key, value)
def __setitem__(self, key, value):
@@ -28,7 +29,7 @@ def copy(self):
def patch(self, overrides):
overrides = overrides or {}
- for key, value in overrides.iteritems():
+ for key, value in overrides.items():
current = self.get(key)
if isinstance(value, dict) and isinstance(current, dict):
current.patch(value)
@@ -62,18 +63,19 @@ def __set__(self, instance, value):
class AutoPropMetaClass(type):
def __new__(mcs, cname, cbases, cattrs):
- autoprops = {name: member
- for name, member in cattrs.iteritems()
- if getattr(member, 'autoprop', False)}
- for name, member in autoprops.iteritems():
+ autoprops = {
+ name: member
+ for name, member in cattrs.items()
+ if getattr(member, 'autoprop', False)
+ }
+ for name, member in autoprops.items():
cattrs[name] = AutoPropDescriptor(member)
return super(AutoPropMetaClass, mcs).__new__(
- mcs, cname, cbases, cattrs)
-
+ mcs, cname, cbases, cattrs
+ )
-class AutoProp(object):
- __metaclass__ = AutoPropMetaClass
+class AutoProp(object, metaclass=AutoPropMetaClass):
@staticmethod
def default(f):
diff --git a/commando/tests/test_commando.py b/commando/tests/test_commando.py
index 9716b1b..30f0e7b 100644
--- a/commando/tests/test_commando.py
+++ b/commando/tests/test_commando.py
@@ -6,7 +6,6 @@
`$ nosetests test_commando.py -d -v`
"""
-from contextlib import nested
from commando import *
from mock import patch
@@ -15,7 +14,7 @@
import cStringIO
StringIO = cStringIO
except ImportError:
- import StringIO as xStringIO
+ import io as xStringIO
StringIO = xStringIO
@@ -25,7 +24,7 @@ def test_wrapper(*args):
f(*args)
except SystemExit:
import traceback
- print traceback.format_exc()
+ print(traceback.format_exc())
assert False
test_wrapper.__name__ = f.__name__
return test_wrapper
@@ -34,7 +33,7 @@ def test_wrapper(*args):
def trap_exit_pass(f):
def test_wrapper(*args):
try:
- print f.__name__
+ print(f.__name__)
f(*args)
except SystemExit:
pass
@@ -55,6 +54,7 @@ def main(self, params):
def _main(self):
pass
+
@trap_exit_fail
def test_command_basic():
@@ -98,8 +98,6 @@ def _main(self, params):
assert params.force3 == '2'
assert params.force2 == '3'
-
-
p = PositionalCommandLine()
args = p.parse(['1', '2', '3'])
p.run(args)
@@ -186,16 +184,16 @@ def _sub():
@trap_exit_pass
def test_command_subcommands_usage():
- with nested(patch.object(ComplexCommandLine, '_main'),
- patch.object(ComplexCommandLine, '_sub')) as (_main, _sub):
+ with patch.object(ComplexCommandLine, '_main'), \
+ patch.object(ComplexCommandLine, '_sub'):
c = ComplexCommandLine()
c.parse(['--usage'])
@trap_exit_fail
def test_command_subcommands():
- with nested(patch.object(ComplexCommandLine, '_main'),
- patch.object(ComplexCommandLine, '_sub')) as (_main, _sub):
+ with patch.object(ComplexCommandLine, '_main') as _main, \
+ patch.object(ComplexCommandLine, '_sub') as _sub:
c = ComplexCommandLine()
args = c.parse(['sub', '--launch', '--launch2', 'True'])
c.run(args)
@@ -225,8 +223,8 @@ def _sub():
@trap_exit_pass
def test_empty_main_command():
- with nested(patch.object(EmptyCommandLine, '_main'),
- patch.object(EmptyCommandLine, '_sub')) as (_main, _sub):
+ with patch.object(EmptyCommandLine, '_main') as _main, \
+ patch.object(EmptyCommandLine, '_sub') as _sub:
e = EmptyCommandLine(raise_exceptions=True)
args = e.parse(None)
e.run(args)
@@ -235,8 +233,8 @@ def test_empty_main_command():
def test_empty_sub_command():
- with nested(patch.object(EmptyCommandLine, '_main'),
- patch.object(EmptyCommandLine, '_sub')) as (_main, _sub):
+ with patch.object(EmptyCommandLine, '_main') as _main, \
+ patch.object(EmptyCommandLine, '_sub') as _sub:
e = EmptyCommandLine(raise_exceptions=True)
e.run(e.parse(['sub']))
assert not _main.called
@@ -293,11 +291,10 @@ def _foobar_blip_blop():
@trap_exit_fail
def test_nested_command_subcommands():
- with nested(patch.object(NestedCommandLine, '_main'),
- patch.object(NestedCommandLine, '_sub'),
- patch.object(NestedCommandLine, '_foobar_bla'),
- patch.object(NestedCommandLine, '_foobar_blip_blop')) \
- as (_main, _sub, _foobar_bla, _foobar_blip_blop):
+ with patch.object(NestedCommandLine, '_main') as _main, \
+ patch.object(NestedCommandLine, '_sub') as _sub,\
+ patch.object(NestedCommandLine, '_foobar_bla') as _foobar_bla, \
+ patch.object(NestedCommandLine, '_foobar_blip_blop') as _blop:
c = NestedCommandLine(raise_exceptions=True)
@@ -318,4 +315,4 @@ def test_nested_command_subcommands():
assert not _main.called
assert _sub.call_count == 1
assert _foobar_bla.call_count == 1
- assert _foobar_blip_blop.call_count == 1
+ assert _blop.call_count == 1
diff --git a/commando/tests/test_loader.py b/commando/tests/test_loader.py
index 076ccaf..929bfee 100644
--- a/commando/tests/test_loader.py
+++ b/commando/tests/test_loader.py
@@ -9,8 +9,6 @@
from nose.tools import raises
import os
-from fswrap import File
-
def test_can_load_locals():
@@ -30,6 +28,7 @@ def test_can_load_from_python_path():
assert "
h3
" == markdown("### h3")
+
def test_can_load_module_without_dot():
yaml = load_python_object('yaml')
@@ -42,12 +41,14 @@ def test_can_load_module_without_dot():
assert abc['d'] == 'efg'
assert abc['l'] == 'mno'
+
@raises(CommandoLoaderException)
def test_exception_raised_for_invalid_module():
load_python_object("junk.junk.junk")
assert False
+
@raises(CommandoLoaderException)
def test_exception_raised_for_invalid_object():
load_python_object("markdown.junk")
- assert False
\ No newline at end of file
+ assert False
diff --git a/commando/util.py b/commando/util.py
index fe12372..b3781ee 100644
--- a/commando/util.py
+++ b/commando/util.py
@@ -7,7 +7,10 @@
from logging import NullHandler
from subprocess import check_call, check_output, Popen
-class CommandoLoaderException(Exception): pass
+
+class CommandoLoaderException(Exception):
+ pass
+
def load_python_object(name):
"""
@@ -22,7 +25,8 @@ def load_python_object(name):
module = __import__(module_name)
except ImportError:
raise CommandoLoaderException(
- "Module [%s] cannot be loaded." % module_name)
+ "Module [%s] cannot be loaded." % module_name
+ )
if object_name == '':
return module
@@ -31,23 +35,26 @@ def load_python_object(name):
module = sys.modules[module_name]
except KeyError:
raise CommandoLoaderException(
- "Error occured when loading module [%s]" % module_name)
+ "Error occured when loading module [%s]" % module_name
+ )
try:
- logger.debug('Getting object [%s] from module [%s]' %
- (object_name, module_name))
+ logger.debug(
+ 'Getting object [%s] from module [%s]' %
+ (object_name, module_name)
+ )
return getattr(module, object_name)
except AttributeError:
raise CommandoLoaderException(
- "Cannot load object [%s]. "
- "Module [%s] does not contain object [%s]. "
- "Please fix the configuration or "
- "ensure that the module is installed properly" %
- (
- name,
- module_name,
- object_name
- )
+ "Cannot load object [%s]. "
+ "Module [%s] does not contain object [%s]. "
+ "Please fix the configuration or "
+ "ensure that the module is installed properly" %
+ (
+ name,
+ module_name,
+ object_name
+ )
)
@@ -95,12 +102,15 @@ def getLoggerWithConsoleHandler(logger_name=None):
handler = logging.StreamHandler(sys.stdout)
if sys.platform == 'win32':
formatter = logging.Formatter(
- fmt="%(asctime)s %(name)s %(message)s",
- datefmt='%H:%M:%S')
+ fmt="%(asctime)s %(name)s %(message)s",
+ datefmt='%H:%M:%S'
+ )
else:
- formatter = ColorFormatter(fmt="$RESET %(asctime)s "
- "$BOLD$COLOR%(name)s$RESET "
- "%(message)s", datefmt='%H:%M:%S')
+ formatter = ColorFormatter(
+ fmt="$RESET %(asctime)s "
+ "$BOLD$COLOR%(name)s$RESET "
+ "%(message)s", datefmt='%H:%M:%S'
+ )
handler.setFormatter(formatter)
logger.addHandler(handler)
return logger
@@ -120,7 +130,7 @@ def getLoggerWithNullHandler(logger_name):
## Code stolen from :
## http://stackoverflow.com/q/384076
##
-BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = range(8)
+BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = list(range(8))
COLORS = {
'WARNING': YELLOW,
@@ -152,11 +162,11 @@ def format(self, record):
levelname = record.levelname
color = COLOR_SEQ % (30 + COLORS[levelname])
message = logging.Formatter.format(self, record)
- message = message.replace("$RESET", RESET_SEQ)\
- .replace("$BOLD", BOLD_SEQ)\
- .replace("$COLOR", color)
+ message = message.replace("$RESET", RESET_SEQ)
+ message = message.replace("$BOLD", BOLD_SEQ)
+ message = message.replace("$COLOR", color)
- for k, v in COLORS.items():
+ for k, v in list(COLORS.items()):
message = message.replace("$" + k, COLOR_SEQ % (v + 30))\
.replace("$BG" + k, COLOR_SEQ % (v + 40))\
.replace("$BG-" + k, COLOR_SEQ % (v + 40))
@@ -166,10 +176,10 @@ def format(self, record):
__all__ = [
- 'CommandoLoaderException',
- 'load_python_object',
- 'ShellCommand',
- 'ColorFormatter',
- 'getLoggerWithNullHandler',
- 'getLoggerWithConsoleHandler'
- ]
\ No newline at end of file
+ 'CommandoLoaderException',
+ 'load_python_object',
+ 'ShellCommand',
+ 'ColorFormatter',
+ 'getLoggerWithNullHandler',
+ 'getLoggerWithConsoleHandler'
+]
diff --git a/distribute_setup.py b/distribute_setup.py
index 3ea2e66..c8bd18c 100644
--- a/distribute_setup.py
+++ b/distribute_setup.py
@@ -14,11 +14,14 @@
This file can also be run as a script to install or upgrade setuptools.
"""
import os
+import shutil
import sys
import time
import fnmatch
import tempfile
import tarfile
+import optparse
+
from distutils import log
try:
@@ -46,7 +49,7 @@ def quote(arg):
args = [quote(arg) for arg in args]
return os.spawnl(os.P_WAIT, sys.executable, *args) == 0
-DEFAULT_VERSION = "0.6.14"
+DEFAULT_VERSION = "0.6.35"
DEFAULT_URL = "http://pypi.python.org/packages/source/d/distribute/"
SETUPTOOLS_FAKED_VERSION = "0.6c11"
@@ -63,7 +66,7 @@ def quote(arg):
""" % SETUPTOOLS_FAKED_VERSION
-def _install(tarball):
+def _install(tarball, install_args=()):
# extracting the tarball
tmpdir = tempfile.mkdtemp()
log.warn('Extracting in %s', tmpdir)
@@ -81,11 +84,14 @@ def _install(tarball):
# installing
log.warn('Installing Distribute')
- if not _python_cmd('setup.py', 'install'):
+ if not _python_cmd('setup.py', 'install', *install_args):
log.warn('Something went wrong during the installation.')
log.warn('See the error message above.')
+ # exitcode will be 2
+ return 2
finally:
os.chdir(old_wd)
+ shutil.rmtree(tmpdir)
def _build_egg(egg, tarball, to_dir):
@@ -110,6 +116,7 @@ def _build_egg(egg, tarball, to_dir):
finally:
os.chdir(old_wd)
+ shutil.rmtree(tmpdir)
# returning the result
log.warn(egg)
if not os.path.exists(egg):
@@ -144,7 +151,7 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
except ImportError:
return _do_download(version, download_base, to_dir, download_delay)
try:
- pkg_resources.require("distribute>="+version)
+ pkg_resources.require("distribute>=" + version)
return
except pkg_resources.VersionConflict:
e = sys.exc_info()[1]
@@ -167,6 +174,7 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
if not no_fake:
_create_fake_setuptools_pkg_info(to_dir)
+
def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
to_dir=os.curdir, delay=15):
"""Download distribute from a specified location and return its filename
@@ -203,6 +211,7 @@ def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
dst.close()
return os.path.realpath(saveto)
+
def _no_sandbox(function):
def __no_sandbox(*args, **kw):
try:
@@ -227,9 +236,12 @@ def violation(*args):
return __no_sandbox
+
def _patch_file(path, content):
"""Will backup the file then patch it"""
- existing_content = open(path).read()
+ f = open(path)
+ existing_content = f.read()
+ f.close()
if existing_content == content:
# already patched
log.warn('Already patched.')
@@ -245,15 +257,21 @@ def _patch_file(path, content):
_patch_file = _no_sandbox(_patch_file)
+
def _same_content(path, content):
- return open(path).read() == content
+ f = open(path)
+ existing_content = f.read()
+ f.close()
+ return existing_content == content
+
def _rename_path(path):
new_name = path + '.OLD.%s' % time.time()
- log.warn('Renaming %s into %s', path, new_name)
+ log.warn('Renaming %s to %s', path, new_name)
os.rename(path, new_name)
return new_name
+
def _remove_flat_installation(placeholder):
if not os.path.isdir(placeholder):
log.warn('Unkown installation at %s', placeholder)
@@ -267,7 +285,7 @@ def _remove_flat_installation(placeholder):
log.warn('Could not locate setuptools*.egg-info')
return
- log.warn('Removing elements out of the way...')
+ log.warn('Moving elements out of the way...')
pkg_info = os.path.join(placeholder, file)
if os.path.isdir(pkg_info):
patched = _patch_egg_dir(pkg_info)
@@ -289,11 +307,13 @@ def _remove_flat_installation(placeholder):
_remove_flat_installation = _no_sandbox(_remove_flat_installation)
+
def _after_install(dist):
log.warn('After install bootstrap.')
placeholder = dist.get_command_obj('install').install_purelib
_create_fake_setuptools_pkg_info(placeholder)
+
def _create_fake_setuptools_pkg_info(placeholder):
if not placeholder or not os.path.exists(placeholder):
log.warn('Could not find the install location')
@@ -307,7 +327,11 @@ def _create_fake_setuptools_pkg_info(placeholder):
return
log.warn('Creating %s', pkg_info)
- f = open(pkg_info, 'w')
+ try:
+ f = open(pkg_info, 'w')
+ except EnvironmentError:
+ log.warn("Don't have permissions to write %s, skipping", pkg_info)
+ return
try:
f.write(SETUPTOOLS_PKG_INFO)
finally:
@@ -321,7 +345,10 @@ def _create_fake_setuptools_pkg_info(placeholder):
finally:
f.close()
-_create_fake_setuptools_pkg_info = _no_sandbox(_create_fake_setuptools_pkg_info)
+_create_fake_setuptools_pkg_info = _no_sandbox(
+ _create_fake_setuptools_pkg_info
+)
+
def _patch_egg_dir(path):
# let's check if it's already patched
@@ -343,6 +370,7 @@ def _patch_egg_dir(path):
_patch_egg_dir = _no_sandbox(_patch_egg_dir)
+
def _before_install():
log.warn('Before install bootstrap.')
_fake_setuptools()
@@ -351,7 +379,7 @@ def _before_install():
def _under_prefix(location):
if 'install' not in sys.argv:
return True
- args = sys.argv[sys.argv.index('install')+1:]
+ args = sys.argv[sys.argv.index('install') + 1:]
for index, arg in enumerate(args):
for option in ('--root', '--prefix'):
if arg.startswith('%s=' % option):
@@ -359,7 +387,7 @@ def _under_prefix(location):
return location.startswith(top_dir)
elif arg == option:
if len(args) > index:
- top_dir = args[index+1]
+ top_dir = args[index + 1]
return location.startswith(top_dir)
if arg == '--user' and USER_SITE is not None:
return location.startswith(USER_SITE)
@@ -376,11 +404,14 @@ def _fake_setuptools():
return
ws = pkg_resources.working_set
try:
- setuptools_dist = ws.find(pkg_resources.Requirement.parse('setuptools',
- replacement=False))
+ setuptools_dist = ws.find(
+ pkg_resources.Requirement.parse('setuptools', replacement=False)
+ )
except TypeError:
# old distribute API
- setuptools_dist = ws.find(pkg_resources.Requirement.parse('setuptools'))
+ setuptools_dist = ws.find(
+ pkg_resources.Requirement.parse('setuptools')
+ )
if setuptools_dist is None:
log.warn('No setuptools distribution found')
@@ -414,7 +445,7 @@ def _fake_setuptools():
res = _patch_egg_dir(setuptools_location)
if not res:
return
- log.warn('Patched done.')
+ log.warn('Patching complete.')
_relaunch()
@@ -422,7 +453,9 @@ def _relaunch():
log.warn('Relaunching...')
# we have to relaunch the process
# pip marker to avoid a relaunch bug
- if sys.argv[:3] == ['-c', 'install', '--single-version-externally-managed']:
+ _cmd1 = ['-c', 'install', '--single-version-externally-managed']
+ _cmd2 = ['-c', 'install', '--record']
+ if sys.argv[:3] == _cmd1 or sys.argv[:3] == _cmd2:
sys.argv[0] = 'setup.py'
args = [sys.executable] + sys.argv
sys.exit(subprocess.call(args))
@@ -448,7 +481,7 @@ def _extractall(self, path=".", members=None):
# Extract directories with a safe mode.
directories.append(tarinfo)
tarinfo = copy.copy(tarinfo)
- tarinfo.mode = 448 # decimal for oct 0700
+ tarinfo.mode = 448 # decimal for oct 0700
self.extract(tarinfo, path)
# Reverse sort directories.
@@ -475,11 +508,39 @@ def sorter(dir1, dir2):
self._dbg(1, "tarfile: %s" % e)
-def main(argv, version=DEFAULT_VERSION):
+def _build_install_args(options):
+ """
+ Build the arguments to 'python setup.py install' on the distribute package
+ """
+ install_args = []
+ if options.user_install:
+ if sys.version_info < (2, 6):
+ log.warn("--user requires Python 2.6 or later")
+ raise SystemExit(1)
+ install_args.append('--user')
+ return install_args
+
+def _parse_args():
+ """
+ Parse the command line for options
+ """
+ parser = optparse.OptionParser()
+ parser.add_option(
+ '--user', dest='user_install', action='store_true', default=False,
+ help='install in user site package (requires Python 2.6 or later)')
+ parser.add_option(
+ '--download-base', dest='download_base', metavar="URL",
+ default=DEFAULT_URL,
+ help='alternative URL from where to download the distribute package')
+ options, args = parser.parse_args()
+ # positional arguments are ignored
+ return options
+
+def main(version=DEFAULT_VERSION):
"""Install or upgrade setuptools and EasyInstall"""
- tarball = download_setuptools()
- _install(tarball)
-
+ options = _parse_args()
+ tarball = download_setuptools(download_base=options.download_base)
+ return _install(tarball, _build_install_args(options))
if __name__ == '__main__':
- main(sys.argv[1:])
+ sys.exit(main())
\ No newline at end of file
diff --git a/setup.py b/setup.py
index b412dae..265559a 100644
--- a/setup.py
+++ b/setup.py
@@ -13,15 +13,18 @@
description='A declarative interface to argparse with additional utilities',
long_description=long_description,
- version='0.3.2a',
+ version='0.4',
author='Lakshmi Vyas',
author_email='lakshmi.vyas@gmail.com',
url='http://github.com/lakshmivyas/commando',
packages=['commando'],
- requires=['python (>= 2.7)'],
+ requires=['python (>= 3.3)'],
provides=['commando'],
+ dependency_links=[
+ "https://github.com/lakshmivyas/fswrap/archive/refactor/python3.zip#egg=fswrap"
+ ],
test_requires=['nose', 'mock', 'fswrap', 'markdown', 'yaml'],
license='MIT',