Mercurial > hg > carton
comparison carton.py @ 36:77285bafc36a
better formatting
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Mon, 09 Apr 2012 13:17:38 -0700 |
parents | 122c56779f2b |
children | 33e5d444ff30 |
comparison
equal
deleted
inserted
replaced
35:122c56779f2b | 36:77285bafc36a |
---|---|
95 if 'virtualenv.py' in files: | 95 if 'virtualenv.py' in files: |
96 virtualenv = os.path.join(root, 'virtualenv.py') | 96 virtualenv = os.path.join(root, 'virtualenv.py') |
97 break | 97 break |
98 else: | 98 else: |
99 raise Exception("virtualenv.py not found in " + tempdir) | 99 raise Exception("virtualenv.py not found in " + tempdir) |
100 | 100 |
101 # create the virtualenv | 101 # create the virtualenv |
102 os.environ.pop('PYTHONHOME', None) | 102 os.environ.pop('PYTHONHOME', None) |
103 call([sys.executable, virtualenv, ENV]) | 103 call([sys.executable, virtualenv, ENV]) |
104 | 104 |
105 # find the bin/scripts directory | 105 # find the bin/scripts directory |
179 call = subprocess.call | 179 call = subprocess.call |
180 | 180 |
181 def main(args=sys.argv[1:]): | 181 def main(args=sys.argv[1:]): |
182 | 182 |
183 # parse CLI arguments | 183 # parse CLI arguments |
184 class PlainDescriptionFormatter(optparse.IndentedHelpFormatter): | |
185 """description formatter for console script entry point""" | |
186 def format_description(self, description): | |
187 if description: | |
188 return description.strip() + '\n' | |
189 else: | |
190 return '' | |
184 parser = OptionParser(usage=usage, description=__doc__) | 191 parser = OptionParser(usage=usage, description=__doc__) |
185 parser.add_option('-o', dest='outfile', | 192 parser.add_option('-o', dest='outfile', |
186 help="specify outfile; otherwise it will come from environment_name") | 193 help="specify outfile; otherwise it will come from environment_name") |
187 parser.add_option('-p', '--package', dest='package', | 194 parser.add_option('-p', '--package', dest='package', |
188 action='store_true', default=False, | 195 action='store_true', default=False, |
228 # use the last modified tarball | 235 # use the last modified tarball |
229 def last_modified(filename): | 236 def last_modified(filename): |
230 return os.path.getmtime(os.path.join(dist_dir, filename)) | 237 return os.path.getmtime(os.path.join(dist_dir, filename)) |
231 tarfiles.sort(key=last_modified) | 238 tarfiles.sort(key=last_modified) |
232 source = os.path.join(dist_dir, tarfiles[-1]) | 239 source = os.path.join(dist_dir, tarfiles[-1]) |
233 | 240 |
234 if (not os.path.isdir(source)) and tarfile.is_tarfile(source): | 241 if (not os.path.isdir(source)) and tarfile.is_tarfile(source): |
235 # check for a tarball | 242 # check for a tarball |
236 buffer = file(source).read() | 243 buffer = file(source).read() |
237 else: | 244 else: |
238 # add other sources (files and directories) to the archive | 245 # add other sources (files and directories) to the archive |
241 source_tar.add(source, arcname=os.path.basename(source.rstrip(os.path.sep))) | 248 source_tar.add(source, arcname=os.path.basename(source.rstrip(os.path.sep))) |
242 source_tar.close() | 249 source_tar.close() |
243 buffer = source_buffer.getvalue() | 250 buffer = source_buffer.getvalue() |
244 | 251 |
245 # could use git, hg, etc repos. but probably shouldn't | 252 # could use git, hg, etc repos. but probably shouldn't |
246 | |
247 source_array.append(buffer.encode('zlib').encode('base64')) | 253 source_array.append(buffer.encode('zlib').encode('base64')) |
248 | 254 |
249 # tar up virtualenv if not available | 255 # tar up virtualenv if not available |
250 if options.virtualenv: | 256 if options.virtualenv: |
251 if isURL(options.virtualenv): | 257 if isURL(options.virtualenv): |