import copy


def v3_to_v2_package(v3_package):
    """Converts a v3 package to a v2 package

    :param v3_package: a v3 package
    :type v3_package: dict
    :return: a v2 package
    :rtype: dict
    """
    package = copy.deepcopy(v3_package)

    package.pop('minDcosReleaseVersion', None)
    package['packagingVersion'] = "2.0"
    resource = package.get('resource', None)
    if resource:
        cli = resource.pop('cli', None)
        if cli and 'command' not in package:
            print(('WARNING: Removing binary CLI from ({}, {}) without a '
                  'Python CLI').format(package['name'], package['version']))

    return package