Mercurial > hg > PaInt
changeset 34:acb2f4896291
working towards something
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Fri, 30 Mar 2012 14:18:09 -0700 |
parents | 5efb61fde8aa |
children | e8d73f9e99fb |
files | paint/package.py |
diffstat | 1 files changed, 33 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/paint/package.py Fri Mar 30 13:43:23 2012 -0700 +++ b/paint/package.py Fri Mar 30 14:18:09 2012 -0700 @@ -37,7 +37,7 @@ # TODO: list of temporary files/directories to be deleted - def path(self): + def _path(self): """filesystem path to package directory""" # return cached copy if it exists @@ -116,7 +116,7 @@ # return cached copy return self._egg_info_path - directory = self.path() + directory = self._path() setup_py = os.path.join(directory, 'setup.py') if not os.path.exists(setup_py): raise AssertionError("%s does not exist" % setup_py) @@ -159,7 +159,6 @@ # TODO: should probably have a more detailed dict: # {'mozinfo': {'version': '>= 0.2', # 'url': 'http://something.com/'}} - # get the egg_info directory egg_info = self._egg_info() @@ -186,15 +185,45 @@ def extension(self): """filename extension""" + raise NotImplementedError("TODO") - def repackage(self, destination): + def repackage(self, destination=None): """ repackage the package to ensure its actually in the right form + and return the path to the destination + - destination: if given, path to put the build in [TODO] """ if self._build_path: + if destination: + shutil.copy(self._build_path, destination) + return os.path.abspath(destination) + + # return cached copy return self._build_path + path = self._path() + dist = os.path.join(path, 'dist') + if os.path.exists(dist): + shutil.rmtree(dist) + + call([sys.executable, 'setup.py', 'sdist'], cwd=path, stdout=subprocess.PIPE) + + assert os.path.exists(dist) + contents = os.listdir(dist) + assert len(contents) == 1 + + self._build_path = os.path.join(dist, contents[0]) + + # destination + # use an evil recursive trick + return self.repackage(destination=destination) + if destination: + shutil.copy(self._build_path, destination) + return destination + + return self._build_path + def download(self, directory): """download a package and all its dependencies using pip""" if not os.path.exists(directory):