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

why not using ensurepip? #3

Closed
OwenChia opened this Issue Apr 7, 2016 · 7 comments

Comments

Projects
None yet
3 participants
@OwenChia
Copy link

OwenChia commented Apr 7, 2016

just like this:

RUN python3 -m ensurepip && pip3 install --upgrade pip
@frol

This comment has been minimized.

Copy link
Owner

frol commented Apr 7, 2016

@OwenChia Good point! I didn't know it was there. I have removed ensurepip in the latest commit since it just takes 1.6MB on disk and doesn't add any value. I would rather prefer to have a py3-pip package in Alpine repo, so I also created a ticket in Alpine bugtracker https://bugs.alpinelinux.org/issues/5381.

Thank you!

@frol frol closed this Apr 7, 2016

@OwenChia

This comment has been minimized.

Copy link

OwenChia commented Apr 7, 2016

@frol
It's may not be good for pyvenv user. Remove ensurepip will damage venv module.

@frol

This comment has been minimized.

Copy link
Owner

frol commented Apr 7, 2016

By default, pyvenv seems to be broken:

# pyvenv /tmp/env
Error: Command '['/tmp/env/bin/python3.5', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1

However, adding --without-pip makes it work just fine for me:

# pyvenv --without-pip /tmp/env
# . /tmp/env/bin/activate
(env) / # pip install flask
Collecting flask
  Downloading Flask-0.10.1.tar.gz (544kB)
    100% |████████████████████████████████| 552kB 1.0MB/s
Collecting Werkzeug>=0.7 (from flask)
  Downloading Werkzeug-0.11.5-py2.py3-none-any.whl (305kB)
    100% |████████████████████████████████| 307kB 2.2MB/s
Collecting Jinja2>=2.4 (from flask)
  Downloading Jinja2-2.8-py2.py3-none-any.whl (263kB)
    100% |████████████████████████████████| 266kB 4.1MB/s
Collecting itsdangerous>=0.21 (from flask)
  Downloading itsdangerous-0.24.tar.gz (46kB)
    100% |████████████████████████████████| 51kB 2.4MB/s
Collecting MarkupSafe (from Jinja2>=2.4->flask)
  Downloading MarkupSafe-0.23.tar.gz
Installing collected packages: Werkzeug, MarkupSafe, Jinja2, itsdangerous, flask
  Running setup.py install for MarkupSafe ... done
  Running setup.py install for itsdangerous ... done
  Running setup.py install for flask ... done
Successfully installed Jinja2-2.8 MarkupSafe-0.23 Werkzeug-0.11.5 flask-0.10.1 itsdangerous-0.24

Am I missing something?

BTW, I have never used virtual envs inside Docker images/containers, so I don't see a problem here anyway...

@frol

This comment has been minimized.

Copy link
Owner

frol commented Apr 7, 2016

