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 fails if the user has not run rez-bind for a specific Python version #1027

Open
ColinKennedy opened this issue Feb 15, 2021 · 2 comments
Labels
bug rez-pip ingesting py pkgs into rez (pip, wheels, etc)

Comments

@ColinKennedy
Copy link

Summary

It looks like, when rez-pip runs with a Python version, it attempts to resolve for that version + pip. And if a pip package exists, but not for that Python version, rez-pip fails midway instead of installing the PyPI package using a different resolve.

Reproduction Steps

cd rez
git checkout 2.72.0
python install.py -v ~/rez
export PATH=~/rez/bin/rez:$PATH
source ~/rez/completion/complete.sh
rez-bind python
rez-bind pip
rez-bind python --exe `which python3`  # In my case, Python 3.6
rez-pip --install parso --python-version=3.6

Error Encountered

Traceback (most recent call last):
  File "/home/selecaoone///rez-2.72.0-python-2.7/bin/rez/rez-pip", line 8, in <module>
    sys.exit(run_rez_pip())
  File "/home/selecaoone/rez-2.72.0-python-2.7/lib/python2.7/site-packages/rez/cli/_entry_points.py", line 178, in run_rez_pip
    return run("pip")
  File "/home/selecaoone/rez-2.72.0-python-2.7/lib/python2.7/site-packages/rez/cli/_main.py", line 170, in run
    returncode = run_cmd()
  File "/home/selecaoone/rez-2.72.0-python-2.7/lib/python2.7/site-packages/rez/cli/_main.py", line 162, in run_cmd
    return func(opts, opts.parser, extra_arg_groups)
  File "/home/selecaoone/rez-2.72.0-python-2.7/lib/python2.7/site-packages/rez/cli/pip.py", line 76, in command
    extra_args=opts.extra)
  File "/home/selecaoone/rez-2.72.0-python-2.7/lib/python2.7/site-packages/rez/pip.py", line 261, in pip_install_package
    py_exe, context = find_pip(pip_version, python_version)
  File "/home/selecaoone/rez-2.72.0-python-2.7/lib/python2.7/site-packages/rez/pip.py", line 95, in find_pip
    python_version, pip_version=version
  File "/home/selecaoone/rez-2.72.0-python-2.7/lib/python2.7/site-packages/rez/pip.py", line 203, in find_pip_from_context
    py_exe = find_python_in_context(context)
  File "/home/selecaoone/rez-2.72.0-python-2.7/lib/python2.7/site-packages/rez/pip.py", line 142, in find_python_in_context
    python_package = context.get_resolved_package("python")
  File "/home/selecaoone/rez-2.72.0-python-2.7/lib/python2.7/site-packages/rez/resolved_context.py", line 434, in get_resolved_package
    pkgs = [x for x in self._resolved_packages if x.name == name]
TypeError: 'NoneType' object is not iterable

Suggested Fix?

Add this code:

    if context.status == ResolverStatus.failed:
        print_error('Package request "%s" could not be resolved.', package_request)

        return None, None, None

Here: https://github.com/nerdvegas/rez/blob/master/src/rez/pip.py#L202

When I do this, it fails to resolve the package_request, ["python-3.6", "pip"], but finds another context which it can resolve. And then the package installs properly.

@johhnry
Copy link

johhnry commented Sep 23, 2021

Hi,

I have the same problem, I am binding a version of python (installed with asdf) different that the system one and pip is not bind by default. Running rez pip --install with that version doesn't work.

By the way is it possible to bind pip using rez bind?
Because this doesn't work:

$ pip --version
pip 20.1.1 from /home/josephhenry/.asdf/installs/python/3.7.9/lib/python3.7/site-packages/pip (python 3.7)

$ rez bind pip
searching /opt/rez/lib/python3.9/site-packages/rez/bind...
creating package 'pip' in /home/josephhenry/packages...
00:41:03 WARNING  Skipping installation: Package variant already exists: /home/josephhenry/packages/pip/20.3.4/package.py[0]

Edit

I found a solution:

I actually installed rez with python3.9 so I reinstalled it with python3.7 after switching python version with asdf and it works now!

@alexey-pelykh
Copy link
Contributor

Related to #1325

@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

4 participants