Bug 1664722

Summary: Latest release breaks easy_install
Product: [Fedora] Fedora EPEL Reporter: Patrick Gerken <patrick.gerken>
Component: python3-setuptoolsAssignee: Miro Hrončok <mhroncok>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: epel7CC: cstratak, mhroncok, orion, pviktori, python-sig, TicoTimo
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: python3-setuptools-39.2.0-2.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-01-27 00:41:54 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1576924    
Bug Blocks:    

Description Patrick Gerken 2019-01-09 13:59:32 UTC
Description of problem:

After the upgrade of python36-setuptools, packages cannot be created via easy_install any more. It expects to use a directory /usr/local/lib/python36 which does not exist


Version-Release number of selected component (if applicable):

python36-setuptools.noarch 0:39.2.0-1.el7

How reproducible:

I reproduced this on a fresh centos:7 docker image

Steps to Reproduce:
1. yum -y install epel-release 
2. yum-config-manager --enable cr
3. yum inspect python36-setuptools
4. easy_install-3.6 pip

Actual results:

```
error: can't create or remove files in install directory

The following error occurred while trying to add or remove files in the
installation directory:

    [Errno 2] No such file or directory: '/usr/local/lib/python3.6/site-packages/test-easy-install-368.write-test'

The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

    /usr/local/lib/python3.6/site-packages/

This directory does not currently exist.  Please create it and try again, or
choose a different installation directory (using the -d or --install-dir
option).
```


Expected results:


Successful installation of the package.


Additional info:

It works with the previous version, 0.19

Comment 1 Miro Hrončok 2019-01-09 14:21:00 UTC
I wonder if this is actually a problem in setuptools or if the Fedora change about /usr/local/lib got smuggled into EPEL7 without anybody noticing.

Comment 2 Miro Hrončok 2019-01-09 14:23:32 UTC
Anyway probably too late to change that, so here's the setuptools fix: https://src.fedoraproject.org/rpms/python-setuptools/blob/master/f/create-site-packages.patch

Comment 3 Patrick Gerken 2019-01-09 14:25:43 UTC
But this would just create the empty site-packages directory when calling easy install, while there already is an existing site-package in /usr/lib/python36 already

Comment 4 Patrick Gerken 2019-01-09 14:29:35 UTC
Oh, interesting, it looks like that is also they it was handled with the older setuptools.

Comment 5 Miro Hrončok 2019-01-09 14:36:19 UTC
See https://fedoraproject.org/wiki/Changes/Making_sudo_pip_safe for why this was done in Fedora. Not sure if this is supposed to be in EPEL, but I guess even if it shouldn't, it's too late now.

Comment 6 Charalampos Stratakis 2019-01-09 14:42:17 UTC
(In reply to Miro Hrončok from comment #5)
> See https://fedoraproject.org/wiki/Changes/Making_sudo_pip_safe for why this
> was done in Fedora. Not sure if this is supposed to be in EPEL, but I guess
> even if it shouldn't, it's too late now.

It could be backported but this change was only intended for Fedora.

Comment 7 Patrick Gerken 2019-01-09 14:47:17 UTC
An existing container with the previous setuptools version has a directory /usr/lib/python3.6/site-packages which only contains a directory named __pycache__
the older version easy_install installed everything to /usr/local/lib/python3.6/site-packages.

With Miros patch, the current version of python36-setuptools would do the same and easy_install should work again.

Comment 8 Patrick Gerken 2019-01-09 14:56:35 UTC
If I apply this patch manually, I can install packages with easy_install. But I noticed that now easy_install.py is in /usr/lib/python3.6, whereas everything installed with easy_install ends up in /usr/local/lib/python3.6.
This behavior is different to the previous version :-(

Comment 9 Miro Hrončok 2019-01-09 15:58:05 UTC
> This behavior is different to the previous version

Nothing changed in setuptools about this, it's a change in the python36 package. Not sure when it got in.

BTW You should not be sudo easy_installing things. That's very dangerous. Get a Python virtual environment, or at least use pip install --user.

Comment 10 Patrick Gerken 2019-01-10 08:10:50 UTC
I compared the python36 versions of all installed packages from a docker image about two weeks ago before the update of python36-setuptools to a current docker image where I install all packages freshly.

I have python36, python36-libs and python36-setuptools. Of all three only python36-setuptools is in a newer version.

Unfortunately I don't know anything about packaging and don't understand the syntax of the .spec file enough to understand what is going on.




Regarding not sudo easy_installing things:

I only use easy_install once while building the docker image because I want to provide pipenv. I want to use pip to install pipenv, but there is no pip command and no python36-pip package to yum install. So I start with easy_install...

The docker image is then only used with users that don't have sudo rights.

Comment 11 Miro Hrončok 2019-01-10 08:32:19 UTC
Let's see what can we do about missing pip.

Comment 12 Miro Hrončok 2019-01-10 08:35:55 UTC
Anyway this might take a while. As a workaround of the immediate problem, create the directory before installing pip.

Also, try using this to install pip:

    python3 -m ensurepip

Note that this is also dangerous with sudo, but a bit less than easy_install.

Comment 13 Miro Hrončok 2019-01-10 08:45:30 UTC
$ docker run -ti jsmigel/centos-epel /bin/bash
...
[root@ea092e28ba9e /]# yum install python36
...

Installed:
  python36.x86_64 0:3.6.6-1.el7                                                                                                                                                                                                  

Dependency Installed:
  python36-libs.x86_64 0:3.6.6-1.el7                                                                                                                                                                                             

Complete!
[root@ea092e28ba9e /]# python3.6 -m ensurepip
Looking in links: /tmp/tmpprhtejdj
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-10.0.1 setuptools-39.0.1
[root@ea092e28ba9e /]# python3.6 -m pip --version
pip 10.0.1 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)

Comment 14 Miro Hrončok 2019-01-10 08:46:16 UTC
Also:

[root@ea092e28ba9e /]# python3.6 -m pip install -U pip
Collecting pip
  Downloading https://files.pythonhosted.org/packages/c2/d7/90f34cb0d83a6c5631cf71dfe64cc1054598c843a92b400e55675cc2ac37/pip-18.1-py2.py3-none-any.whl (1.3MB)
    100% |################################| 1.3MB 12.1MB/s 
Installing collected packages: pip
  Found existing installation: pip 10.0.1
    Uninstalling pip-10.0.1:
      Successfully uninstalled pip-10.0.1
Successfully installed pip-18.1
[root@ea092e28ba9e /]# python3.6 -m pip --version
pip 18.1 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)

