def install_package(
        package_name,
        package_version=None,
        service_name=None,
        options_file=None,
        options_json=None,
        wait_for_completion=False,
        timeout_sec=600,
        expected_running_tasks=0
):
    """ Install a package via the DC/OS library

        :param package_name: name of the package
        :type package_name: str
        :param package_version: version of the package (defaults to latest)
        :type package_version: str
        :param service_name: unique service name for the package
        :type service_name: str
        :param options_file: filename that has options to use and is JSON format
        :type options_file: str
        :param options_json: dict that has options to use and is JSON format
        :type options_json: dict
        :param wait_for_completion: whether or not to wait for the app's deployment to complete
        :type wait_for_completion: bool
        :param timeout_sec: number of seconds to wait for task completion
        :type timeout_sec: int
        :param expected_running_tasks: number of service tasks to check for, or zero to disable
        :type expected_task_count: int

        :return: True if installation was successful, False otherwise
        :rtype: bool
    """

    start = time.time()

    if options_file:
        options = _get_options(options_file)
    elif options_json:
        options = options_json
    else:
        options = {}

    package_manager = _get_package_manager()
    pkg = package_manager.get_package_version(package_name, package_version)

    if package_version is None:
        # Get the resolved version for logging below
        package_version = 'auto:{}'.format(pkg.version())

    if service_name is None:
        # Get the service name from the marathon template
        try:
            labels = pkg.marathon_json(options).get('labels')
            if 'DCOS_SERVICE_NAME' in labels:
                service_name = labels['DCOS_SERVICE_NAME']
        except errors.DCOSException as e:
            pass

    print('\n{}installing {} with service={} version={} options={}'.format(
        shakedown.cli.helpers.fchr('>>'), package_name, service_name, package_version, options))

    try:
        # Print pre-install notes to console log
        pre_install_notes = pkg.package_json().get('preInstallNotes')
        if pre_install_notes:
            print(pre_install_notes)

        package_manager.install_app(pkg, options, service_name)

        # Print post-install notes to console log
        post_install_notes = pkg.package_json().get('postInstallNotes')
        if post_install_notes:
            print(post_install_notes)

        # Optionally wait for the app's deployment to finish
        if wait_for_completion:
            print("\n{}waiting for {} deployment to complete...".format(
                shakedown.cli.helpers.fchr('>>'), service_name))
            if expected_running_tasks > 0 and service_name is not None:
                wait_for_service_tasks_running(service_name, expected_running_tasks, timeout_sec)

            app_id = pkg.marathon_json(options).get('id')
            shakedown.deployment_wait(timeout_sec, app_id)
            print('\n{}install completed after {}\n'.format(
                shakedown.cli.helpers.fchr('>>'), pretty_duration(time.time() - start)))
        else:
            print('\n{}install started after {}\n'.format(
                shakedown.cli.helpers.fchr('>>'), pretty_duration(time.time() - start)))
    except errors.DCOSException as e:
        print('\n{}{}'.format(
            shakedown.cli.helpers.fchr('>>'), e))

    # Install subcommands (if defined)
    if pkg.cli_definition():
        print("{}installing CLI commands for package '{}'".format(
            shakedown.cli.helpers.fchr('>>'), package_name))
        subcommand.install(pkg)

    return True