Mercurial > hg > carton
comparison carton.py @ 15:f05e636b7444
now you can specify the name of the env in the created script
| author | Jeff Hammel <jhammel@mozilla.com> |
|---|---|
| date | Fri, 08 Jul 2011 15:35:53 -0700 |
| parents | c474362cf69a |
| children | c91abbdc871b |
comparison
equal
deleted
inserted
replaced
| 14:c474362cf69a | 15:f05e636b7444 |
|---|---|
| 24 # global variables | 24 # global variables |
| 25 usage = "%prog [options] environment_name directory|url [...]" | 25 usage = "%prog [options] environment_name directory|url [...]" |
| 26 virtualenv_url = 'http://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.6.1.tar.gz' | 26 virtualenv_url = 'http://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.6.1.tar.gz' |
| 27 template = """#!/usr/bin/env python | 27 template = """#!/usr/bin/env python |
| 28 | 28 |
| 29 "create a virtualenv at %(ENV)s" | |
| 30 | |
| 29 import os | 31 import os |
| 30 import shutil | 32 import shutil |
| 31 import subprocess | 33 import subprocess |
| 32 import sys | 34 import sys |
| 33 import tarfile | 35 import tarfile |
| 45 ENV='''%(ENV)s''' | 47 ENV='''%(ENV)s''' |
| 46 | 48 |
| 47 # packed files | 49 # packed files |
| 48 VIRTUAL_ENV='''%(VIRTUAL_ENV)s'''.decode('base64').decode('zlib') | 50 VIRTUAL_ENV='''%(VIRTUAL_ENV)s'''.decode('base64').decode('zlib') |
| 49 PACKAGE_SOURCES=%(PACKAGE_SOURCES)s | 51 PACKAGE_SOURCES=%(PACKAGE_SOURCES)s |
| 52 | |
| 53 # parse options | |
| 54 usage = os.path.basename(sys.argv[0]) + ' [options]' | |
| 55 parser = OptionParser(usage=usage, description=__doc__) | |
| 56 parser.add_option('--env', dest='env', help="environment name [DEFAULT: " + ENV + "]") | |
| 57 options, args = parser.parse_args() | |
| 58 if options.env: | |
| 59 ENV = options.env | |
| 50 | 60 |
| 51 # unpack virtualenv | 61 # unpack virtualenv |
| 52 tempdir = tempfile.mkdtemp() | 62 tempdir = tempfile.mkdtemp() |
| 53 buffer = StringIO() | 63 buffer = StringIO() |
| 54 buffer.write(VIRTUAL_ENV) | 64 buffer.write(VIRTUAL_ENV) |
