Changeset 78
- Timestamp:
- 06/25/06 06:18:53 (2 years ago)
- Files:
-
- branches/mk/cheesecake/cheesecake_index.py (modified) (9 diffs)
- branches/mk/cheesecake/util.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/mk/cheesecake/cheesecake_index.py
r77 r78 27 27 from util import pad_with_dots, pad_left_spaces, pad_right_spaces, pad_msg, pad_line 28 28 from util import run_cmd, command_successful 29 from util import unzip_package, untar_package 29 from util import unzip_package, untar_package, unegg_package 30 30 from util import mkdirs 31 31 from util import StdoutRedirector … … 526 526 distance_penalty = -5 527 527 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): 529 529 if download_url: 530 530 self.value = self.max_value … … 545 545 self.details += " directly from the Cheese Shop" 546 546 else: 547 if found_locally: 548 self.details = "found on local filesystem" 547 549 self.value = 0 548 550 … … 840 842 "tgz": untar_package, 841 843 "zip": unzip_package, 842 "egg": un zip_package,844 "egg": unegg_package, 843 845 } 844 846 … … 992 994 found_on_cheeseshop : bool 993 995 Whenever package has been found on CheeseShop. 996 found_locally : bool 997 Whenever package has been already installed. 994 998 """ 995 999 self.log.info("Trying to download package %s from PyPI using setuptools utilities" % self.name) … … 1047 1051 self.distance_from_pypi = 0 1048 1052 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(): 1051 1056 s = re.search(r"Reading http(.*)", line) 1052 1057 if s: … … 1063 1068 self.package = self.get_package_from_path(output) 1064 1069 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 1065 1073 1066 1074 if re.search(r"cheeseshop.python.org", self.download_url): … … 1203 1211 {'sandbox': self.sandbox_install_dir}} 1204 1212 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), 1206 1215 environment) 1207 1216 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): 1211 1219 package_dir = self.sandbox 1212 1220 cwd = os.getcwd() 1213 1221 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) 1215 1224 os.chdir(cwd) 1216 1225 … … 1221 1230 self.log('*** End of captured output.') 1222 1231 else: 1232 self.log('Installation into %s successful.' % \ 1233 self.sandbox_install_dir) 1223 1234 self.installed = True 1224 1235 branches/mk/cheesecake/util.py
r75 r78 1 1 import os 2 import shutil 2 3 import sys 3 4 import tarfile … … 149 150 return tarinfo.name.split(os.sep)[0] 150 151 152 def 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 151 165 def mkdirs(dir): 152 166 """Make directory with parent directories as needed.
