[apparmor] [patch] fix python LibAppArmor import failures with swig > 3.0.8
Christian Boltz
apparmor at cboltz.de
Wed Sep 14 18:52:33 UTC 2016
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?
Note: you'll need to cleanup your libraries/libapparmor/swig/python/
directory manually before applying this patch ("make clean" isn't enough,
so check "bzr ignored"), and regenerate the autogenerated files with
autogen.sh and configure afterwards.
If there's a "superclean" make target I missed, please tell me ;-)
[ libapparmor-fix-import-path.diff ]
Index: libraries/libapparmor/swig/python/Makefile.am
===================================================================
--- libraries/libapparmor/swig/python/Makefile.am.orig 2014-01-06 23:08:55.000000000 +0100
+++ libraries/libapparmor/swig/python/Makefile.am 2016-08-26 18:03:52.526582753 +0200
@@ -6,9 +6,8 @@ SUBDIRS = test
libapparmor_wrap.c: $(srcdir)/../SWIG/libapparmor.i
$(SWIG) -python -I$(srcdir)/../../include -module LibAppArmor -o $@ $(srcdir)/../SWIG/libapparmor.i
- mv LibAppArmor.py __init__.py
-MOSTLYCLEANFILES=libapparmor_wrap.c __init__.py
+MOSTLYCLEANFILES=libapparmor_wrap.c LibAppArmor.py
all-local: libapparmor_wrap.c setup.py
if test ! -f libapparmor_wrap.c; then cp $(srcdir)/libapparmor_wrap.c . ; fi
Index: libraries/libapparmor/swig/python/__init__.py
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ libraries/libapparmor/swig/python/__init__.py 2016-08-26 18:03:16.790763701 +0200
@@ -0,0 +1 @@
+from LibAppArmor.LibAppArmor import *
=== modified file '.bzrignore'
--- .bzrignore 2015-10-21 19:40:35 +0000
+++ .bzrignore 2016-09-14 18:34:04 +0000
@@ -88,7 +88,7 @@
libraries/libapparmor/swig/perl/blib
libraries/libapparmor/swig/perl/libapparmor_wrap.c
libraries/libapparmor/swig/perl/pm_to_blib
-libraries/libapparmor/swig/python/__init__.py
+libraries/libapparmor/swig/python/LibAppArmor.py
libraries/libapparmor/swig/python/build/
libraries/libapparmor/swig/python/libapparmor_wrap.c
libraries/libapparmor/swig/python/Makefile
Regards,
Christian Boltz
--
> My personal opinion is that bugzilla should be sent in a rocket
> to the oblivion and pick up something sane and usable, [...]
Do you really mean the core Bugzilla software or perhaps some
infrastructure software like this "Internet in CHAINs" thingy or
whatever its actual name is?
[> Cristian Rodríguez and Johannes Meixner in opensuse-factory]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20160914/ca3f335c/attachment.pgp>
More information about the AppArmor
mailing list