Reading Python pyvenv code and googling around I discovered that this ensurepip hard dependency is an upstream bug, which people seems to have not reported to the upstream (or I haven't found the ticket), but reported to Ubuntu and other distributions bugtrackers. Could you please try to find a bugreport on Python bugtracker or create one?

The reports that I have found:

@OwenChia

This comment has been minimized.

Copy link

OwenChia commented Apr 7, 2016

@frol
Do you have ensurepip existed? It's work for me.

/ # apk --no-cache add python3
fetch http://mirrors.ustc.edu.cn/alpine/v3.3/main/x86_64/APKINDEX.tar.gz
fetch http://mirrors.ustc.edu.cn/alpine/v3.3/community/x86_64/APKINDEX.tar.gz
(1/9) Installing libbz2 (1.0.6-r4)
(2/9) Installing expat (2.1.0-r2)
(3/9) Installing libffi (3.2.1-r2)
(4/9) Installing gdbm (1.11-r1)
(5/9) Installing ncurses-terminfo-base (6.0-r6)
(6/9) Installing ncurses-terminfo (6.0-r6)
(7/9) Installing ncurses-libs (6.0-r6)
(8/9) Installing sqlite-libs (3.9.2-r0)
(9/9) Installing python3 (3.5.1-r0)
Executing busybox-1.24.1-r7.trigger
OK: 61 MiB in 20 packages
/ # pyvenv test
/ # ls -l test
total 16
drwxr-xr-x    2 root     root          4096 Apr  7 10:30 bin
drwxr-xr-x    2 root     root          4096 Apr  7 10:30 include
drwxr-xr-x    3 root     root          4096 Apr  7 10:30 lib
lrwxrwxrwx    1 root     root             3 Apr  7 10:30 lib64 -> lib
-rw-r--r--    1 root     root            69 Apr  7 10:30 pyvenv.cfg
@frol

This comment has been minimized.

Copy link
Owner

frol commented Apr 7, 2016

Here is the current Dockerfile state:

RUN apk add --no-cache python3 && \
    python3 -m ensurepip && \
    rm -r /usr/lib/python*/ensurepip && \
    pip3 install --upgrade pip setuptools && \
    rm -r /root/.cache

As you can see, I am removing ensurepip there (rm -r /usr/lib/python*/ensurepip). Why would anyone need it when pip is already installed in the image? I just saved 1.6MB by removing the useless bundle.

@GenPage

This comment has been minimized.

Copy link

GenPage commented Mar 7, 2018

@frol Came across this issue today. When using a venv using --without-pip, there is no pip or setuptools installed in the venv. What you are seeing in your test is the global pip binary. Installing packages using pip installs them globally, not in the venv.

(venv) /argo # pip -V
pip 9.0.1 from /usr/lib/python3.6/site-packages (python 3.6)
(venv) /argo # python -m pip -V
/argo/venv/bin/python: No module named pip
(venv) /argo # ls venv/lib/python3.6/site-packages/
(venv) /argo #
(venv) /argo # ls /usr/lib/python3.6/site-packages/
GitPython-2.1.8.dist-info                           gitdb
Jinja2-2.10.dist-info                               gitdb2-2.0.3.dist-info
Markdown-2.6.11.dist-info                           idna
MarkupSafe-1.0-py3.6.egg-info                       idna-2.6.dist-info
OpenSSL                                             jinja2
Pygments-2.2.0.dist-info                            markdown
README.txt                                          markupsafe
WebOb-1.7.4.dist-info                               pip
WebTest-2.0.29.dist-info                            pip-9.0.1.dist-info
Yapsy-1.11.223-py3.6.egg-info                       pkg_resources
__pycache__                                         pyOpenSSL-17.2.0.dist-info
_cffi_backend.cpython-36m-x86_64-linux-gnu.so       pycparser
ansi                                                pycparser-2.18-py3.6.egg-info
ansi-0.1.3-py3.6.egg-info                           pygments
asn1crypto                                          pygments_markdown_lexer
asn1crypto-0.24.0.dist-info                         pygments_markdown_lexer-0.1.0.dev39-py3.6.egg-info
beautifulsoup4-4.6.0.dist-info                      raven
bottle-0.12.13-py3.6.egg-info                       raven-6.6.0.dist-info
bottle.py                                           requests
bs4                                                 requests-2.18.4.dist-info
certifi                                             rocket
certifi-2018.1.18.dist-info                         rocket_errbot-1.2.5-py3.6.egg-info
cffi                                                setuptools
cffi-1.11.5-py3.6.egg-info                          setuptools-38.5.1.dist-info
chardet                                             six-1.11.0.dist-info
chardet-3.0.4.dist-info                             six.py
colorlog                                            slackclient
colorlog-3.1.2.dist-info                            slackclient-1.1.3-py3.6.egg-info
cryptography                                        smmap
cryptography-2.0.3-py3.6.egg-info                   smmap2-2.0.3.dist-info
daemonize-2.4.7.dist-info                           urllib3
daemonize.py                                        urllib3-1.22.dist-info
dns                                                 waitress
dnspython-1.15.0.dist-info                          waitress-1.1.0.dist-info
dnspython3-1.15.0-py3.6.egg-info                    webob
easy_install.py                                     websocket
errbot                                              websocket_client-0.47.0.dist-info
errbot-5.1.3-py3.6.egg-info                         webtest
git                                                 yapsy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment