summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/python/gnuradio
diff options
context:
space:
mode:
Diffstat (limited to 'gnuradio-runtime/python/gnuradio')
-rw-r--r--gnuradio-runtime/python/gnuradio/__init__.py34
-rw-r--r--gnuradio-runtime/python/gnuradio/gr/CMakeLists.txt14
-rw-r--r--gnuradio-runtime/python/gnuradio/gr/__init__.py13
-rw-r--r--gnuradio-runtime/python/gnuradio/gr/tag_utils.py7
4 files changed, 58 insertions, 10 deletions
diff --git a/gnuradio-runtime/python/gnuradio/__init__.py b/gnuradio-runtime/python/gnuradio/__init__.py
index d55dac79db..c0274656d1 100644
--- a/gnuradio-runtime/python/gnuradio/__init__.py
+++ b/gnuradio-runtime/python/gnuradio/__init__.py
@@ -10,3 +10,37 @@ GNU Radio is licensed under the GNU General Public License (GPL) version 3. All
# This file makes gnuradio a package
# The docstring will be associated with the top level of the package.
+
+import os
+
+# Check if the gnuradio package is installed or whether we're attempting to import it from
+# the build directory.
+path_ending = os.path.join('gnuradio-runtime', 'python', 'gnuradio', '__init__.py')
+path = os.path.abspath(__file__)
+if path.endswith('.pyc'):
+ path = path[:-1]
+
+if path.endswith(path_ending):
+ # We importing it from build directory.
+ build_path = os.path.join(path[:-len(path_ending)])
+
+ # Place these directories on __path__ so that their contents are
+ # part of the gnuradio package.
+ __path__.append(os.path.join(build_path, 'gr-utils', 'src', 'python'))
+ __path__.append(os.path.join(build_path, 'gr-blocks', 'python'))
+ __path__.append(os.path.join(build_path, 'gr-digital', 'python'))
+ __path__.append(os.path.join(build_path, 'gr-filter', 'python'))
+ __path__.append(os.path.join(build_path, 'gr-fft', 'python'))
+ __path__.append(os.path.join(build_path, 'gr-analog', 'python'))
+ __path__.append(os.path.join(build_path, 'gr-trellis', 'python'))
+ __path__.append(os.path.join(build_path, 'gr-wavelet', 'python'))
+ #__path__.append(os.path.join(build_path, 'gr-audio', 'python'))
+ __path__.append(os.path.join(build_path, 'gr-qtgui', 'python'))
+ __path__.append(os.path.join(build_path, 'gr-wxgui', 'python'))
+ #__path__.append(os.path.join(build_path, 'gr-atsc', 'python'))
+ __path__.append(os.path.join(build_path, 'gr-noaa', 'python'))
+ __path__.append(os.path.join(build_path, 'gr-pager', 'python'))
+ __path__.append(os.path.join(build_path, 'gr-video-sdl', 'python'))
+ __path__.append(os.path.join(build_path, 'gr-vocoder', 'python'))
+ __path__.append(os.path.join(build_path, 'gr-fcd', 'python'))
+ __path__.append(os.path.join(build_path, 'gr-comedi', 'python'))
diff --git a/gnuradio-runtime/python/gnuradio/gr/CMakeLists.txt b/gnuradio-runtime/python/gnuradio/gr/CMakeLists.txt
index 2be4d4a0f3..7f9c19500b 100644
--- a/gnuradio-runtime/python/gnuradio/gr/CMakeLists.txt
+++ b/gnuradio-runtime/python/gnuradio/gr/CMakeLists.txt
@@ -38,10 +38,16 @@ GR_PYTHON_INSTALL(FILES
# Handle the unit tests
########################################################################
if(ENABLE_TESTING)
-include(GrTest)
-file(GLOB py_qa_test_files "qa_*.py")
-foreach(py_qa_test_file ${py_qa_test_files})
+ set(GR_TEST_TARGET_DEPS "")
+ set(GR_TEST_LIBRARY_DIRS "")
+ set(GR_TEST_PYTHON_DIRS
+ ${CMAKE_BINARY_DIR}/gruel/src/python
+ ${CMAKE_BINARY_DIR}/gnuradio-core/src/python
+ )
+ include(GrTest)
+ file(GLOB py_qa_test_files "qa_*.py")
+ foreach(py_qa_test_file ${py_qa_test_files})
get_filename_component(py_qa_test_name ${py_qa_test_file} NAME_WE)
GR_ADD_TEST(${py_qa_test_name} ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} ${py_qa_test_file})
-endforeach(py_qa_test_file)
+ endforeach(py_qa_test_file)
endif(ENABLE_TESTING)
diff --git a/gnuradio-runtime/python/gnuradio/gr/__init__.py b/gnuradio-runtime/python/gnuradio/gr/__init__.py
index 20a8f97f63..94a5c9ec2b 100644
--- a/gnuradio-runtime/python/gnuradio/gr/__init__.py
+++ b/gnuradio-runtime/python/gnuradio/gr/__init__.py
@@ -28,7 +28,18 @@ Core contents.
# This is the main GNU Radio python module.
# We pull the swig output and the other modules into the gnuradio.gr namespace
-from runtime_swig import *
+# If gnuradio is installed then the swig output will be in this directory.
+# Otherwise it will reside in ../../../swig.
+
+import os
+
+try:
+ from runtime_swig import *
+except ImportError:
+ dirname, filename = os.path.split(os.path.abspath(__file__))
+ __path__.append(os.path.join(dirname, "..", "..", "..", "swig"))
+ from runtime_swig import *
+
from exceptions import *
from top_block import *
from hier_block2 import *
diff --git a/gnuradio-runtime/python/gnuradio/gr/tag_utils.py b/gnuradio-runtime/python/gnuradio/gr/tag_utils.py
index e35564c1eb..c25ed8d772 100644
--- a/gnuradio-runtime/python/gnuradio/gr/tag_utils.py
+++ b/gnuradio-runtime/python/gnuradio/gr/tag_utils.py
@@ -22,10 +22,7 @@
import pmt
-try:
- from gnuradio import gr
-except ImportError:
- from runtime_swig import tag_t
+from gnuradio import gr
class PythonTag(object):
" Python container for tags "
@@ -46,7 +43,7 @@ def tag_to_python(tag):
def tag_to_pmt(tag):
""" Convert a Python-readable object to a stream tag """
- newtag = tag_t()
+ newtag = gr.tag_t()
newtag.offset = tag.offset
newtag.key = pmt.to_python(tag.key)
newtag.value = pmt.from_python(tag.value)