Mercurial > hg > PaInt
comparison paint/package.py @ 49:85374a69cf89
call in foreground to avoid hang :(
| author | Jeff Hammel <jhammel@mozilla.com> |
|---|---|
| date | Thu, 10 May 2012 15:24:51 -0700 |
| parents | abfb267e8332 |
| children | daa35ff485c2 |
comparison
equal
deleted
inserted
replaced
| 48:abfb267e8332 | 49:85374a69cf89 |
|---|---|
| 28 constructor takes the package 'src' | 28 constructor takes the package 'src' |
| 29 """ | 29 """ |
| 30 | 30 |
| 31 def __init__(self, src): | 31 def __init__(self, src): |
| 32 self.src = src | 32 self.src = src |
| 33 self.verbose = True | |
| 33 | 34 |
| 34 # ephemeral data | 35 # ephemeral data |
| 35 self._tmppath = None | 36 self._tmppath = None |
| 36 self._egg_info_path = None | 37 self._egg_info_path = None |
| 37 self._build_path = None | 38 self._build_path = None |
| 38 self._pkg_info_path = None | 39 self._pkg_info_path = None |
| 39 | 40 |
| 40 # TODO: list of temporary files/directories to be deleted | 41 # TODO: list of temporary files/directories to be deleted |
| 41 | 42 |
| 43 def _log(self, message): | |
| 44 if self.verbose: | |
| 45 print '>>> %s' % message | |
| 46 | |
| 42 def _path(self): | 47 def _path(self): |
| 43 """filesystem path to package directory""" | 48 """filesystem path to package directory""" |
| 44 | 49 |
| 45 print ">>> Getting path to package" | 50 print ">>> _path:Getting path to package" |
| 46 | 51 |
| 47 # return cached copy if it exists | 52 # return cached copy if it exists |
| 48 if self._tmppath: | 53 if self._tmppath: |
| 49 return self._tmppath | 54 return self._tmppath |
| 50 | 55 |
| 227 return dependencies | 232 return dependencies |
| 228 | 233 |
| 229 def extension(self): | 234 def extension(self): |
| 230 """filename extension of the package""" | 235 """filename extension of the package""" |
| 231 | 236 |
| 237 print ">>> extension:Getting package" | |
| 232 package = self.package() | 238 package = self.package() |
| 239 print ">>> extension:package=%s" % package | |
| 233 | 240 |
| 234 # determine the extension (XXX hacky) | 241 # determine the extension (XXX hacky) |
| 235 extensions = ('.tar.gz', '.zip', '.tar.bz2') | 242 extensions = ('.tar.gz', '.zip', '.tar.bz2') |
| 236 for ext in extensions: | 243 for ext in extensions: |
| 237 if package.endswith(ext): | 244 if package.endswith(ext): |
| 241 | 248 |
| 242 def package(self, destination=None): | 249 def package(self, destination=None): |
| 243 """ | 250 """ |
| 244 repackage the package to ensure its actually in the right form | 251 repackage the package to ensure its actually in the right form |
| 245 and return the path to the destination | 252 and return the path to the destination |
| 246 - destination: if given, path to put the build in [TODO] | 253 - destination: if given, path to put the build in |
| 247 """ | 254 """ |
| 255 | |
| 256 self._log("package: Getting package directory, destination=%s" % repr(destination)) | |
| 248 | 257 |
| 249 if self._build_path: | 258 if self._build_path: |
| 259 self._log("package: build_path already set: %s" % self._build_path) | |
| 250 if destination: | 260 if destination: |
| 251 shutil.copy(self._build_path, destination) | 261 shutil.copy(self._build_path, destination) |
| 252 return os.path.abspath(destination) | 262 return os.path.abspath(destination) |
| 253 | 263 |
| 254 # return cached copy | 264 # return cached copy |
| 255 return self._build_path | 265 return self._build_path |
| 256 | 266 |
| 257 path = self._path() | 267 path = self._path() |
| 258 dist = os.path.join(path, 'dist') | 268 dist = os.path.join(path, 'dist') |
| 269 self._log("package: dist directory: %s; (path=%s)" % (dist, path)) | |
| 259 if os.path.exists(dist): | 270 if os.path.exists(dist): |
| 260 shutil.rmtree(dist) | 271 shutil.rmtree(dist) |
| 261 | 272 |
| 262 call([sys.executable, 'setup.py', 'sdist'], cwd=path, stdout=subprocess.PIPE) | 273 command = [sys.executable, 'setup.py', 'sdist'] |
| 274 self._log("package: running: %s" % ' '.join(command)) | |
| 275 call(command, cwd=path) | |
| 276 self._log("package: done running setup.py dist") | |
| 263 | 277 |
| 264 assert os.path.exists(dist) | 278 assert os.path.exists(dist) |
| 265 contents = os.listdir(dist) | 279 contents = os.listdir(dist) |
| 266 assert len(contents) == 1 | 280 assert len(contents) == 1 |
| 267 | 281 |
