Skip to content

rez-pip error with inconsistency between underscores and dashes #1159

Closed
@huntfx

Description

Version: Rez 2.97.0
OS: Windows 10
Python: 3.9.6

In trying to use rez-pip -i typing_extensions and rez-pip -i typing_inspect, I was getting this error:

Traceback (most recent call last):
  File "C:\Program Files\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Tools\Rez\Scripts\rez\rez-pip.exe\__main__.py", line 7, in <module>
  File "c:\tools\rez\lib\site-packages\rez\cli\_entry_points.py", line 179, in run_rez_pip
    return run("pip")
  File "c:\tools\rez\lib\site-packages\rez\cli\_main.py", line 187, in run
    returncode = run_cmd()
  File "c:\tools\rez\lib\site-packages\rez\cli\_main.py", line 179, in run_cmd
    return func(opts, opts.parser, extra_arg_groups)
  File "c:\tools\rez\lib\site-packages\rez\cli\pip.py", line 63, in command
    pip_install_package(
  File "c:\tools\rez\lib\site-packages\rez\pip.py", line 339, in pip_install_package
    rez_requires = get_rez_requirements(
  File "c:\tools\rez\lib\site-packages\rez\utils\pip.py", line 380, in get_rez_requirements
    is_pure_python = is_pure_python_package(installed_dist)
  File "c:\tools\rez\lib\site-packages\rez\utils\pip.py", line 323, in is_pure_python_package
    wheel_data = setuptools_dist.get_metadata('WHEEL')
AttributeError: 'NoneType' object has no attribute 'get_metadata'

I found that inside convert_distlib_to_setuptools, the check of setuptools_dist.key == installed_dist.key was not working. The results from pkg_resources.find_distributions had the name with a dash (typing-extensions), and was being compared to the name with an underscore (typing_extensions).

Doing a .replace('-', '_') on both of them fixed the check and let me do the pip installs, though that's obviously not a good fix.

If a fix is not possible, a custom error would be better, or perhaps if the is_pure_python check is not super important, could that default to True in the case of convert_distlib_to_setuptools returning None?

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions