Log warning when there's a problem parsing requirements
"""
from collections import namedtuple
+import logging
from pip._vendor.packaging.utils import canonicalize_name
from pip._vendor.pkg_resources import RequirementParseError
@@ -10,6 +11,8 @@ from pip._internal.operations.prepare import make_abstract_dist
from pip._internal.utils.misc import get_installed_distributions
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
+logger = logging.getLogger(__name__)
+
if MYPY_CHECK_RUNNING:
from pip._internal.req.req_install import InstallRequirement # noqa: F401
from typing import ( # noqa: F401
@@ -41,9 +44,9 @@ def create_package_set_from_installed(**kwargs):
name = canonicalize_name(dist.project_name)
try:
package_set[name] = PackageDetails(dist.version, dist.requires())
- except RequirementParseError:
+ except RequirementParseError as e:
# Don't crash on broken metadata
- pass # TODO: log a warning?
+ logging.warning("Error parsing requirements for %s: %s", name, e)
return package_set
