示例#1
0
文件: inst.py 项目: Malex/pyg
 def _find_develop(self, dir, req):
     try:
         logger.info('Looking for a local package...')
         try:
             dist = Develop(req.name)
         except (ValueError, AttributeError):
             logger.error('Cannot find a local distribution for {0}', req.name, exc=PygError)
         else:
             # XXX: Add a `location` attribute in pkgtools' next release
             location = os.path.abspath(dist._arg_name)
             path = os.path.dirname(location)
             if not req.match(Version(dist.version)):
                 logger.error('Found {0}, but it does not match the requirement', path, exc=PygError)
             setup_py = os.path.join(path, 'setup.py')
             if not os.path.exists(setup_py):
                 logger.error('Cannot find setup.py for {0}', req.name, exc=PygError)
             logger.info('Found a matching package in {0}', path)
             with TempDir() as tempdir:
                 code, output = call_setup(path, ['sdist', '-d', tempdir])
                 if code != 0:
                     logger.fatal('setup.py failed to create the source distribution')
                     print_output(output, 'setup.py sdist')
                     raise PygError
                 arch = glob.glob(os.path.join(tempdir, '*{0}*'.format(req.name)))[0]
                 shutil.move(arch, dir)
                 arch_name = os.path.join(dir, os.path.basename(arch))
                 unpack(arch_name)
                 return arch_name
     except (PygError, IndexError, ValueError):
         return False
示例#2
0
文件: inst.py 项目: fdev31/pyg
    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
示例#3
0
文件: _opts.py 项目: fdev31/pyg
def download_func(args):
    pref = None
    if args.prefer:
        pref = ['.' + args.prefer.strip('.')]
    name = args.packname
    dest = args_manager['download']['download_dir']
    unpk = args_manager['download']['unpack']
    downloader = ReqManager(Requirement(name), pref)
    downloader.download(dest)
    if downloader.downloaded_name is None:
        logger.fatal('Error: Did not find any files for {0}', name, exc=PygError)
    if unpk:
        path = os.path.abspath(downloader.downloaded_name)
        logger.info('Unpacking {0} to {1}', os.path.basename(path), os.getcwd())
        unpack(path)