def bootstrap(config_file, git=False):
    current_dir = os.path.abspath(os.path.dirname(__file__))
    branch_name = git if type(git) is str else "master"
    branch_url = "{}{}/".format(RAW_URL, branch_name)

    if os.path.exists(os.path.join(current_dir, "pimlico")):
        print("Pimlico source directory already exists: delete it if you want to fetch again")
        sys.exit(1)

    # Check the config file to find the version of Pimlico we need
    version = find_config_value(config_file, "release")
    if version is None:
        print("Could not find Pimlico release in config file %s" % config_file)
        sys.exit(1)
    major_version = int(version.partition(".")[0])
    print("Config file requires Pimlico version {}".format(version))

    available_releases = lookup_pimlico_versions()
    bleeding_edge = lookup_bleeding_edge(branch_url)
    tags = available_releases

    # If the bleeding edge version is compatible (same major version) just use that
    if int(bleeding_edge.lstrip("v").partition(".")[0]) == major_version:
        print("Bleeding edge ({}) is compatible".format(bleeding_edge))
        fetch_release = "master"
    else:
        if git:
            print("Error: tried to clone the Git repo instead of fetching a release, but config file is not " \
                  "compatible with latest Pimlico version")
            sys.exit(1)
        # Find the latest release that has the same major version
        compatible_tags = [t for t in tags if int(t.lstrip("v").partition(".")[0]) == major_version]
        fetch_release = compatible_tags[-1]
        print("Fetching latest release of major version {}, which is {}".format(major_version, fetch_release))

    if git:
        # Clone the latest version of the code from the Git repository
        # Allow the git kwarg to name a branch to clone
        if type(git) is str:
            args = "--branch {} ".format(git)
        else:
            args = ""
        print("Cloning git repository ({})".format("{} branch".format(git) if type(git) is str else "master"))
        import subprocess
        subprocess.check_call("git clone {}{}".format(args, GIT_URL), shell=True)
    else:
        archive_url = "%s%s.tar.gz" % (DOWNLOAD_URL, fetch_release)
        print("Downloading Pimlico source code from {}".format(archive_url))
        tar_download_path = os.path.join(current_dir, "archive.tar.gz")
        with open(tar_download_path, "wb") as archive_file:
            archive_file.write(urlopen(archive_url).read())

        print("Extracting source code")
        extracted_dirname = tar_dirname(tar_download_path)
        extract(tar_download_path)
        # Extracted source code: remove the archive
        os.remove(tar_download_path)

        os.rename(os.path.join(current_dir, extracted_dirname), os.path.join(current_dir, "pimlico"))
    print("Pimlico source (%s) is now available in directory pimlico/" % fetch_release)
    # Create symlink to pimlico.sh, so it's easier to run
    print("Creating symlink pimlico.sh for running Pimlico")
    symlink(os.path.join("pimlico", "bin", "pimlico.sh"), "pimlico.sh")