gnuradio / pybombs

PyBOMBS (Python Build Overlay Managed Bundle System) is the GNU Radio install management system for resolving dependencies and pulling in out-of-tree projects.
https://gnuradio.org
GNU General Public License v3.0
415 stars 190 forks source link

A more versatile setup_env.sh #431

Open jaredd opened 7 years ago

jaredd commented 7 years ago

Often I find that I install OOT modules to a directory separate from my base gnuradio install in order to keep my base GR install clean and make nuking my OOT easy if I need to completely rebuild and reinstall. The setup_env.sh is almost appropriate for also adding the OOT paths to the environment to pull in those blocks and libs except it explicitly uses the prefix directory in its paths. Below is a portion of an (annotated) alternative setup_env.sh that could be copied to the appropriate OOT directory and operate as desired.

#!/bin/bash

# path to this file
OWNPATH=$(dirname $(realpath ${BASH_SOURCE[0]}))

# activate virtualenv first, shouldn't GR paths precede VE paths?
# If we're in a Python virtualenv, activate that
if [ -r $OWNPATH/bin/activate ]; then
    source $OWNPATH/bin/activate
fi

# change the IFS to do splitting / assembly with colons, save old IFS
OIFS=$IFS
export IFS=':'
# use path globs which are clearer than giant paragraph of paths
paths=($OWNPATH/{lib,lib64}/python{2.6,2.7}/{site,dist}-packages $PYTHONPATH)
# the following expands with colons b/w elements b/c IFS=':'
PYTHONPATH="${paths[*]}"
#
# repeat for other env vars
#
# restore IFS
export IFS=$OIFS

export PATH PYTHONPATH LD_LIBRARY_PATH LIBRARY_PATH PKG_CONFIG_PATH
if [ -d $OWNPATH/.pybombs ]; then
  export PYBOMBS_PREFIX=$OWNPATH
fi
mbr0wn commented 7 years ago

This looks like it's not portable to some other shells, but I like some of the concepts.

jaredd commented 7 years ago

For this to truly work there needs to be some extra support for environment variable management from the virtualenv scripts. I'll see what I can do there. In the meantime, why can't there be several templates for scripts for different shells? I feel like this is something that won't have to be updated too often (famous last words). The setup-env scripts will also need an "undo" feature so one can switch b/w different OOT mixins through the environment.

giladbeeri commented 7 years ago

This will also help with moving prefixes, see #422