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

Fix for issue #819 - adding ability to deal with pip packages installed via git #840

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/rosdep2/platforms/pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,12 @@ def pip_detect(pkgs, exec_fn=None):
pip_cmd = get_pip_command()
if not pip_cmd:
return []


pkg_names = {}
for pkg in pkgs:
short_name = pkg.split('#egg=')[1] if '#egg=' in pkg else pkg
pkg_names[short_name] = pkg

fallback_to_pip_show = False
if exec_fn is None:
exec_fn = read_stdout
Expand All @@ -96,16 +101,16 @@ def pip_detect(pkgs, exec_fn=None):
ret_list = []
for pkg in pkg_list:
pkg_row = pkg.split('==')
if pkg_row[0] in pkgs:
ret_list.append(pkg_row[0])
if pkg_row[0] in pkg_names:
ret_list.append(pkg_names[pkg_row[0]])

# Try to detect with the return code of `pip show`.
# This can show the existance of things like `argparse` which
# otherwise do not show up.
# See:
# https://github.com/pypa/pip/issues/1570#issuecomment-71111030
if fallback_to_pip_show:
for pkg in [p for p in pkgs if p not in ret_list]:
for pkg in [p for p in pkg_names if p not in ret_list]:
# does not see retcode but stdout for old pip to check if installed
proc = subprocess.Popen(
pip_cmd + ['show', pkg],
Expand All @@ -116,7 +121,7 @@ def pip_detect(pkgs, exec_fn=None):
output = output.strip()
if proc.returncode == 0 and output:
# `pip show` detected it, add it to the list.
ret_list.append(pkg)
ret_list.append(pkg_names[pkg])

return ret_list

Expand Down