"How to Write a Signal Processing Block" vagueness

Eric (or anyone, really),

I’m trying to follow “How to Write a Signal Processing Block” and I
have a question about getting started.

In the guide, you say “The good news is that we provide boilerplate
that can be used pretty much as-is” and I assume you are referring to
ftp://ftp.gnu.org/gnu/gnuradio/gr-howto-write-a-block-3.0.2.tar.gz

It seems like in the tarball that the autotools have already been run,
because there is no bootstrap file, but there is a configure script,
when I follow the steps like running ‘make check’ after I do a
./configure everything works fine, but that means that I can’t change
the names of the files if I wanted to make a new block because
configure explicitly looks for the ‘howto’ files.

So I guess my question boils down to ( is there different
‘boilerplate’ for new blocks ) or ( how do I change the autotools
stuff in the tarball to make it pay attention to my changes?).

Thanks,

Jason

Jason U. wrote:

In the guide, you say “The good news is that we provide boilerplate
that can be used pretty much as-is” and I assume you are referring to
ftp://ftp.gnu.org/gnu/gnuradio/gr-howto-write-a-block-3.0.2.tar.gz

Yes (there is a newer version than that however.)

It seems like in the tarball that the autotools have already been run,
because there is no bootstrap file, but there is a configure script,
when I follow the steps like running ‘make check’ after I do a
./configure everything works fine, but that means that I can’t change
the names of the files if I wanted to make a new block because
configure explicitly looks for the ‘howto’ files.

Beginning with release 3.1.3, the bootstrap script will be included in
the tarball so you can run it if you have autotools installed and want
to make these sorts of changes. In the interim, you can copy the script
from the trunk which will work just fine:

http://gnuradio.org/trac/browser/gnuradio/trunk/bootstrap

Thanks, I was able to create a new block with a different name by
changing the various .am and .ac files then re-running bootstrap.

Lastly, the FAQ doesn’t really touch on the issue of actually using
the blocks once they are written.

I did a make install and it installed the files in
/usr/local/lib/python2.4/site-packages/gnuradio/, which is in my
PYTHONPATH, however I consistently get

from gnuradio import my_new_package
Traceback (most recent call last):
File “”, line 1, in ?
ImportError: cannot import name my_new_package

What steps do I need to take so my new block is accessible to gnuradio?

Thanks
Jason

Python is looking for a module literally named “my_new_package”. You
should simply substitute “my_new_package” with whatever Python module/
file (e.g. cool_block.py) that you write. And you might want to
create/keep your module in a local directory and simply append that
directory path to your PYTHONPATH environment variable.

-Randy

On Tue, Aug 19, 2008 at 11:03:42AM -0500, Jason U. wrote:

In that directory I have the following (from make install)
_my_new_package.la
_my_new_package.so
my_new_package.py
my_new_package.pyc
my_new_package.pyo

Is the rest of the gnuradio stuff there?

Does

from gnuradio import gr

work?

Are you on a 64-bit machine?

Can you send the complete backtrace that you get when you try the
import?

simply ‘make install’ again (overwrite), or do I have to make
uninstall the old module before I edit it?

Generally make install is suffcient.

Eric

Is the rest of the gnuradio stuff there?

No, it is in /opt/local/lib/python2.4/site-packages (OSX install)

If Python finds ‘gnuradio’ in /opt/local/lib/python2.4/site-packages
(which is before /usr/local/lib/python2.4/site-packages/ in the path)
and does not find ‘my_new_package’; does it not check
/usr/local/lib/python2.4/site-packages/gnuradio/ since it has already
‘found’ the gnuradio package?

Does from gnuradio import gr work?

Yes

Are you on a 64-bit machine?

No

Can you send the complete backtrace that you get when you try the import?

I’m not sure how to do that, do you mean this? :

from gnuradio import my_new_package
Traceback (most recent call last):
File “”, line 1, in ?
ImportError: cannot import name my_new_package

Lastly, if I do change the new module later, is it sufficient to
simply ‘make install’ again (overwrite), or do I have to make
uninstall the old module before I edit it?

Generally make install is suffcient.

Thank you, I’ll do that when updating.

Jason

Can you send the complete backtrace that you get when you try the import?

I’m not sure how to do that, do you mean this? :

from gnuradio import my_new_package
Traceback (most recent call last):
File “”, line 1, in ?
ImportError: cannot import name my_new_package

As an update, if I add “path_to_top_dir/src/lib” to my PYTHONPATH and
attempt an ‘import my_new_package’ I get the following:

import my_new_package
Traceback (most recent call last):
File “”, line 1, in ?
File “/(path_to_top_dir)/src/lib/my_new_package.py”, line 6, in ?
import _my_new_package
ImportError: No module named _my_new_package

I noticed that the there is no _my_new_package.so in the src folder,
and I couldn’t find one in the build directory anywhere (but it is the
install directory when I make install), if I were to ‘make uninstall’
and just point PYTHONPATH to the build directory, where would I point
it so I could do an ‘import my_new_package’ from python?

Jason
Jason

I noticed that the there is no _my_new_package.so in the src folder,
and I couldn’t find one in the build directory anywhere (but it is the
install directory when I make install), if I were to ‘make uninstall’
and just point PYTHONPATH to the build directory, where would I point
it so I could do an ‘import my_new_package’ from python?

I’m sorry, I didn’t look at run_tests closely enough,

I have now added /both/ “path_to_top_dir/src/lib” and
“path_to_top_dir/src/lib/.libs” both to PYTHONPATH and it works fine.

Jason

On Tue, Aug 19, 2008 at 02:41:29PM -0500, Jason U. wrote:

Is the rest of the gnuradio stuff there?

No, it is in /opt/local/lib/python2.4/site-packages (OSX install)

If Python finds ‘gnuradio’ in /opt/local/lib/python2.4/site-packages
(which is before /usr/local/lib/python2.4/site-packages/ in the path)
and does not find ‘my_new_package’; does it not check
/usr/local/lib/python2.4/site-packages/gnuradio/ since it has already
‘found’ the gnuradio package?

Add an empty file init.py to:

/usr/local/lib/python2.4/site-packages/gnuradio/

Eric

On Mon, Aug 18, 2008 at 9:41 PM, Randy H. [email protected]
wrote:

Python is looking for a module literally named “my_new_package”. You should
simply substitute “my_new_package” with whatever Python module/file (e.g.
cool_block.py) that you write. And you might want to create/keep your
module in a local directory and simply append that directory path to your
PYTHONPATH environment variable.

Right, but I think the package is literally named “my_new_package”
“/usr/local/lib/python2.4/site-packages/gnuradio/” is in my PYTHONPATH;
In that directory I have the following (from make install)
_my_new_package.la
_my_new_package.so
my_new_package.py
my_new_package.pyc
my_new_package.pyo

My .i file specified the module as
“GR_SWIG_BLOCK_MAGIC(my_new_package,tx_encoder)”

As for appending to PYTHONPATH, I tried that first and got the same
error, so I figured a make install would fix it.

Is there something that I need to update a file somewhere so python
can find these?

Lastly, if I do change the new module later, is it sufficient to
simply ‘make install’ again (overwrite), or do I have to make
uninstall the old module before I edit it?

Thanks
Jason

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs