Python blocks in a new package

I’ve been creating a new package, called tdrss, based on the examples
in gr-howto-write-a-block-3.1.1. The C++ blocks in src/lib and the
QA tests in src/python all work fine, but I’ve been having a problem
intalling the one Python block I wrote.

It’s in a subdir called tdrss_utils that is under src/python. I
added a line “SUBDIR = tdrss_utils” to the Makefile.am in src/python,
put a copy of init.py in src/python/tdrss_utils, and
created a Makefile.am in src/python/tdrs_utils containing:


include $(top_srcdir)/Makefile.common

Install this stuff so that it ends up as the gnuradio.tdrss_utils

module

This usually ends up at:

#${prefix}/lib/python${python_version}/site-packages/gnuradio/tdrss_utils

tdrss_utilspythondir = $(grpythondir)/tdrss_utils
tdrss_utilslibdir = $(grpyexecdir)/tdrss_utils

tdrss_utilspython_PYTHON =
init.py
gold_code_pn_source_b.py

CLEANFILES = *.pyc


If I run bootstrap, no Makefile.in or Makefile get created,
and when I run make, I get:

Making all in python
Making all in tdrss_utils
make[4]: *** No rule to make target `all’. Stop.

What automake magic am I missing?

@(^.^)@ Ed

Ed Criscuolo wrote:

What automake magic am I missing?

You need to add one line to configure.ac specifying the new makefile.
It’s near the bottom.


Johnathan C.
Corgan Enterprises LLC
http://corganenterprises.com

Johnathan C. wrote:

You need to add one line to configure.ac specifying the new makefile.
It’s near the bottom.

Thanks Jonathan. That got the Makefile.in and the Makefile constructed.

The make install succeeded, but I only ended up with a file called
gold_code_pn_source_b.py in …/site-packages/gnuradio/tdrss_utils .

The .pyc and .pyo files were missing, and any attempt to reference
tdrss_utils.gold_code_pn_source_b() from a python program fails
with the message

AttributeError: ‘module’ object has no attribute
‘gold_code_code_pn_source_b’

@(^.^)@ Ed

On Tue, Nov 20, 2007 at 04:04:49PM -0500, Ed Criscuolo wrote:

gold_code_pn_source_b.py in …/site-packages/gnuradio/tdrss_utils .

The .pyc and .pyo files were missing, and any attempt to reference
tdrss_utils.gold_code_pn_source_b() from a python program fails
with the message

AttributeError: ‘module’ object has no attribute
‘gold_code_code_pn_source_b’

You need to install an empty init.py in to your tdrss_utils
directory.

See http://docs.python.org/tut/node8.html#SECTION008400000000000000000

for info on Python packages.

Eric

Eric B. wrote:

You need to install an empty init.py in to your tdrss_utils
directory.

I already have an empty init.py there. I did find why I
wasn’t getting the .pyc & .pyo files. There was a syntax error in
my python block, but the error was geting lost in the huge voulme
of stuff that comes out during a make!

I fixed it, and I now end up with .py, .pyc, and .pyo files for
both init and gold_code_pn_source_b installed in the
…/site-packages/gnuradio/tdrss_utils/ directory.

But when I write any python code containing

from gnuradio import tdrss_utils



pn = tdrss_utils.gold_code_pn_source_b(11, 1, 1, 1, 1)

I still get the error

AttributeError: ‘module’ object has no attribute
‘gold_code_pn_source_b’

Any other ideas? I’m stumped!

On Wed, Nov 21, 2007 at 10:59:06PM -0500, Ed Criscuolo wrote:

of stuff that comes out during a make!

pn = tdrss_utils.gold_code_pn_source_b(11, 1, 1, 1, 1)

I still get the error

AttributeError: ‘module’ object has no attribute
‘gold_code_pn_source_b’

Any other ideas? I’m stumped!

$ python

from gnuradio import tdrss_utils
dir(tdrss_utils)

Do you see your module(s) in there or something unexpected?

Eric

Eric B. wrote:

$ python

from gnuradio import tdrss_utils
dir(tdrss_utils)

Do you see your module(s) in there or something unexpected?

When I try the above, all I see is
[‘builtins’, ‘doc’, ‘file’, ‘name’, ‘path’]

No trace of ‘gold_code_pn_source_b’

Here’s the listing of …/site-packages/gnuradio/tdrss_utils:

-rw-r–r-- 1 root wheel 22 Nov 21 23:41 init.py
-rw-r–r-- 1 root wheel 151 Nov 21 23:41 init.pyc
-rw-r–r-- 1 root wheel 151 Nov 21 23:41 init.pyo
-rw-r–r-- 1 root wheel 1459 Nov 21 23:41 gold_code_pn_source_b.py
-rw-r–r-- 1 root wheel 1131 Nov 20 16:56 gold_code_pn_source_b.pyc
-rw-r–r-- 1 root wheel 1131 Nov 20 16:56 gold_code_pn_source_b.pyo

@(^.^)@ Ed

Eric B. wrote:

Where’s the shared library (.so file)?

There is no shared library in tdrss_utils. Should there be?
It only has the one python module, nothing in C++.

I have a separate package called “tdrss” which contains all
the processing blocks written in C++. Those all work and
pass their QA tests when I do a “make check”.

In …/site-packages/gnuradio/ there is:

_tdrss.la
_tdrss.so
tdrss.py
tdrss.pyc
tdrss.pyo
tdrss_utils/

Is there some way to put it all in one package? When I tried
this by doing a “make” and “make install” with the directory named
…tdrss/src/python/tdrss/, I couldn’t import any of my C++ modules.
As soon as I changed the name to …tdrss/src/python/tdrss_utils/
that problem went away.

@(^.^)@ Ed

On Tue, Nov 27, 2007 at 10:11:51AM -0500, Ed Criscuolo wrote:

-rw-r–r-- 1 root wheel 151 Nov 21 23:41 init.pyc
-rw-r–r-- 1 root wheel 151 Nov 21 23:41 init.pyo
-rw-r–r-- 1 root wheel 1459 Nov 21 23:41 gold_code_pn_source_b.py
-rw-r–r-- 1 root wheel 1131 Nov 20 16:56 gold_code_pn_source_b.pyc
-rw-r–r-- 1 root wheel 1131 Nov 20 16:56 gold_code_pn_source_b.pyo

Where’s the shared library (.so file)?