From ea1bb2bae51ce96bb43bc7d87f948672135bf5c8 Mon Sep 17 00:00:00 2001 From: UebelAndre Date: Fri, 17 Sep 2021 16:36:10 -0700 Subject: [PATCH] Avoid failing to parse requirements due to invalid entry points config. (#536) --- python/pip_install/extract_wheels/lib/wheel.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/python/pip_install/extract_wheels/lib/wheel.py b/python/pip_install/extract_wheels/lib/wheel.py index aa5b0ca2d3..a60efc6d9a 100644 --- a/python/pip_install/extract_wheels/lib/wheel.py +++ b/python/pip_install/extract_wheels/lib/wheel.py @@ -63,9 +63,18 @@ def entry_points(self) -> Dict[str, str]: # Parse the avaialble entry points config = configparser.ConfigParser() - config.read_string(whl.read(entry_points_path).decode("utf-8")) - if "console_scripts" in config.sections(): - return dict(config["console_scripts"]) + try: + config.read_string(whl.read(entry_points_path).decode("utf-8")) + if "console_scripts" in config.sections(): + return dict(config["console_scripts"]) + + # TODO: It's unclear what to do in a situation with duplicate sections or options. + # For now, we treat the config file as though it contains no scripts. For more + # details on the config parser, see: + # https://docs.python.org/3.7/library/configparser.html#configparser.ConfigParser + # https://docs.python.org/3.7/library/configparser.html#configparser.Error + except configparser.Error: + pass return dict()