GRC request

I would like to be able to execute GRC from a directory structure
moved elsewhere from ${prefix} … meaning, I compile and install into
${prefix}, but then ‘cp -r’ or ‘mv’ or ‘tar - | tar -’ the whole
directory structure elsewhere outside of the usual execution
location. I then create / modify the environment variables such that
they point to the new location (PATH, PYTHONPATH, and
DYLD_LIBRARY_PATH are the 3 primary ones for OSX). From my initial
testing, the rest of GNU Radio can do this with just those 3 variables
(on OSX; Y-Variables-MV on other platforms)

This doesn’t work because GRC hard-wires the install path (or
something like it) in a few files (I do not know if all of these files
need to be modified to get what I’d like to do working; nor do I know
if these are all of the files that need to be tweaked):

grc/freedesktop/grc_setup_freedesktop.in
grc/src/platforms/base/Constants.py.in
grc/src/platforms/python/Constants.py.in

I can think of two possible solutions:

  1. Put a switch at the top of each of these files along the lines of:

import os
DATA_DIR = os.getenv (“GRC_DATADIR”)
if not DATA_DIR:
DATA_DIR = @datadir@

or the equivalent functionality that would work for the @variables@
used in that file (I don’t know if the above would work; it is for
descriptive purposes only): first check the user’s shell environment
for the appropriate variables, and if they don’t exist, then revert to
the default from compiling. This way, users who wish to change the
location can do so easily via their shell environment, and those who
do not set the shell environment variables get the default – same as
current usage.

  1. Even better would be the use of relative paths (it does work for
    me, directly modifying the installed files). This solution would
    require knowing the path to $sharedir and the $pythondir and then
    figuring out how to get from one to the other (the relative path), but
    IMHO is the more elegant solution.

Thanks in advance! - MLD

Im not a huge fan of the hard-coded directories, i think it might be
kind of nice to have a data_dir_prefix that would default to whatever
automake/autoconf says, but also takes queues from an environment
variable…so

I know this is possible, but I am a bit confused about why. Woulnt it be
easier to modify $(datadir) via ./configure --datadir=xxx, and use the
whole automake system for gnuradio? What are you attempting to do,
making a distributable package?

-Josh

if not DATA_DIR:
DATA_DIR = @datadir@

and because we like one-liners :slight_smile:

import os
DATA_DIR = os.environ.get(“GRC_DATADIR”, @datadir@)