diff options
Diffstat (limited to 'gnuradio-runtime')
-rw-r--r-- | gnuradio-runtime/python/gnuradio/__init__.py | 34 | ||||
-rw-r--r-- | gnuradio-runtime/python/gnuradio/gr/CMakeLists.txt | 14 | ||||
-rw-r--r-- | gnuradio-runtime/python/gnuradio/gr/__init__.py | 13 | ||||
-rw-r--r-- | gnuradio-runtime/python/gnuradio/gr/tag_utils.py | 7 | ||||
-rw-r--r-- | gnuradio-runtime/python/pmt/__init__.py | 10 | ||||
-rwxr-xr-x | gnuradio-runtime/python/pmt/qa_pmt.py | 2 |
6 files changed, 68 insertions, 12 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) diff --git a/gnuradio-runtime/python/pmt/__init__.py b/gnuradio-runtime/python/pmt/__init__.py index 7900a6e7a8..00940e4cc1 100644 --- a/gnuradio-runtime/python/pmt/__init__.py +++ b/gnuradio-runtime/python/pmt/__init__.py @@ -39,7 +39,15 @@ bool, symbol (string), integer, real, complex, null, pair, list, vector, dict, uniform_vector, any (boost::any cast) ''' -from pmt_swig import * +import os + +try: + from pmt_swig import * +except ImportError: + dirname, filename = os.path.split(os.path.abspath(__file__)) + __path__.append(os.path.join(dirname, "..", "..", "swig")) + from pmt_swig import * + from pmt_to_python import pmt_to_python as to_python from pmt_to_python import python_to_pmt as to_pmt diff --git a/gnuradio-runtime/python/pmt/qa_pmt.py b/gnuradio-runtime/python/pmt/qa_pmt.py index 75e112678b..2a72fa6089 100755 --- a/gnuradio-runtime/python/pmt/qa_pmt.py +++ b/gnuradio-runtime/python/pmt/qa_pmt.py @@ -21,7 +21,7 @@ # import unittest -import pmt_swig as pmt +import pmt class test_pmt(unittest.TestCase): |