def install_from_source(mongodb_version, mongodb_edition, build_threads=None,
                        build_tmp_dir=None):
    """

    :param version:
    :param ssl:
    :param repo_name: The repo to use to generate archive name
    :return:
    """

    version_info = make_version_info(mongodb_version, mongodb_edition)

    if build_tmp_dir:
        ensure_dir(build_tmp_dir)
        os.chdir(build_tmp_dir)

    allowed_build_editions = [MongoDBEdition.COMMUNITY,
                              MongoDBEdition.COMMUNITY_SSL]
    if mongodb_edition not in allowed_build_editions:
        raise MongoctlException("build is only allowed for %s editions" %
                                allowed_build_editions)

    log_info("Installing MongoDB '%s %s' from source" % (mongodb_version,
                                                         mongodb_edition))
    source_archive_name = "r%s.tar.gz" % mongodb_version

    target_dir = get_install_target_dir(mongodb_version, mongodb_edition)

    source_url = ("https://github.com/mongodb/mongo/archive/%s" %
                  source_archive_name)

    response = urllib.urlopen(source_url)

    if response.getcode() != 200:
        msg = ("Unable to find a mongodb release for version '%s' in MongoDB"
               " github repo. See https://github.com/mongodb/mongo/releases "
               "for possible releases (response code '%s'). " %
               (mongodb_version, response.getcode()))
        raise MongoctlException(msg)

    log_info("Downloading MongoDB '%s' source from github '%s' ..." %
             (mongodb_version, source_url))

    download_url(source_url)

    log_info("Extract source archive ...")

    source_dir = extract_archive(source_archive_name)

    log_info("Building with scons!")

    scons_exe = which("scons")
    if not scons_exe:
        raise MongoctlException("scons command not found in your path")


    scons_cmd = [scons_exe, "core", "tools", "install"]
    if build_threads:
        scons_cmd.extend(["-j", str(build_threads)])

    scons_cmd.append("--prefix=%s" % target_dir)

    if mongodb_edition == MongoDBEdition.COMMUNITY_SSL:
        validate_openssl()
        scons_cmd.append("--ssl")

    log_info("Running scons command: %s" % " ".join(scons_cmd))

    call_command(scons_cmd, cwd=source_dir)

    # cleanup
    log_info("Cleanup")
    try:
        os.remove(source_archive_name)
        shutil.rmtree(source_dir)

    except Exception, e:
        log_error(str(e))
        log_exception(e)

    # install validation
    validate_mongodb_install(target_dir)
    log_info("MongoDB %s installed successfully!" % version_info)

###############################################################################
dataset/ETHPy150Open mongolab/mongoctl/mongoctl/commands/misc/install.py/install_from_source/original