AcademySoftwareFoundation / AcademySoftwareFoundation/rez

rez-pip raises an exception while getting dependencies

Open
#390 1 comment 0 reactions 0 assignees View on GitHub
bug rez-pip
Dominant language
Python
Stars
1.1k
Forks
369
Avg merge
12d 3h
Merged PRs (30d)
5

Description

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
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=[]. 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.

Contributor guide

Open the contributing guide

Research direction

Start in rez/pip.py with get_distribution_name and _get_dependencies, using the reported command `rez-pip -i python-dateutil` to reproduce the NoneType exception. Trace how the `six (>=1.5)` requirement and the distributions list are handled. Done means dependency processing no longer calls lower() on None and the command completes with the expected dependencies.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.