<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def install_package(package, wheels_path, venv=None, requirement_files=None, upgrade=False, install_args=None):
 """Install a Python package. Can specify a specific version. Can specify a prerelease. Can specify a venv to install in. Can specify a list of paths or urls to requirement txt files. Can specify a local wheels_path to use for offline installation. Can request an upgrade. """

    requirement_files = requirement_files or []

    logger.info('Installing %s...', package)
    if venv and not os.path.isdir(venv):
        raise WagonError('virtualenv {0} does not exist'.format(venv))

    pip_command = _construct_pip_command(
        package,
        wheels_path,
        venv,
        requirement_files,
        upgrade,
        install_args)

    if IS_VIRTUALENV and not venv:
        logger.info('Installing within current virtualenv')

    result = _run(pip_command)
    if not result.returncode == 0:
        raise WagonError('Could not install package: {0} ({1})'.format(
            package, result.aggr_stderr))