howto: create howto_swig.*, use constructed Python namespace
authorJohnathan Corgan <jcorgan@corganenterprises.com>
Thu, 12 Nov 2009 18:47:22 +0000 (10:47 -0800)
committerJohnathan Corgan <jcorgan@corganenterprises.com>
Thu, 12 Nov 2009 18:47:22 +0000 (10:47 -0800)
gr-howto-write-a-block/python/Makefile.am
gr-howto-write-a-block/python/__init__.py [new file with mode: 0644]
gr-howto-write-a-block/python/qa_howto.py
gr-howto-write-a-block/swig/.gitignore
gr-howto-write-a-block/swig/Makefile.swig.gen

index 79f44019d15f08451b1bc9a1faf3f996426911b3..4ef5fc964d276fac3c858ab26dedf4d92878a9d2 100644 (file)
 
 include $(top_srcdir)/Makefile.common
 
-EXTRA_DIST = run_tests.in
-
+ourpythondir = $(grpythondir)/howto
 
-TESTS =                                \
-       run_tests
+EXTRA_DIST = run_tests.in
+TESTS = run_tests
 
+ourpython_PYTHON = \
+       __init__.py
 
-noinst_PYTHON =                        \
+noinst_PYTHON = \
        qa_howto.py                     
diff --git a/gr-howto-write-a-block/python/__init__.py b/gr-howto-write-a-block/python/__init__.py
new file mode 100644 (file)
index 0000000..3107e1f
--- /dev/null
@@ -0,0 +1,49 @@
+#
+# Copyright 2008,2009 Free Software Foundation, Inc.
+# 
+# This application is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+# 
+# This application is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+
+# The presence of this file turns this directory into a Python package
+
+# ----------------------------------------------------------------
+# Temporary workaround for ticket:181 (swig+python problem)
+import sys
+_RTLD_GLOBAL = 0
+try:
+    from dl import RTLD_GLOBAL as _RTLD_GLOBAL
+except ImportError:
+    try:
+       from DLFCN import RTLD_GLOBAL as _RTLD_GLOBAL
+    except ImportError:
+       pass
+    
+if _RTLD_GLOBAL != 0:
+    _dlopenflags = sys.getdlopenflags()
+    sys.setdlopenflags(_dlopenflags|_RTLD_GLOBAL)
+# ----------------------------------------------------------------
+
+
+# import swig generated symbols into the trppm namespace
+from howto_swig import *
+
+# import any pure python here
+#
+
+# ----------------------------------------------------------------
+# Tail of workaround
+if _RTLD_GLOBAL != 0:
+    sys.setdlopenflags(_dlopenflags)      # Restore original flags
+# ----------------------------------------------------------------
index 0abe0e2440f2f39f2785e48676ef2b45ded29c89..630f57bf422a55e023fe193a2e5c7f6338d4070f 100755 (executable)
@@ -21,7 +21,7 @@
 # 
 
 from gnuradio import gr, gr_unittest
-import howto
+import howto_swig
 
 class qa_howto (gr_unittest.TestCase):
 
@@ -35,7 +35,7 @@ class qa_howto (gr_unittest.TestCase):
         src_data = (-3, 4, -5.5, 2, 3)
         expected_result = (9, 16, 30.25, 4, 9)
         src = gr.vector_source_f (src_data)
-        sqr = howto.square_ff ()
+        sqr = howto_swig.square_ff ()
         dst = gr.vector_sink_f ()
         self.tb.connect (src, sqr)
         self.tb.connect (sqr, dst)
@@ -47,7 +47,7 @@ class qa_howto (gr_unittest.TestCase):
         src_data = (-3, 4, -5.5, 2, 3)
         expected_result = (9, 16, 30.25, 4, 9)
         src = gr.vector_source_f (src_data)
-        sqr = howto.square2_ff ()
+        sqr = howto_swig.square2_ff ()
         dst = gr.vector_sink_f ()
         self.tb.connect (src, sqr)
         self.tb.connect (sqr, dst)
index 9165273176904dc438e6c7899297a9f0d528aef2..7f4c478d9528bb5f68a6a2afaf8732ea445a8c43 100644 (file)
@@ -2,5 +2,5 @@
 /.libs
 /Makefile.in
 /Makefile
-/howto.cc
-/howto.py
+/howto_swig.cc
+/howto_swig.py
index f76cc637118f5d4bac584c3836921343e3974daf..c62e5aa3e0a1beb9de01c71b5c61172a2bf06118 100644 (file)
@@ -72,42 +72,42 @@ MOSTLYCLEANFILES += $(DEPDIR)/*.S*
 ## .h file is sometimes built, but not always ... so that one has to
 ## be added manually by the including Makefile.am .
 
-swig_built_sources += howto.py howto.cc
+swig_built_sources += howto_swig.py howto_swig.cc
 
 ## Various SWIG variables.  These can be overloaded in the including
 ## Makefile.am by setting the variable value there, then including
 ## Makefile.swig .
 
 howto_swiginclude_HEADERS =            \
-       howto.i                 \
+       howto.i                         \
        $(howto_swiginclude_headers)
 
 howto_pylib_LTLIBRARIES =              \
-       _howto.la
+       _howto_swig.la
 
-_howto_la_SOURCES =                    \
-       howto.cc                        \
+_howto_swig_la_SOURCES =               \
+       howto_swig.cc                   \
        $(howto_la_swig_sources)
 
-_howto_la_LIBADD =                     \
+_howto_swig_la_LIBADD =                        \
        $(STD_SWIG_LA_LIB_ADD)          \
        $(howto_la_swig_libadd)
 
-_howto_la_LDFLAGS =                    \
+_howto_swig_la_LDFLAGS =               \
        $(STD_SWIG_LA_LD_FLAGS)         \
        $(howto_la_swig_ldflags)
 
-_howto_la_CXXFLAGS =                   \
+_howto_swig_la_CXXFLAGS =              \
        $(STD_SWIG_CXX_FLAGS)           \
        $(howto_la_swig_cxxflags)
 
 howto_python_PYTHON =                  \
-       howto.py                        \
+       howto_swig.py                   \
        $(howto_python)
 
 ## Entry rule for running SWIG
 
-howto.h howto.py howto.cc: howto.i
+howto.h howto_swig.py howto_swig.cc: howto.i
 ## This rule will get called only when MAKE decides that one of the
 ## targets needs to be created or re-created, because:
 ##
@@ -202,7 +202,7 @@ $(DEPDIR)/howto-generate-stamp:
 ##
        if $(SWIG) $(STD_SWIG_PYTHON_ARGS) $(howto_swig_args) \
                -MD -MF $(DEPDIR)/howto.Std \
-               -module howto -o howto.cc $(WHAT); then \
+               -module howto_swig -o howto_swig.cc $(WHAT); then \
            if test $(host_os) = mingw32; then \
                $(RM) $(DEPDIR)/howto.Sd; \
                $(SED) 's,\\\\,/,g' < $(DEPDIR)/howto.Std \