Bug 1715589 - python3-libselinux ImportError when rebuilt with swig 4
Summary: python3-libselinux ImportError when rebuilt with swig 4
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: libselinux
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: ---
Assignee: Petr Lautrbach
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON38
TreeView+ depends on / blocked
 
Reported: 2019-05-30 17:46 UTC by Miro Hrončok
Modified: 2019-05-31 07:33 UTC (History)
4 users (show)

Fixed In Version: libselinux-2.9-2.fc31
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-05-31 06:16:45 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Miro Hrončok 2019-05-30 17:46:53 UTC
python3-libselinux-2.9-1.fc31 when rebuilt with swig 4 cannot import selinux.


This is python3-libselinux-2.9-1.fc31 from Fedora rawhide (rebuilt with swig 3.0.12):

<mock-chroot> sh-5.0# rpm -q python3-libselinux
python3-libselinux-2.9-1.fc31.x86_64
<mock-chroot> sh-5.0# head /usr/lib64/python3.7/site-packages/selinux/__init__.py  -n2
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 3.0.12
<mock-chroot> sh-5.0# python3 -c 'import selinux' && echo OK
OK

However when I rebuild it with swig 4.0.0:

<mock-chroot> sh-5.0# rpm -q python3-libselinux
python3-libselinux-2.9-3.fc31.x86_64
<mock-chroot> sh-5.0# head /usr/lib64/python3.8/site-packages/selinux/__init__.py  -n2
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 4.0.0
<mock-chroot> sh-5.0# python3 -c 'import selinux' && echo OK
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib64/python3.8/site-packages/selinux/__init__.py", line 13, in <module>
    from . import _selinux
ImportError: cannot import name '_selinux' from 'selinux' (/usr/lib64/python3.8/site-packages/selinux/__init__.py)


(The double bump form -1 to -3 was done by me.)

This happens with Python 3.8, I'm runn ing a scratch build against 3.7 to see if it is also affected.

This blocks the rebuild of setroubleshoot for Python 3.8:

checking whether /usr/bin/python3 version is >= 3... yes
checking for /usr/bin/python3 version... 3.8
checking for /usr/bin/python3 platform... linux
checking for /usr/bin/python3 script directory... ${prefix}/lib/python3.8/site-packages
checking for /usr/bin/python3 extension module directory... ${exec_prefix}/lib64/python3.8/site-packages
checking for the selinux python3 module... no
configure: error: cannot import Python3 module selinux
                   Please check your Python3 installation. The error was:
                   Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib64/python3.8/site-packages/selinux/__init__.py", line 13, in <module>
    from . import _selinux
ImportError: cannot import name '_selinux' from 'selinux' (/usr/lib64/python3.8/site-packages/selinux/__init__.py)

Comment 1 Miro Hrončok 2019-05-30 17:49:20 UTC
With a new Python 3.7 scratchbuild: https://koji.fedoraproject.org/koji/taskinfo?taskID=35151346

$ mock -r fedora-rawhide-x86_64 install https://kojipkgs.fedoraproject.org//work/tasks/1417/35151417/python3-libselinux-2.9-1.fc31.x86_64.rpm https://kojipkgs.fedoraproject.org//work/tasks/1417/35151417/libselinux-2.9-1.fc31.x86_64.rpm
$ mock -r fedora-rawhide-x86_64 shell
<mock-chroot> sh-5.0# rpm -q python3-libselinux
python3-libselinux-2.9-1.fc31.x86_64
<mock-chroot> sh-5.0# head /usr/lib64/python3.7/site-packages/selinux/__init__.py  -n2
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 4.0.0
<mock-chroot> sh-5.0# python3 -c 'import selinux' && echo OK
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib64/python3.7/site-packages/selinux/__init__.py", line 13, in <module>
    from . import _selinux
ImportError: cannot import name '_selinux' from 'selinux' (/usr/lib64/python3.7/site-packages/selinux/__init__.py)

Comment 2 Petr Lautrbach 2019-05-31 06:16:45 UTC
https://src.fedoraproject.org/rpms/libselinux/c/5d8ec18db09e97729be68029ace116c5f91e7755?branch=master

I haven't found out how to do it so it works with swig-4.0.0 and swig-3.x.0 :/

Comment 3 Miro Hrončok 2019-05-31 07:33:32 UTC
Thanks for the super fast fix.


Note You need to log in before you can comment on or make changes to this bug.