from pathlib import Path
import warnings


def parse_requirements(req_path: Path):
    """Parse requirements

    Args:
        req_path: path to requirements file

    Returns:
        list of requirement strings in form of "library" or "library==0.0.0"
    """

    # Parse requirements from file - no need to specify them many times
    # Any dependencies defined in includes are omitted.
    # Only dependencies in provided file are considered
    # This is intended behavior
    parsed_requirements = []
    with open(req_path) as f:
        for line in f:
            content = line.split("#")[0].strip()  # remove comments
            if "://" in content:  # URL
                warnings.warn(f"Ignoring '{content}' requirement. Setuptools does not support URLs.")
            elif len(content) > 0 and content[0] != '-':  # non empty and not a command
                parsed_requirements.append(content)

    return parsed_requirements