Exemple #1
0
def install_func(packname, req_file, editable, ignore, yes):
    check_and_exit()
    if editable:
        if len(packname) > 1:
            logger.error('Error: Unable to install multiple packages in editable mode')
            return
        package = packname[0]
        if os.path.exists(os.path.abspath(package)):
            package = 'dir+{0}#egg={1}'.format(os.path.abspath(package),
                                               os.path.basename(package))
        return vcs(package).develop()
    if req_file:
        logger.info('Installing from requirements file')
        for rq in req_file:
            Installer.from_req_file(os.path.abspath(rq))
        return
    if packname:
        for package in packname:
            _install_package_from_name(package, ignore)
Exemple #2
0
def _install_package_from_name(package, ignore=False):
    if os.path.exists(package) and not ignore:
        path = os.path.abspath(package)
        logger.info('Installing {0}', path)
        if os.path.isfile(path):
            return Installer.from_file(path)
        elif os.path.isdir(path):
            if not os.path.exists(os.path.join(path, 'setup.py')):
                raise PygError('{0} must contain the setup.py file', path)
            return Installer.from_dir(path)
        else:
            raise PygError('Cannot install the package: {0} is neither a file nor a directory', path)
    if package.startswith(('http://', 'https://')):
        return Installer.from_url(package)
    for s in ('git+', 'hg+', 'bzr+', 'svn+'):
        if package.startswith(s):
            with TempDir() as tempdir:
                return vcs(package, tempdir).install()
    return Installer(package).install()