aboutsummaryrefslogtreecommitdiffstats
path: root/distribute_setup.py
diff options
context:
space:
mode:
authorPedro Romano <pedro.romano@digitaluna.net>2012-08-30 11:58:22 +0100
committerPedro Romano <pedro.romano@digitaluna.net>2012-08-30 11:58:22 +0100
commitdbc8208b379835ee43224e83829b41790347e1e2 (patch)
treebd7010dde6a1ee8f4ea9b1557cdf154a372fd564 /distribute_setup.py
parent9ebbe014df37c19976a5a9cb0ac2fa228a03144a (diff)
downloadexternal_python_setuptools-dbc8208b379835ee43224e83829b41790347e1e2.tar.gz
external_python_setuptools-dbc8208b379835ee43224e83829b41790347e1e2.tar.bz2
external_python_setuptools-dbc8208b379835ee43224e83829b41790347e1e2.zip
Use 'optparse' module to parse command line arguments.
--HG-- branch : distribute extra : rebase_source : 09f901daf15d650d2b2c5f620ef3660d78e5e4b7
Diffstat (limited to 'distribute_setup.py')
-rw-r--r--distribute_setup.py24
1 files changed, 15 insertions, 9 deletions
diff --git a/distribute_setup.py b/distribute_setup.py
index f3199d12..5b10f1ef 100644
--- a/distribute_setup.py
+++ b/distribute_setup.py
@@ -19,6 +19,7 @@ import time
import fnmatch
import tempfile
import tarfile
+import optparse
from distutils import log
try:
@@ -495,22 +496,27 @@ def _extractall(self, path=".", members=None):
self._dbg(1, "tarfile: %s" % e)
-def _build_install_args(argv):
+def _build_install_args(user_install):
install_args = []
- user_install = '--user' in argv
- if user_install and sys.version_info < (2, 6):
- log.warn("--user requires Python 2.6 or later")
- raise SystemExit(1)
if user_install:
- install_args.append('--user')
+ if sys.version_info < (2, 6):
+ log.warn("--user requires Python 2.6 or later")
+ raise SystemExit(1)
+ else:
+ install_args.append('--user')
return install_args
-def main(argv, version=DEFAULT_VERSION):
+def main(version=DEFAULT_VERSION):
"""Install or upgrade setuptools and EasyInstall"""
+ 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)')
+ options, args = parser.parse_args()
tarball = download_setuptools()
- _install(tarball, _build_install_args(argv))
+ _install(tarball, _build_install_args(options.user_install))
if __name__ == '__main__':
- main(sys.argv[1:])
+ main()