Mercurial > hg > PaInt
changeset 36:f59da9e6be37
this almost works, dammit
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Fri, 30 Mar 2012 14:44:12 -0700 |
parents | e8d73f9e99fb |
children | 36e70712fc9a |
files | paint/package.py |
diffstat | 1 files changed, 20 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/paint/package.py Fri Mar 30 14:24:20 2012 -0700 +++ b/paint/package.py Fri Mar 30 14:44:12 2012 -0700 @@ -2,6 +2,8 @@ package model for python PAckage INTrospection """ +# TODO: use pkginfo.sdist more + import os import pip import pypi @@ -191,7 +193,7 @@ # determine the extension (XXX hacky) extensions = ('.tar.gz', '.zip', '.tar.bz2') for ext in extensions: - if package.endsiwth(ext): + if package.endswith(ext): return ext raise Exception("Extension %s not found: %s" % (extensions, package)) @@ -226,10 +228,8 @@ # destination # use an evil recursive trick - return self.repackage(destination=destination) if destination: - shutil.copy(self._build_path, destination) - return destination + return self.package(destination=destination) return self._build_path @@ -259,41 +259,32 @@ # make a package of the thing package = Package(src) - # # get destination dirname, filename - # try: - # dirname, filename = pypi.pypi_path(src) - # except ValueError: - # # PKG-INFO not found - # pass # TODO + # get destination dirname, filename + dirname, filename = package.pypi_path() - # # make the directory if it doesn't exist - # subdir = os.path.join(directory, dirname) - # if not os.path.exists(subdir): - # os.makedirs(subdir) - # assert os.path.isdir(subdir) + # make the directory if it doesn't exist + subdir = os.path.join(directory, dirname) + if not os.path.exists(subdir): + os.makedirs(subdir) + assert os.path.isdir(subdir) - # # move the file - # shutil.move(src, os.path.join(subdir, filename)) + # move the file + self.package(destination=os.path.join(subdir, filename)) finally: shutil.rmtree(tempdir) - def pypi_path(self, path): + def pypi_path(self): """ returns subpath 2-tuple appropriate for pypi path structure: http://k0s.org/portfolio/pypi.html """ info = self.info() -# sdist = pkginfo.sdist.SDist(path) - # determine the extension (XXX hacky) - extensions = ('.tar.gz', '.zip', '.tar.bz2') - for ext in extensions: - import pdb; pdb.set_trace() - if sdist.filename.endswith(ext): - break - else: - + # determine the extension + extension = self.extension() # get the filename destination - filename = '%s-%s%s' % (info['name'], ext) - return sdist.name, filename + name = info['Name'] + version = info['Version'] + filename = '%s-%s%s' % (name, version, extension) + return name, filename