def _get_version(filename): ## A bit hacky but there is no solution because some packages ## are in the form {package_name}-{version}-{something_else}-{?pyx.y}.{ext} ## and we cannot predict where is the version in that mess. _version_re = re.compile(r'\d[\.\d\w]*') parts = name(filename).split('-') for part in parts: match = _version_re.search(part) if match is not None: return match.group()
def _download(self, dir, req): ''' Given a destination directory and a requirement to meet, download it and return the archive path. ''' manager = ReqManager(req, ('.tar.gz', '.tar.bz2', '.zip')) manager.download(dir) d_name, version = manager.downloaded_name, manager.downloaded_version arch_name = os.path.join(dir, d_name) unpack(arch_name) self.bundled.append('{0}=={1}'.format(name(d_name).split('-')[0], version)) return arch_name