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 raises an exception while getting dependencies #390

Open
brentVilla opened this issue Feb 24, 2017 · 1 comment
Open

rez-pip raises an exception while getting dependencies #390

brentVilla opened this issue Feb 24, 2017 · 1 comment
Labels
bug rez-pip ingesting py pkgs into rez (pip, wheels, etc)

Comments

@brentVilla
Copy link

First the basics:

  • Rez version: 2.4.1
  • Platform: Linux (Red Hat Enterprise v6.8 64-bit)
  • Command/reproduction: rez-pip -i python-dateutil

On certain installations using rez-pip, I get an AttributeError exception citing "'NoneType' object has no attribute 'lower'". The stacktrace is this:

Traceback (most recent call last):
  File "/rel/third_party/rez/2.4.1/bin/rez/rez-pip", line 4, in <module>
    run('pip')
  File "/rel/third_party/rez/2.4.1/lib/python2.7/site-packages/rez-2.4.1-py2.7.egg/rez/cli/_main.py", line 117, in run
    returncode = run_cmd()
  File "/rel/third_party/rez/2.4.1/lib/python2.7/site-packages/rez-2.4.1-py2.7.egg/rez/cli/_main.py", line 109, in run_cmd
    return opts.func(opts, opts.parser, arg_groups[1:])
  File "/rel/third_party/rez/2.4.1/lib/python2.7/site-packages/rez-2.4.1-py2.7.egg/rez/cli/pip.py", line 46, in command
    release=opts.release)
  File "/rel/third_party/rez/2.4.1/lib/python2.7/site-packages/rez-2.4.1-py2.7.egg/rez/pip.py", line 262, in pip_install_package
    requirements.extend(_get_dependencies(requirement, distributions))
  File "/rel/third_party/rez/2.4.1/lib/python2.7/site-packages/rez-2.4.1-py2.7.egg/rez/pip.py", line 74, in _get_dependencies
    name = get_distrubution_name(name)
  File "/rel/third_party/rez/2.4.1/lib/python2.7/site-packages/rez-2.4.1-py2.7.egg/rez/pip.py", line 47, in get_distrubution_name
    pip_to_rez_name = pip_name.lower().replace("-", "_")
AttributeError: 'NoneType' object has no attribute 'lower'

Here's what I've been able to observe. The InstallMode._get_dependencies method in rez/pip.py is called with requirement=u'six (>=1.5)' and distributions=[<EggInfoDistribution u'python-dateutil' 2.6.0>]. On line #62, the local "name" variable is set to None because get_distribution_name never gets a match on line #50 because "six" != "python-dateutil" and hence that return line on #51 isn't executed. When get_distribution_name is called again on line #74, that function tries to call the lower() method on that None object and fails.

Some ideas on how to fix this, but take them with a grain of salt since I'm new to this codebase:

  1. If a match between the distribution name and the requirement name isn't found in get_distribution_name, instead of returning None, just pass through the pip_to_rez_name value.
  2. Maybe the distributions list is incomplete. If there should be an EggInfoDistribution object in the distributions list for each requirement, we need to figure out why that isn't happening in some cases.
@bpabel
Copy link
Contributor

bpabel commented Feb 28, 2017

I'm guessing this is likely being caused by some legacy idiosyncrasies in how PyPi indexes its python packages. There are many cases where the "PyPi package name" doesn't match the actual installed "package name" (especially for any package that contains a dash ("-") in the name). In this case, it's likely trying to match the python-dateutil package and can't find it because it's been installed as python_dateutil or just dateutil.

I ran into the same problem and ended up writing my own pip rez package maker script. It uses a python library called pipdeptree to get dependencies and match up installed package names to the PyPi index name.

If I get some time, I'll try to merge it into the official rez pip and submit a Pull Request.

@JeanChristopheMorinPerso JeanChristopheMorinPerso added bug rez-pip ingesting py pkgs into rez (pip, wheels, etc) labels Mar 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug rez-pip ingesting py pkgs into rez (pip, wheels, etc)
Projects
None yet
Development

No branches or pull requests

3 participants