Comment 15 Patrick Gerken 2019-01-11 10:08:07 UTC
python3.6 -m ensurepip works
python3.6 -m pip install -U pip does not.

ensurepip also leaves the system in the same state as easy_intall in the old version.

I can live with ensurepip perfectly fine. using easy_install was just a workaround I am glad I got rid of. Thank you! 

But I guess people who do have to use easy install still are in trouble.

Comment 16 Miro Hrončok 2019-01-11 10:26:47 UTC
Yes, this is indeed a bug that needs to be fixed. I'm just providing workarounds.


Anyway, you might be interested in https://src.fedoraproject.org/rpms/python-pip/pull-request/22

Comment 17 Miro Hrončok 2019-01-11 10:37:52 UTC
Patrick, any chance you could review the PR and test the built RPM from it?

https://src.fedoraproject.org/rpms/python3-setuptools/pull-request/3

Comment 18 Patrick Gerken 2019-01-11 11:09:00 UTC
Hi Miro,

sorry for pointing that out I am used to work in ticket systems where people take any excuse to close a ticket no matter what...

so I tried, running in a stock centos:7 image:

yum -y install epel-release && yum-config-manager --enable cr && yum install -y python36 && curl -o setuptools.rpm https://kojipkgs.fedoraproject.org//work/tasks/3669/31953669/python36-setuptools-39.2.0-2.el7.noarch.rpm && yum install setuptools.rpm && easy_install-3.6 pip


This will successfully install easy_install and pip.
I looked a bit deeper, setuptools now does get installed in /usr/lib/python3.6/site-packages while pip got installed in /usr/local/lib/python3.6/site-package.

With the previous version, setuptools ended up in /usr/local/lib/python3.6/site-packages.

But from the interpreter I can both import setuptools and pip, so both directories get checked. 

Given that in python we don't import modules with absolute paths, I guess this is good enough.

Comment 19 Miro Hrončok 2019-01-11 11:23:06 UTC
> setuptools now does get installed in /usr/lib/python3.6/site-packages while pip got installed in /usr/local/lib/python3.6/site-package

That was expected.

> With the previous version, setuptools ended up in /usr/local/lib/python3.6/site-packages.

That was not expected.

> Given that in python we don't import modules with absolute paths, I guess this is good enough.

Thanks.

Comment 20 Fedora Update System 2019-01-11 11:35:48 UTC
python3-setuptools-39.2.0-2.el7 has been submitted as an update to Fedora EPEL 7. https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2019-e29af3c9e7

Comment 21 Fedora Update System 2019-01-12 03:35:15 UTC
python3-setuptools-39.2.0-2.el7 has been pushed to the Fedora EPEL 7 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2019-e29af3c9e7

Comment 22 Fedora Update System 2019-01-27 00:41:54 UTC
python3-setuptools-39.2.0-2.el7 has been pushed to the Fedora EPEL 7 stable repository. If problems still persist, please make note of it in this bug report.