import re


def filenameToRequirement(filename):
    """Converts 'package-name-1.2.3.tar.gz' to 'package-name==1.2.3'"""
    match = re.match(r'(.+)-(\d.+?)(\.tar\.gz|\.tar\.bz2|\.zip)$', filename)
    if not match:
        return None
    package, version, _extension = match.groups()
    return '{package}=={version}'.format(package=package, version=version)