Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
huntfx opened this issue Nov 25, 2021 · 4 comments
Closed

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

huntfx opened this issue Nov 25, 2021 · 4 comments

Comments

@huntfx
Copy link

huntfx commented Nov 25, 2021

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?

@johhnry
Copy link

johhnry commented Nov 26, 2021

Hi,

I have the exact same issue with Rez 2.100.0 on Ubuntu with Python 3.7.9:

$ rez pip -i typing_extensions
21:58:14 INFO     Trying to use pip from python package
21:58:15 INFO     Trying to use pip from pip package
21:58:15 WARNING  Found no pip in any python and/or pip rez packages!
21:58:15 WARNING  Falling back to pip installed in rez own virtualenv:
21:58:15 WARNING         pip: 21.3.1 (/home/josephhenry/rez/lib/python3.7/site-packages/pip/__init__.py)
21:58:15 WARNING      python: 3.7.9 (/home/josephhenry/rez/bin/python)
21:58:15 INFO     Installing 'typing_extensions' with pip taken from '/home/josephhenry/rez/bin/python'
Collecting typing_extensions
  Using cached typing_extensions-4.0.0-py3-none-any.whl (22 kB)
Installing collected packages: typing-extensions
Successfully installed typing-extensions-4.0.0
21:58:16 WARNING  Metadata: missing: ['Home-page', 'Author'], warnings: []
Traceback (most recent call last):
  File "/home/josephhenry/rez/bin/rez/rez", line 8, in <module>
    sys.exit(run_rez())
  File "/home/josephhenry/rez/lib/python3.7/site-packages/rez/cli/_entry_points.py", line 80, in run_rez
    return run()
  File "/home/josephhenry/rez/lib/python3.7/site-packages/rez/cli/_main.py", line 202, in run
    returncode = run_cmd()
  File "/home/josephhenry/rez/lib/python3.7/site-packages/rez/cli/_main.py", line 194, in run_cmd
    return func(opts, opts.parser, extra_arg_groups)
  File "/home/josephhenry/rez/lib/python3.7/site-packages/rez/cli/pip.py", line 84, in command
    extra_args=opts.extra)
  File "/home/josephhenry/rez/lib/python3.7/site-packages/rez/pip.py", line 357, in pip_install_package
    name_casings=dist_names
  File "/home/josephhenry/rez/lib/python3.7/site-packages/rez/utils/pip.py", line 396, in get_rez_requirements
    is_pure_python = is_pure_python_package(installed_dist)
  File "/home/josephhenry/rez/lib/python3.7/site-packages/rez/utils/pip.py", line 338, in is_pure_python_package
    wheel_data = setuptools_dist.get_metadata('WHEEL')
AttributeError: 'NoneType' object has no attribute 'get_metadata'

@johhnry
Copy link

johhnry commented Dec 1, 2021

The error also appear on Rez 2.95.0:

~ » rez --version
Rez 2.95.0

~ » rez pip -i typing_extensions
00:08:00 INFO     Trying to use pip from python package
00:08:00 INFO     Trying to use pip from pip package
00:08:00 WARNING  Found no pip in any python and/or pip rez packages!
00:08:00 WARNING  Falling back to pip installed in rez own virtualenv:
00:08:00 WARNING         pip: 20.1.1 (/home/josephhenry/rez/lib/python3.7/site-packages/pip/__init__.py)
00:08:00 WARNING      python: 3.7.9 (/home/josephhenry/rez/bin/python)
00:08:00 INFO     Installing 'typing_extensions' with pip taken from '/home/josephhenry/rez/bin/python'
Collecting typing_extensions
  Using cached typing_extensions-4.0.1-py3-none-any.whl (22 kB)
Installing collected packages: typing-extensions
Successfully installed typing-extensions-4.0.1
WARNING: You are using pip version 20.1.1; however, version 21.3.1 is available.
You should consider upgrading via the '/home/josephhenry/rez/bin/python -m pip install --upgrade pip' command.
00:08:01 WARNING  Metadata: missing: ['Home-page', 'Author'], warnings: []
Traceback (most recent call last):
  File "/home/josephhenry/rez/bin/rez/rez", line 8, in <module>
    sys.exit(run_rez())
  File "/home/josephhenry/rez/lib/python3.7/site-packages/rez/cli/_entry_points.py", line 65, in run_rez
    return run()
  File "/home/josephhenry/rez/lib/python3.7/site-packages/rez/cli/_main.py", line 184, in run
    returncode = run_cmd()
  File "/home/josephhenry/rez/lib/python3.7/site-packages/rez/cli/_main.py", line 176, in run_cmd
    return func(opts, opts.parser, extra_arg_groups)
  File "/home/josephhenry/rez/lib/python3.7/site-packages/rez/cli/pip.py", line 69, in command
    extra_args=opts.extra)
  File "/home/josephhenry/rez/lib/python3.7/site-packages/rez/pip.py", line 342, in pip_install_package
    name_casings=dist_names
  File "/home/josephhenry/rez/lib/python3.7/site-packages/rez/utils/pip.py", line 380, in get_rez_requirements
    is_pure_python = is_pure_python_package(installed_dist)
  File "/home/josephhenry/rez/lib/python3.7/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 am unable to install aiohttp with rez-pip

@nerdvegas
Copy link
Contributor

thanks for highlighting this, will have a look soon

@johhnry
Copy link

johhnry commented Dec 11, 2021

@nerdvegas Thank you it works now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants