Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bug#996822: ensurepip throws an AssertionError on pypy3

192 views
Skip to first unread message

Ophir Lojkine

unread,
Oct 19, 2021, 7:10:03 AM10/19/21
to
Package: pypy3
Version: 7.3.5+dfsg-2


Running pypy3 -m ensurepip on Debian returns an AssertionError. 

 Here is a Dockerfile that reproduces the issue:

FROM debian:stable-slim
RUN apt-get update && apt-get -y install pypy3RUN pypy3 -m ensurepip 

 It throws the following error:

------                                                                                                                    
 > [3/3] RUN pypy3 -m ensurepip:                                                                                          
#7 0.593 Traceback (most recent call last):                                                                               
#7 0.593   File "/usr/lib/pypy3/lib-python/3/runpy.py", line 196, in _run_module_as_main                                  
#7 0.593     "__main__", mod_spec)                                                                                        
#7 0.593   File "/usr/lib/pypy3/lib-python/3/runpy.py", line 85, in _run_code                                             
#7 0.593     exec(code, run_globals)
#7 0.593   File "/usr/lib/pypy3/lib-python/3/ensurepip/__main__.py", line 5, in <module>
#7 0.593     sys.exit(ensurepip._main())
#7 0.593   File "/usr/lib/pypy3/lib-python/3/ensurepip/__init__.py", line 221, in _main
#7 0.593     version="pip {}".format(version()),
#7 0.593   File "/usr/lib/pypy3/lib-python/3/ensurepip/__init__.py", line 71, in version
#7 0.593     assert len(wheel_names) == 1, wheel_names
#7 0.593 AssertionError: []
———

Running get-pip.py does not change the error.


stef...@debian.org

unread,
Oct 19, 2021, 12:40:04 PM10/19/21
to
Hi Ophir (2021.10.19_10:59:43_+0000)
> Running pypy3 -m ensurepip on Debian returns an AssertionError.

Thanks for the bug, that shouldn't happen.

What should happen is that it prints the error message:

> ensurepip is disabled in Debian/Ubuntu for the system python.
>
> Python modules for the system python are usually handled by dpkg and apt-get.
>
> apt-get install python3-<module name>
>
> Install the python3-pip package to use pip itself. Using pip together
> with the system python might have unexpected results for any system
> installed module, so use it on your own risk, or make sure to only use
> it in virtual environments.

However:

> Running get-pip.py <https://bootstrap.pypa.io/get-pip.py> does not
> change the error.

I can't reproduce that, get-pip.py works for me, and leaves me with a
functional pip.

SR

--
Stefano Rivera
http://tumbleweed.org.za/
+1 415 683 3272

Ophir Lojkine

unread,
Oct 19, 2021, 12:40:04 PM10/19/21
to
>
> I can't reproduce that, get-pip.py works for me, and leaves me with a
> functional pip.

Interesting ! What does the following script return for you ?

cat <<EOF > Dockerfile
FROM debian:stable-slim

RUN apt-get update && apt-get -y install pypy3 wget

RUN wget https://bootstrap.pypa.io/get-pip.py && pypy3 get-pip.py

RUN pypy3 -m ensurepip
EOF

docker build .

Ophir Lojkine

unread,
Oct 19, 2021, 12:50:03 PM10/19/21
to

> What should happen is that it prints the error message:
>
>> […]
>> Install the python3-pip package to use pip itself. […]

Should it encourage the user to install python3-pip ? I thought this package was specific to cpython.
Installing it does not seem to make ensurepip work in pypy, at least.

stef...@debian.org

unread,
Oct 19, 2021, 1:00:03 PM10/19/21
to
Hi Ophir (2021.10.19_16:45:43_+0000)
> Should it encourage the user to install python3-pip ? I thought this
> package was specific to cpython.

It is not specific to cpython.
All python3 implementations on Debian can use it.

However, when it comes to C extensions, those tend to be specific to
cpython (yes, this is a bit of a mess)

> Installing it does not seem to make ensurepip work in pypy, at least.

Again, not sure what you're expecting there.

stef...@debian.org

unread,
Oct 19, 2021, 1:00:04 PM10/19/21
to
Hi Ophir (2021.10.19_16:32:18_+0000)
> RUN apt-get update && apt-get -y install pypy3 wget
>
> RUN wget https://bootstrap.pypa.io/get-pip.py && pypy3 get-pip.py
>
> RUN pypy3 -m ensurepip

The same error. get-pip.py will do nothing to make ensurepip behave any
differently.

If you want to *use* pip, use "pypy3 -m pip", ensurepip is not a pip
wrapper.

stef...@debian.org

unread,
Oct 19, 2021, 1:10:03 PM10/19/21
to
Hi Ophir (2021.10.19_16:58:38_+0000)
> Of course ! But shouldn't ensurepip detect pip when it is installed,
> instead of returning an AssertionError ?

Yeah, possibly.

And as I said before, it shouldn't be returning an AssertionError,
that's a bug. You should be getting a friendly error explaining why
using ensurepip in a Debian packaged python doesn't make any sense.

> ensurepip being broken means that `pypy3 -m venv venv` is broken too, which
> is annoying.

No, that should be working. That's why we have ensurepip.

Ophir Lojkine

unread,
Oct 19, 2021, 1:10:03 PM10/19/21
to


If you want to *use* pip, use "pypy3 -m pip", ensurepip is not a pip
wrapper.

Of course ! But shouldn't ensurepip detect pip when it is installed, instead of returning an AssertionError ? 

Ophir Lojkine

unread,
Oct 19, 2021, 1:20:04 PM10/19/21
to

Again, not sure what you're expecting there.

If python3-pip is supposed to work with pypy, I would expect `apt install pypy3 python3-pip && pypy3 -m ensurepip --version` to return “pip 20.3.4-4”. Instead, it returns the long error message you mentioned above that suggests installing another package.

No, that should be working. That's why we have ensurepip.

Can you try it in a docker image ? Starting from Debian slim, "apt install pypy3 && pypy3 -m venv venv” fails for me.

stef...@debian.org

unread,
Oct 19, 2021, 1:40:03 PM10/19/21
to
Hi Ophir (2021.10.19_17:13:16_+0000)

>
> > Again, not sure what you're expecting there.
>
> If python3-pip is supposed to work with pypy, I would expect `apt install pypy3 python3-pip && pypy3 -m ensurepip --version` to return “pip 20.3.4-4”. Instead, it returns the long error message you mentioned above that suggests installing another package.

Nope, I get:
$ pypy3 -m ensurepip --version
pip 20.3.4

> > No, that should be working. That's why we have ensurepip.
>
> Can you try it in a docker image ? Starting from Debian slim, "apt install pypy3 && pypy3 -m venv venv” fails for me.

With an error message that says:

> The virtual environment was not created successfully because ensurepip
> is not available. On Debian/Ubuntu systems, you need to install the
> python-pip-whl package using the following command.
>
> apt-get install python-pip-whl
>
> You may need to use sudo with that command. After installing the
> python-pip-whl package, recreate your virtual environment.

If you read that error message, does that help?

Ophir Lojkine

unread,
Oct 20, 2021, 11:50:03 AM10/20/21
to

>> If python3-pip is supposed to work with pypy, I would expect `apt install pypy3 python3-pip && pypy3 -m ensurepip --version` to return “pip 20.3.4-4”. Instead, it returns the long error message you mentioned above that suggests installing another package.
>
> Nope, I get:
> $ pypy3 -m ensurepip --version
> pip 20.3.4

Yes, you are right, this works correctly.

> If you read that error message, does that help?

Yes, that error message is fine and helpful. The only issue is the assertion error in ensurepip.
0 new messages