from ast import literal_eval
import re


def get_setup_py_install_requires(content):
    """
    Extract 'install_requires' value using regex from 'content',
    function will return a list of python packages:
    ['package_a', 'package_b==1.5.6', 'package_c>=3.0']

    :param content: the content of a setup.py file
    :return: list on strings, install_requires values as list
    """
    # use DOTALL https://docs.python.org/3/library/re.html#re.DOTALL to include new lines
    regex_install_requires_pattern = re.compile(r"install_requires=(.*?)],", flags=re.DOTALL)
    version_match = regex_install_requires_pattern.findall(content)

    if len(version_match) > 1:
        raise RuntimeError("More than one 'install_requires' found: {0}".format(version_match))
    if not version_match:
        # 'install_requires' missing from setup.py file, just return empty array
        return []

    # add ending ']' since regex will not include it
    found_install_requires = version_match[0] + ']'

    # convert found_install_requires values into an array and return
    return literal_eval(found_install_requires)