diff options
Diffstat (limited to 'gnuradio-runtime/python')
-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 | 5 | ||||
-rw-r--r-- | gnuradio-runtime/python/pmt/__init__.py | 10 | ||||
-rwxr-xr-x | gnuradio-runtime/python/pmt/qa_pmt.py | 2 |
6 files changed, 67 insertions, 11 deletions
diff --git a/gnuradio-runtime/python/gnuradio/__init__.py b/gnuradio-runtime/python/gnuradio/__init__.py index d55dac79db..de9f20f71b 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-core', 'src', '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 cd57704930..5b75f7f4f6 100644 --- a/gnuradio-runtime/python/gnuradio/gr/CMakeLists.txt +++ b/gnuradio-runtime/python/gnuradio/gr/CMakeLists.txt @@ -37,10 +37,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 c1d6c87629..bb55a1095f 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, "..", "..", "..", "lib", "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 8de7110e3f..5caa10bd21 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 gr_tag_t +from gnuradio.gr import gr_tag_t class PythonTag(object): " Python container for tags " diff --git a/gnuradio-runtime/python/pmt/__init__.py b/gnuradio-runtime/python/pmt/__init__.py index bc933e80a5..0d995c24a4 100644 --- a/gnuradio-runtime/python/pmt/__init__.py +++ b/gnuradio-runtime/python/pmt/__init__.py @@ -25,7 +25,15 @@ The GNU Radio Utility Etcetera Library's Polymorphic Types for Python. ''' -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): |