[apparmor] [patch] fix python LibAppArmor import failures with swig > 3.0.8

Tyler Hicks tyhicks at canonical.com
Wed Sep 14 21:26:07 UTC 2016


On 09/14/2016 04:05 PM, Tyler Hicks wrote:
> On 09/14/2016 03:32 PM, Steve Beattie wrote:
>> On Wed, Sep 14, 2016 at 02:12:35PM -0500, Tyler Hicks wrote:
>>> On 09/14/2016 01:52 PM, Christian Boltz wrote:
>>>> Hello,
>>>>
>>>> renaming LibAppArmor.py to __init__.py breaks the import path
>>>> calculation in swig (> 3.0.8)-generated python code, leading to an error
>>>> message saying
>>>>     No module named '_LibAppArmor'
>>>>
>>>> Therefore this patch drops renaming the file. To stay compatible with the
>>>>     import LibAppArmor.$function_name
>>>> syntax, add an __init__.py that does
>>>>     from LibAppArmor.LibAppArmor import *
>>>>
>>>> References: https://bugzilla.opensuse.org/show_bug.cgi?id=987607
>>>>
>>>>
>>>> Also adjust .bzrignore for this change.
>>>>
>>>>
>>>>
>>>> I propose this patch for trunk and 2.10.
>>>> I'm undecided about 2.9 - technically it shares this bug, but I'd expect
>>>> that 2.9 users don't use the latest swig ;-) - opinions?
>>>
>>> Acked-by: Tyler Hicks <tyhicks at canonical.com>
>>>
>>> Please apply to 2.9, as well. IIRC, this is one of the errors I hit when
>>> I run `make check` on the utils/ dir from Ubuntu 16.04 (with swig
>>> 3.0.8-0ubuntu3) development machine so it'd be nice if that's fixed in
>>> all of our stable branches. Thanks for fixing it!
>>
>> Also, no, it does not fix the make check issue in the utils/ directory:
>>
>> === test-pivot_root_parse.py ===
>> Traceback (most recent call last):
>>   File "test-pivot_root_parse.py", line 12, in <module>
>>     import apparmor.aa as aa
>>   File "/home/steve/bzr/apparmor-master/utils/apparmor/aa.py", line 29, in <module>
>>     import apparmor.logparser
>>   File "/home/steve/bzr/apparmor-master/utils/apparmor/logparser.py", line 19, in <module>
>>     import LibAppArmor
>>   File "/home/steve/bzr/apparmor-master/libraries/libapparmor/swig/python/build/lib.linux-x86_64-3.5/LibAppArmor/__init__.py", line 1, in <module>
>>     from LibAppArmor.LibAppArmor import *
>>   File "/home/steve/bzr/apparmor-master/libraries/libapparmor/swig/python/build/lib.linux-x86_64-3.5/LibAppArmor/LibAppArmor.py", line 28, in <module>
>>     _LibAppArmor = swig_import_helper()
>>   File "/home/steve/bzr/apparmor-master/libraries/libapparmor/swig/python/build/lib.linux-x86_64-3.5/LibAppArmor/LibAppArmor.py", line 20, in swig_import_helper
>>     import _LibAppArmor
>> ImportError: No module named _LibAppArmor
>>
> 
> Yeah, I should have tested this myself before I gave the ack. I see a
> little bit different error. Maybe because I'm not forcing python3 to be
> used?
> 
> $ (cd libraries/libapparmor/ && ./autogen.sh && ./configure && make) \

Bah, it would help if I configured libapparmor --with-python. Doesn't
matter though because I see the same error. I think we've previously
determined that my "problem" is because I'm trying to test the in-tree
code and don't have a python libapparmor module installed system-wide.

Tyler

>   > /dev/null && (cd binutils/ && make) > /dev/null && \
>   (cd parser/ && make) > /dev/null && (cd utils && make) > /dev/null
> $ (cd utils && make check)
> ...
> === test-pivot_root_parse.py ===
> Traceback (most recent call last):
>   File "test-pivot_root_parse.py", line 12, in <module>
>     import apparmor.aa as aa
>   File "/var/scm/apparmor.git/utils/apparmor/aa.py", line 29, in <module>
>     import apparmor.logparser
>   File "/var/scm/apparmor.git/utils/apparmor/logparser.py", line 19, in
> <module>
>     import LibAppArmor
> ImportError: No module named LibAppArmor
> Makefile:65: recipe for target 'check' failed
> make[1]: *** [check] Error 1
> make[1]: Leaving directory '/var/scm/apparmor.git/utils/test'
> Makefile:92: recipe for target 'check' failed
> make: *** [check] Error 2
> 
> It sounds like I should rescind my ack until we get some more discussion
> around this patch.
> 
> Tyler
> 
> 
> 
> 
> 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20160914/4bfb4a1f/attachment.pgp>


More information about the AppArmor mailing list