pip-and-virtualenv removes system python packages on fedora 29 but some tools require them

Bug #1813232 reported by Ian Wienand
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
diskimage-builder
Fix Released
Undecided
Ian Wienand

Bug Description

on fedora29, pip installs into separate locations. Several tools run with "/usr/bin/python3 -Es" which removes the pip path from the invocation.

pip-and-virtualenv has cleared out the system versions of pip/virtualenv etc in an effort to not have them conflict. But now these system tools can't find important packages, leading to things like

---
[root@fedora-29-inap-mtl01-0002083442 ~]# /usr/bin/python3 -Es
Python 3.7.2 (default, Jan 3 2019, 09:14:01)
[GCC 8.2.1 20181215 (Red Hat 8.2.1-6)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import seobject
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.7/site-packages/seobject.py", line 34, in <module>
    import sepolicy
  File "/usr/lib/python3.7/site-packages/sepolicy/__init__.py", line 9, in <module>
    import setools
  File "/usr/lib64/python3.7/site-packages/setools/__init__.py", line 78, in <module>
    from .permmap import PermissionMap
  File "/usr/lib64/python3.7/site-packages/setools/permmap.py", line 25, in <module>
    import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'
>>>
---

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to diskimage-builder (master)

Fix proposed to branch: master
Review: https://review.openstack.org/633141

Changed in diskimage-builder:
assignee: nobody → Ian Wienand (iwienand)
status: New → In Progress
Revision history for this message
Ian Wienand (iwienand) wrote :

With the fix, there is another problem now:

---
$ semanage
Traceback (most recent call last):
  File "/usr/sbin/semanage", line 28, in <module>
    import seobject
  File "/usr/lib/python3.7/site-packages/seobject.py", line 34, in <module>
    import sepolicy
  File "/usr/lib/python3.7/site-packages/sepolicy/__init__.py", line 9, in <module>
    import setools
  File "/usr/lib64/python3.7/site-packages/setools/__init__.py", line 24, in <module>
    __version__ = pkg_resources.get_distribution("setools").version
AttributeError: module 'pkg_resources' has no attribute 'get_distribution'
---

this seems to be related to https://bugzilla.redhat.com/show_bug.cgi?id=1550368#c21

---
The problem seems to stem from the fact that python3's pip is set to install only to the `/usr/local/lib/` prefix, but if it encounters an older version in `/usr/lib/` it will happily remove it. The result is that programs that run in isolated environment (that don't see into `/usr/local/lib/`) can't find setuptools and crash.
---

Revision history for this message
Ian Wienand (iwienand) wrote :

Testing with this change on a Fedora29 + pip-and-virtualenv the semanage tool seems to work ok now

---
bash-4.4# dnf install policycoreutils-python-utils

bash-4.4# semanage
usage: semanage [-h]
                {import,export,login,user,port,ibpkey,ibendport,interface,module,node,fcontext,boolean,permissive,dontaudit}
                ...
semanage: error: the following arguments are required: subcommand
---

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to diskimage-builder (master)

Reviewed: https://review.openstack.org/633141
Committed: https://git.openstack.org/cgit/openstack/diskimage-builder/commit/?id=ea1735b6a259c5424d2a0ca52eca371bf9213ac9
Submitter: Zuul
Branch: master

commit ea1735b6a259c5424d2a0ca52eca371bf9213ac9
Author: Ian Wienand <email address hidden>
Date: Fri Jan 25 16:27:49 2019 +1100

    pip-and-virtualenv : only remove system files on centos

    As described inline, we only want to remove the system package files
    on centos; it causes problems on Fedora where some system tools expect
    these to be there.

    But there is an additional bug -- pip actually removes the system
    package files anyway. To work around this, reinstall the system
    package.

    Closes-Bug: #1813232
    Change-Id: I041a141366099093805e6052b1bbf64efd277e1e

Changed in diskimage-builder:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.