Changeset 78

Show
Ignore:
Timestamp:
06/25/06 06:18:53 (2 years ago)
Author:
mk
Message:

Fixed installation index bugs.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/mk/cheesecake/cheesecake_index.py

    r77 r78  
    2727from util import pad_with_dots, pad_left_spaces, pad_right_spaces, pad_msg, pad_line 
    2828from util import run_cmd, command_successful 
    29 from util import unzip_package, untar_package 
     29from util import unzip_package, untar_package, unegg_package 
    3030from util import mkdirs 
    3131from util import StdoutRedirector 
     
    526526    distance_penalty = -5 
    527527 
    528     def compute(self, package, found_on_cheeseshop, distance_from_pypi, download_url): 
     528    def compute(self, package, found_on_cheeseshop, found_locally, distance_from_pypi, download_url): 
    529529        if download_url: 
    530530            self.value = self.max_value 
     
    545545                self.details += " directly from the Cheese Shop" 
    546546        else: 
     547            if found_locally: 
     548                self.details = "found on local filesystem" 
    547549            self.value = 0 
    548550 
     
    840842            "tgz": untar_package, 
    841843            "zip": unzip_package, 
    842             "egg": unzip_package, 
     844            "egg": unegg_package, 
    843845        } 
    844846 
     
    992994          found_on_cheeseshop : bool 
    993995              Whenever package has been found on CheeseShop. 
     996          found_locally : bool 
     997              Whenever package has been already installed. 
    994998        """ 
    995999        self.log.info("Trying to download package %s from PyPI using setuptools utilities" % self.name) 
     
    10471051        self.distance_from_pypi = 0 
    10481052        self.found_on_cheeseshop = False 
    1049  
    1050         for line in captured_stdout.split('\n'): 
     1053        self.found_locally = False 
     1054 
     1055        for line in captured_stdout.splitlines(): 
    10511056            s = re.search(r"Reading http(.*)", line) 
    10521057            if s: 
     
    10631068        self.package = self.get_package_from_path(output) 
    10641069        self.log.info("Downloaded package %s from %s" % (self.package, self.download_url)) 
     1070 
     1071        if os.path.isdir(self.sandbox_pkg_file): 
     1072            self.found_locally = True 
    10651073 
    10661074        if re.search(r"cheeseshop.python.org", self.download_url): 
     
    12031211                           {'sandbox': self.sandbox_install_dir}} 
    12041212            rc, output = run_cmd("easy_install --no-deps --prefix %s %s" % \ 
    1205                                  (self.sandbox_install_dir, self.sandbox_pkg_file), 
     1213                                 (self.sandbox_install_dir, 
     1214                                  self.sandbox_pkg_file), 
    12061215                                 environment) 
    12071216        else: 
    1208             if os.path.isdir(self.package_name): 
    1209                 package_dir = os.path.join(self.sandbox, self.package_name) 
    1210             else: 
     1217            package_dir = os.path.join(self.sandbox, self.package_name) 
     1218            if not os.path.isdir(package_dir): 
    12111219                package_dir = self.sandbox 
    12121220            cwd = os.getcwd() 
    12131221            os.chdir(package_dir) 
    1214             rc, output = run_cmd("python setup.py install --root=" + self.sandbox_install_dir) 
     1222            rc, output = run_cmd("python setup.py install --root=%s" % \ 
     1223                                 self.sandbox_install_dir) 
    12151224            os.chdir(cwd) 
    12161225 
     
    12211230            self.log('*** End of captured output.') 
    12221231        else: 
     1232            self.log('Installation into %s successful.' % \ 
     1233                     self.sandbox_install_dir) 
    12231234            self.installed = True 
    12241235 
  • branches/mk/cheesecake/util.py

    r75 r78  
    11import os 
     2import shutil 
    23import sys 
    34import tarfile 
     
    149150    return tarinfo.name.split(os.sep)[0] 
    150151 
     152def unegg_package(package, destination): 
     153    """Unpack given egg to the `destination` directory. 
     154 
     155    Return name of unpacked directory or None on error. 
     156    """ 
     157    if os.path.isdir(package): 
     158        package_name = os.path.basename(package) 
     159        destination = os.path.join(destination, package_name) 
     160        shutil.copytree(package, destination, symlinks=True) 
     161        return package_name 
     162    else: 
     163        return unzip_package(package, destination) 
     164 
    151165def mkdirs(dir): 
    152166    """Make directory with parent directories as needed.